Upon a plea of guilty or nolo contendere to an accusatory pleading charging a felony, other than a violation of paragraph (2), (3), or (6) of subdivision (a) of Section 261, paragraph (1) or (4) of subdivision (a) of Section 262, Section 264.1, Section 286 or 287 or former Section 288a by force, violence, duress, menace or threat of great bodily harm, subdivision (b) of Section 288, or subdivision (a) of Section 289, the plea may specify the punishment to the same extent as it may be specified by the jury on a plea of not guilty or fixed by the court on a plea of guilty, nolo contendere, or not guilty, and may specify the exercise by the court thereafter of other powers legally available to it.
Where the plea is accepted by the prosecuting attorney in open court and is approved by the court, the defendant, except as otherwise provided in this section, cannot be sentenced on the plea to a punishment more severe than that specified in the plea and the court may not proceed as to the plea other than as specified in the plea.
If the court approves of the plea, it shall inform the defendant prior to the making of the plea that (1) its approval is not binding, (2) it may, at the time set for the hearing on the application for probation or pronouncement of judgment, withdraw its approval in the light of further consideration of the matter, and (3) in that case, the defendant shall be permitted to withdraw his or her plea if he or she desires to do so. The court shall also cause an inquiry to be made of the defendant to satisfy itself that the plea is freely and voluntarily made, and that there is a factual basis for the plea.
If the plea is not accepted by the prosecuting attorney and approved by the court, the plea shall be deemed withdrawn and the defendant may then enter the plea or pleas as would otherwise have been available.
If the plea is withdrawn or deemed withdrawn, it may not be received in evidence in any criminal, civil, or special action or proceeding of any nature, including proceedings before agencies, commissions, boards, and tribunals.
Ca. Pen. Code § 1192.5