If it appears to the court, by affidavit or otherwise, or upon inspection of the process or warrant of commitment and proceedings as may be shown to the court, that the party is guilty of a criminal offense or ought not to be discharged, such court, although the charge is defectively or not substantially set forth in such process or warrant of commitment, must cause the complainant or other necessary witness to be subpoenaed to attend at such time as ordered, to testify before the court, and upon the examination the judge may discharge such party, admit the party to bail if the offense is bailable, or recommit the party to custody, as may be just and legal.
N.D.C.C. § 32-22-19