
    The Honorable Thomas F. GREENWELL, Judge of the 319th District Court, Relator, v. THE COURT OF APPEALS FOR THE THIRTEENTH JUDICIAL DISTRICT.
    No. AP-75017.
    Court of Criminal Appeals of Texas.
    Feb. 9, 2005.
    
      Joseph V. Colhna, Corpus Christi, for Appellant.
    Douglas K. Norman, Asst. District Atty., Corpus Christi, Matthew Paul, State’s Atty., Austin, for State.
   OPINION

KELLER, P.J.,

delivered the opinion of the unanimous Court.

This mandamus action arises from a court of appeals’s order requiring a trial court to amend its “certification of the defendant’s right of appeal.” We will grant relief.

I. BACKGROUND

A. Procedural history

Defendant Brian Ernst was indicted for indecency with a child. He entered into a pretrial diversion agreement with the State, and his indictment was dismissed. A little over a year later, the State filed a notice of noncompliance, alleging that the defendant had broken the terms of the agreement, and Ernst was subsequently re-indicted. He filed a pretrial motion to dismiss the indictment. His motion argued, among other things, that he had “substantially completed the requirements” of the pretrial diversion agreement. No order or other explicit ruling on this motion appears in the record.

The defendant also filed a pretrial application for writ of habeas corpus raising the same issue. The trial court held a hearing on the merits of the application. At the end of the hearing, the trial court stated that it would consider the case law and the parties’ briefs and would rule on the habe-as application by the end of the week. The record contains no written order concerning the habeas application, but there is a docket entry noting that the trial court denied relief on the same day as the hearing on the merits.

Ernst later pled guilty pursuant to a plea bargain, which the trial court followed. The defendant filed a notice of appeal on May 8, 2002. On July 21, 2003, the court of appeals abated the appeal and ordered the trial court to supplement the record with a “certification of the defendant’s right of appeal.” The trial court supplemented the record with a certification indicating that the case is a plea bargain case and the defendant has no right of appeal.

B. Court of Appeals order

The court of appeals issued an order requiring the trial court to amend the certification to say that the case “is a plea bargain case, but matters were raised by written motion filed and ruled on before trial and not withdrawn or waived, and the defendant has the right of appeal.” The appellate court reasoned that “insofar as both the motion to dismiss and the application for habeas corpus urged the same ground for relief, the trial court’s ruling on [the defendant’s] habeas corpus application was an implicit ruling on his motion to dismiss [the indictment].” Under this reasoning, the defendant’s motion to dismiss triggered his right of appeal because the motion to dismiss was a written motion ruled upon before trial. In response to Justice Castillo’s dissent, the court of appeals suggested that the trial court’s denial of the habeas action showed that it had informally overruled the motion to dismiss.

C. Request for mandamus relief

The trial judge, the Honorable Thomas Greenwell, has filed a petition for mandamus relief. Among other things, the trial judge complains that the court of appeals “clearly abused its discretion in ordering the trial court to certify that the defendant has a right to appeal in a plea-bargained case based on a pretrial motion on which the trial court never ruled.” We now consider that contention.

II. ANALYSIS

A. Overview

When mandamus is sought to require a court to withdraw an order, the relator must demonstrate that: (1) there is no other adequate legal remedy, and (2) there is a clear and indisputable right to the relief sought. Under the rules of appellate procedure, an “appeal must be dismissed if a certification that shows the defendant has the right of appeal has not been made part of the record under these rules.” A defendant who enters a plea bargain may appeal only:

(A) those maters that were raised by written motion filed and ruled on before trial,
or
(B) after getting the trial court’s permission to appeal.

No one disputes that the trial court did not give permission to appeal as required by subsection (B). The question before us is whether the court of appeals’s order to change the certification form to show that appellant met the requirement in subsection (A) entitles relator to mandamus relief.

B. No adequate remedy

There is no provision for obtaining immediate review of the court of appeals’s interlocutory order. If we did not give relief on mandamus and the court of appeals ultimately reversed the conviction, the State could then seek review by way of petition for discretionary review in this Court. But potential review at a later time is not always or automatically an adequate remedy: “In some cases, a remedy at law may technically exist; however, it may nevertheless be so uncertain, tedious, burdensome, slow, inconvenient, inappropriate, or ineffective as to be deemed inadequate.” When, for instance, a trial court erroneously removed appointed counsel before trial, we found that the defendant had no adequate remedy, for mandamus purposes, despite the availability of appeal sometime after trial. Using “the appellate process in this situation to correct this particular ill would be too burdensome and would only aggravate the harm and most likely would result in a new trial compelling relator to again endure a trip through the system.” In the pretrial habeas corpus context, we have found that appeal after trial was not an adequate remedy for certain double jeopardy claims because protection of the constitutional right of double jeopardy requires review before exposure to jeopardy occurs.

Similar considerations are present here. The purpose of the certification requirement is to efficiently sort appealable cases from non-appealable cases. Certification allows appealable cases to move through the system unhindered while eliminating, at an early stage, the time and expense associated with non-appealable cases. When appeal is barred by Texas Rule of Appellate Procedure 25.2(a)(2), the clerk’s and court reporter’s records need not be prepared, counsel need not be appointed, and briefs need not be filed. On the other hand, if there is something in whatever record does exist that indicates that an appellant has the right to appeal, the court of appeals must determine whether the certification is deficient and resolve the conflict.

Delaying review of a court of appeals’s order that allows an appeal to proceed would frustrate the purpose of furthering judicial economy by requiring all the actions — appointment of counsel, preparation of the record, filing of briefs, and other proceedings before a court of appeals— that the certification requirement was designed to prevent. One purpose of the certification requirement is to permit earlier identification of an appeal from a defendant who has no right to appeal. The 1977 legislation that restricted the right of plea-bargainers to appeal and curtailed the right to bail pending appeal “were aimed at eliminating, or reducing, the ability of plea-bargaining defendants to delay the execution of their sentences by taking meritless appeals.” That purpose would be frustrated in this case if the State had no remedy until the court of appeals considered the merits of appellant’s appeal, the State petitioned for discretionary review, we granted review, briefs were filed, and our decision was rendered. Relator has shown that he lacks an adequate remedy other than mandamus.

C. Clear and indisputable right to relief

A habeas corpus proceeding has always been regarded as separate from the criminal prosecution, as Professors Dix and Dawson explain:

A habeas corpus action is, in theory, a different litigation than the criminal prosecution.... When habeas corpus is used as a vehicle for raising matters pretrial in a pending criminal prosecution, the difference between the pending prosecution and the habeas corpus proceeding is both more subtle and more significant. An order denying relief on the merits is a final judgment in the habeas corpus proceeding. Therefore, it is immediately appealable by the unsuccessful petitioner.

The professors’ view is amply supported by our caselaw. We have denoted the separateness of habeas corpus in the post-conviction context by characterizing the procedure as a “collateral attack” on the judgment of conviction. But we have also long recognized the separateness of pre-conviction habeas proceedings by permitting an immediate appeal from a denial of relief, before the trial proceedings in a criminal prosecution have been concluded. In the double jeopardy context, an immediate appeal from the denial of relief in a habeas corpus proceeding is permitted even though an immediate appeal would not be permitted when the same claim was raised only in a pretrial motion to dismiss. However, there are no statutes that specifically grant a right to immediately appeal the denial of relief in a pre-conviction habeas corpus proceeding. The right of appeal occurs because the habeas proceeding is in fact considered a separate “criminal action,” and the denial of relief marks the end of the trial stage of that criminal action and the commencement of the timetable for appeal. The appealability of a habeas proceeding turns not upon the nature of the claim advanced but upon the use of the procedure itself and the trial court’s decision to consider the claim (i.e. “issue the writ”). And we have expressly disapproved implying the existence of a habeas action from proceedings in a criminal prosecution when a separate habeas action has not been filed.

Because a habeas corpus action is separate from the underlying criminal prosecution, a ruling in the habeas action is not tantamount to a ruling on the same issue in a motion to dismiss in the criminal prosecution. Nor can a ruling in the habe-as action, by itself, be a basis for an inference that the trial court made, in the criminal prosecution, a ruling not reflected in the record. Here, nothing in the record indicates that the trial court made a ruling, explicit or implicit, on the motion to dismiss. The court of appeals was indisputably incorrect to hold otherwise.

Relator is entitled to a writ of mandamus from this Court ordering the court of appeals to vacate its order. As is our custom, we will withhold issuance of the writ and accord the court of appeals an opportunity to conform its actions to this opinion. Only if such action is not taken will the writ of mandamus issue. 
      
      . See Tex.R.App. P. 25.2(a)(2)(a).
     
      
      . Ernst v. State, 159 S.W.2d 656, 658, 2004 WL 1166210, 2004 Tex.App. LEXIS 4704, at 8 (Corpus Christi, delivered May 26, 2004).
     
      
      . Id. at 4.
     
      
      . Id. at 7.
     
      
      . Id. at 6-7.
     
      
      . State ex rel. Hill v. Court of Appeals for the Fifth Dist., 34 S.W.3d 924, 927 (Tex.Crim.App.2001).
     
      
      . Tex.R.App. P. 25.2(d).
     
      
      . Tex.R.App. P. 25.2(a)(2)(emphasis added).
     
      
      . See Tex R.App. P. and Tex.Code Crim Proc., passim. See also State ex rel. Holmes v. Court of Appeals for Third Dist., 885 S.W.2d 389, 394 (Tex.Crim.App.1994)(adequacy of remedy affected by interlocutory nature of the order relator seeks to overturn).
     
      
      . Smith v. Flack, 728 S.W.2d 784, 792 (Tex.Crim.App.1987),
     
      
      . Stearnes v. Clinton, 780 S.W.2d 216, 225 (Tex.Crim.App. 1989).
     
      
      . Ex parte Robinson, 641 S.W.2d 552, 555 (Tex.Crim.App.1982).
     
      
      . Dears v. State, 154 S.W.3d 610 (Tex.Crim.App.2005)(certification reflected plea bargain; docketing statement reflected no plea bargain).
     
      
      . Young v. State, 8 S.W.3d 656, 665 (Tex.Crim.App.2000).
     
      
      . Dix and Dawson, Texas Practice: Criminal Practice And Procedure, 2nd ed., Vol. 43B, § 47.51, 219-220 (2001)(ellipsis inserted; emphasis in original).
     
      
      . Ex parte Rieck, 144 S.W.3d 510, 516 (Tex.Crim.App.2004)(citing Ex parte Tuley, 109 S.W.3d 388, 390 (Tex.Crim.App.2002)).
     
      
      . Ex parte Halsted, 147 Tex.Crim. 453, 456-457, 182 S.W.2d 479, 481-482 (1944).
     
      
      . Robinson, 641 S.W.2d at 555, ns. 4 & 5(double jeopardy claim raised in habeas immediately appealable although same claim raised in a motion to dismiss could not have been immediately appealed).
     
      
      . See Tex.Code Crim. Proc., Art. 11.01, et seq. and Art. 44.02, passim.
      
     
      
      . See State ex. rel. Hill v. Pirtle, 887 S.W.2d 921 (Tex.Crim.App.1994).
     
      
      . Id.
      
     
      
      . See Art. 44.02 (defendant’s right to appeal "any criminal action”).
     
      
      . Ex parte McCullough, 966 S.W.2d 529, 531-532 (Tex.Crim.App.1998).
     
      
      . Jordan v. State, 54 S.W.3d 783, 786 (Tex.Crim.App.2001).
     
      
      . See Hill, 34 S.W.3d at 927-928 (relief sought must be "clear and indisputable”).
     
      
      . While an appellate court may require a trial court to certify whether there is a right to appeal, the appellate court may not dictate the content of the certification. See Tex.R.App. P. 37.1.
     