California Penal Code Section 1332 Interpretation
In California, as applicable to witnesses deemed material for trial, this principle is embodied in Penal Code section 1332.
Section 1332 provides:
"(a) Notwithstanding the provisions of Sections 878 to 883, inclusive, when the court is satisfied, by proof on oath, that there is good cause to believe that any material witness for the prosecution or defense, whether the witness is an adult or a minor, will not appear and testify unless security is required, at any proceeding in connection with a wardship petition pursuant to Section 602 of the Welfare and Institutions Code, the court may order the witness to enter into a written undertaking to the effect that he or she will appear and testify at the time and place ordered by the court or that he or she will forfeit an amount the court deems proper.
(b) If the witness required to enter into an undertaking to appear and testify, either with or without sureties, refuses compliance with the order for that purpose, the court may commit the witness, if an adult, to the custody of the sheriff, and if a minor, to the custody of the probation officer or other appropriate agency, until the witness complies or is legally discharged.
(c) When a person is committed pursuant to this section, he or she is entitled to an automatic review of the order requiring a written undertaking and the order committing the person, by a judge or magistrate having jurisdiction over the offense other than the one who issued the order. This review shall be held not later than two days from the time of the original order of commitment.
(d) If it is determined that the witness must remain in custody, the witness is entitled to a review of that order after 10 days. (e) When a witness has entered into an undertaking to appear, upon his or her failure to do so the undertaking is forfeited in the same manner as undertakings of bail."
Under that section, on an appropriate sworn showing, a trial court may detain a material witness when it finds good cause to believe that the witness will not attend the trial and testify.
However, the statute does not confer unfettered discretion to incarcerate a material witness.
In article I, section 10, the California Constitution states in relevant part that "[w]itnesses may not be unreasonably detained."