When an indictment or information is dismissed after the sustaining of a demurrer, or at any other stage of the proceedings because of any defect or insufficiency of the indictment or information, if the court directs that the case be resubmitted to the same or another grand jury or that a new information be filed, the defendant shall not be discharged from custody, nor the defendant's bail exonerated nor money or other property deposited instead of bail on the defendant's behalf refunded, but the same proceedings must be had on such direction as are prescribed in Sections 997 and 998.
Ca. Pen. Code § 1010