If a witness, required to enter into an undertaking to appear and testify, either with or without sureties, refuse compliance with the order for that purpose, the magistrate must commit him to prison until he comply, or is legally discharged.
R.L.1910, § 5689.