Any person subpoenaed to appear before any court of record of this state, or justice of the peace, to give evidence in any case brought before the court or justice shall attend each and every term, or from time to time, until the case is decided, or until the witness is discharged by the court or justice trying the case.