(a) Any witness required under this chapter to enter into an undertaking, with or without surety, may be committed to jail on failure or refusal to do so.
(b) In cases arising under subsection (a) of this section, the court must state in the commitment the amount of the undertaking and whether surety is required; and the witness must be discharged by the sheriff on entering into the undertaking as required.