/ Check-in [af8e2006]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove the sqlite3_error_string() API. (CVS 1514)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:af8e2006d808031a040f293c44f3bfbe841b866b
User & Date: danielk1977 2004-05-31 23:56:43
Context
2004-06-01
00:03
Remove the sqlite3_open_varargs() API. (CVS 1515) check-in: 6902fb1b user: danielk1977 tags: trunk
2004-05-31
23:56
Remove the sqlite3_error_string() API. (CVS 1514) check-in: af8e2006 user: danielk1977 tags: trunk
23:13
Synchronize lemon.c to the version on the 2.8 branch. (CVS 1513) check-in: 6ab3af88 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.200 2004/05/31 19:34:33 drh Exp $
           17  +** $Id: main.c,v 1.201 2004/05/31 23:56:43 danielk1977 Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <ctype.h>
    22     22   
    23     23   /*
    24     24   ** A pointer to this structure is used to communicate information
................................................................................
   208    208     sqlite3SafetyOn(db);
   209    209   
   210    210     /* Create a cursor to hold the database open
   211    211     */
   212    212     if( db->aDb[iDb].pBt==0 ) return SQLITE_OK;
   213    213     rc = sqlite3BtreeCursor(db->aDb[iDb].pBt, MASTER_ROOT, 0, 0, 0, &curMain);
   214    214     if( rc!=SQLITE_OK && rc!=SQLITE_EMPTY ){
   215         -    sqlite3SetString(pzErrMsg, sqlite3_error_string(rc), (char*)0);
          215  +    sqlite3SetString(pzErrMsg, sqlite3ErrStr(rc), (char*)0);
   216    216       return rc;
   217    217     }
   218    218   
   219    219     /* Get the database meta information.
   220    220     **
   221    221     ** Meta values are as follows:
   222    222     **    meta[0]   Schema cookie.  Changes with each schema change.
................................................................................
   235    235     */
   236    236     if( rc==SQLITE_OK ){
   237    237       int i;
   238    238       for(i=0; rc==SQLITE_OK && i<sizeof(meta)/sizeof(meta[0]); i++){
   239    239         rc = sqlite3BtreeGetMeta(db->aDb[iDb].pBt, i+1, &meta[i]);
   240    240       }
   241    241       if( rc ){
   242         -      sqlite3SetString(pzErrMsg, sqlite3_error_string(rc), (char*)0);
          242  +      sqlite3SetString(pzErrMsg, sqlite3ErrStr(rc), (char*)0);
   243    243         sqlite3BtreeCloseCursor(curMain);
   244    244         return rc;
   245    245       }
   246    246     }else{
   247    247       memset(meta, 0, sizeof(meta));
   248    248     }
   249    249     db->aDb[iDb].schema_cookie = meta[0];
................................................................................
   489    489     /* sqlite3RollbackInternalChanges(db); */
   490    490   }
   491    491   
   492    492   /*
   493    493   ** Return a static string that describes the kind of error specified in the
   494    494   ** argument.
   495    495   */
   496         -const char *sqlite3_error_string(int rc){
          496  +const char *sqlite3ErrStr(int rc){
   497    497     const char *z;
   498    498     switch( rc ){
   499    499       case SQLITE_OK:         z = "not an error";                          break;
   500    500       case SQLITE_ERROR:      z = "SQL logic error or missing database";   break;
   501    501       case SQLITE_INTERNAL:   z = "internal SQLite implementation flaw";   break;
   502    502       case SQLITE_PERM:       z = "access permission denied";              break;
   503    503       case SQLITE_ABORT:      z = "callback requested query abort";        break;
................................................................................
   785    785   ** error.
   786    786   */
   787    787   const char *sqlite3_errmsg(sqlite3 *db){
   788    788     if( !db ){
   789    789       /* If db is NULL, then assume that a malloc() failed during an
   790    790       ** sqlite3_open() call.
   791    791       */
   792         -    return sqlite3_error_string(SQLITE_NOMEM);
          792  +    return sqlite3ErrStr(SQLITE_NOMEM);
   793    793     }
   794    794     if( db->zErrMsg ){
   795    795       return db->zErrMsg;
   796    796     }
   797         -  return sqlite3_error_string(db->errCode);
          797  +  return sqlite3ErrStr(db->errCode);
   798    798   }
   799    799   
   800    800   /*
   801    801   ** Return UTF-16 encoded English language explanation of the most recent
   802    802   ** error.
   803    803   */
   804    804   const void *sqlite3_errmsg16(sqlite3 *db){

Changes to src/shell.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code to implement the "sqlite" command line
    13     13   ** utility for accessing SQLite databases.
    14     14   **
    15         -** $Id: shell.c,v 1.100 2004/05/31 19:34:33 drh Exp $
           15  +** $Id: shell.c,v 1.101 2004/05/31 23:56:43 danielk1977 Exp $
    16     16   */
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <stdio.h>
    20     20   #include "sqlite3.h"
    21     21   #include <ctype.h>
    22     22   
................................................................................
  1059   1059         if( rc || zErrMsg ){
  1060   1060           if( in!=0 && !p->echoOn ) printf("%s\n",zSql);
  1061   1061           if( zErrMsg!=0 ){
  1062   1062             printf("SQL error: %s\n", zErrMsg);
  1063   1063             sqlite3_free(zErrMsg);
  1064   1064             zErrMsg = 0;
  1065   1065           }else{
  1066         -          printf("SQL error: %s\n", sqlite3_error_string(rc));
         1066  +          printf("SQL error: %s\n", sqlite3ErrStr(rc));
  1067   1067           }
  1068   1068         }
  1069   1069         free(zSql);
  1070   1070         zSql = 0;
  1071   1071         nSql = 0;
  1072   1072       }
  1073   1073     }

Changes to src/sqlite.h.in.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This header file defines the interface that the SQLite library
    13     13   ** presents to client programs.
    14     14   **
    15         -** @(#) $Id: sqlite.h.in,v 1.87 2004/05/31 19:34:33 drh Exp $
           15  +** @(#) $Id: sqlite.h.in,v 1.88 2004/05/31 23:56:43 danielk1977 Exp $
    16     16   */
    17     17   #ifndef _SQLITE_H_
    18     18   #define _SQLITE_H_
    19     19   #include <stdarg.h>     /* Needed for the definition of va_list */
    20     20   
    21     21   /*
    22     22   ** Make sure we can call this stuff from C++.
................................................................................
   209    209   ** table. To get an accurate count of the number of rows deleted, use
   210    210   ** "DELETE FROM table WHERE 1" instead.
   211    211   **
   212    212   ******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
   213    213   */
   214    214   int sqlite3_last_statement_changes(sqlite*);
   215    215   
   216         -/* If the parameter to this routine is one of the return value constants
   217         -** defined above, then this routine returns a constant text string which
   218         -** descripts (in English) the meaning of the return value.
   219         -*/
   220         -const char *sqlite3_error_string(int);
   221         -#define sqliteErrStr sqlite3_error_string  /* Legacy. Do not use in new code. */
   222         -
   223    216   /* This function causes any pending database operation to abort and
   224    217   ** return at its earliest opportunity.  This routine is typically
   225    218   ** called in response to a user action such as pressing "Cancel"
   226    219   ** or Ctrl-C where the user wants a long query operation to halt
   227    220   ** immediately.
   228    221   */
   229    222   void sqlite3_interrupt(sqlite*);

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.265 2004/05/31 18:51:58 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.266 2004/05/31 23:56:43 danielk1977 Exp $
    15     15   */
    16     16   #include "config.h"
    17     17   #include "sqlite3.h"
    18     18   #include "hash.h"
    19     19   #include "parse.h"
    20     20   #include <stdio.h>
    21     21   #include <stdlib.h>
................................................................................
  1353   1353   char sqlite3ExprAffinity(Expr *pExpr);
  1354   1354   int sqlite3atoi64(const char*, i64*);
  1355   1355   void sqlite3Error(sqlite *, int, const char*,...);
  1356   1356   int sqlite3utfTranslate(const void *, int , u8 , void **, int *, u8);
  1357   1357   u8 sqlite3UtfReadBom(const void *zData, int nData);
  1358   1358   void *sqlite3HexToBlob(const char *z);
  1359   1359   int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
         1360  +const char *sqlite3ErrStr(int);

Changes to src/tclsqlite.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** A TCL Interface to SQLite
    13     13   **
    14         -** $Id: tclsqlite.c,v 1.77 2004/05/31 18:51:58 drh Exp $
           14  +** $Id: tclsqlite.c,v 1.78 2004/05/31 23:56:43 danielk1977 Exp $
    15     15   */
    16     16   #ifndef NO_TCL     /* Omit this whole file if TCL is unavailable */
    17     17   
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
................................................................................
   769    769       if( rc==SQLITE_ABORT ){
   770    770         rc = SQLITE_OK;
   771    771       }else if( zErrMsg ){
   772    772         Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);
   773    773         free(zErrMsg);
   774    774         rc = TCL_ERROR;
   775    775       }else if( rc!=SQLITE_OK ){
   776         -      Tcl_AppendResult(interp, sqlite3_error_string(rc), 0);
          776  +      Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0);
   777    777         rc = TCL_ERROR;
   778    778       }
   779    779       break;
   780    780     }
   781    781   
   782    782     /*
   783    783     **     $db rekey KEY
................................................................................
   791    791         Tcl_WrongNumArgs(interp, 2, objv, "KEY");
   792    792         return TCL_ERROR;
   793    793       }
   794    794       pKey = Tcl_GetByteArrayFromObj(objv[2], &nKey);
   795    795   #ifdef SQLITE_HAS_CODEC
   796    796       rc = sqlite_rekey(pDb->db, pKey, nKey);
   797    797       if( rc ){
   798         -      Tcl_AppendResult(interp, sqlite3_error_string(rc), 0);
          798  +      Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0);
   799    799         rc = TCL_ERROR;
   800    800       }
   801    801   #endif
   802    802       break;
   803    803     }
   804    804   
   805    805     /*

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the printf() interface to SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.67 2004/05/31 19:34:33 drh Exp $
           16  +** $Id: test1.c,v 1.68 2004/05/31 23:56:43 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include "os.h"
    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   
................................................................................
   718    718       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 
   719    719          " DB FUNCTION-NAME", 0);
   720    720       return TCL_ERROR;
   721    721     }
   722    722     if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
   723    723     rc = sqlite3_create_function(db, argv[2], -1, 0, 0, 0, testFunc, 0, 0);
   724    724     if( rc!=0 ){
   725         -    Tcl_AppendResult(interp, sqlite3_error_string(rc), 0);
          725  +    Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0);
   726    726       return TCL_ERROR;
   727    727     }
   728    728     return TCL_OK;
   729    729   }
   730    730   
   731    731   /*
   732    732   ** Usage:  sqlite3_finalize  STMT 
................................................................................
   835    835       Tcl_AppendResult(interp, "4th argument should be "
   836    836           "\"null\" or \"static\" or \"normal\"", 0);
   837    837       return TCL_ERROR;
   838    838     }
   839    839     if( rc ){
   840    840       char zBuf[50];
   841    841       sprintf(zBuf, "(%d) ", rc);
   842         -    Tcl_AppendResult(interp, zBuf, sqlite3_error_string(rc), 0);
          842  +    Tcl_AppendResult(interp, zBuf, sqlite3ErrStr(rc), 0);
   843    843       return TCL_ERROR;
   844    844     }
   845    845     return TCL_OK;
   846    846   }
   847    847   
   848    848   /*
   849    849   ** Usage:    breakpoint

Changes to src/tokenize.c.

    11     11   *************************************************************************
    12     12   ** An tokenizer for SQL
    13     13   **
    14     14   ** This file contains C code that splits an SQL input string up into
    15     15   ** individual tokens and sends those tokens one-by-one over to the
    16     16   ** parser for analysis.
    17     17   **
    18         -** $Id: tokenize.c,v 1.75 2004/05/31 18:51:58 drh Exp $
           18  +** $Id: tokenize.c,v 1.76 2004/05/31 23:56:43 danielk1977 Exp $
    19     19   */
    20     20   #include "sqliteInt.h"
    21     21   #include "os.h"
    22     22   #include <ctype.h>
    23     23   #include <stdlib.h>
    24     24   
    25     25   /*
................................................................................
   475    475         sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
   476    476         pParse->zTail = &zSql[i];
   477    477       }
   478    478       sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
   479    479     }
   480    480     sqlite3ParserFree(pEngine, free);
   481    481     if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
   482         -    sqlite3SetString(&pParse->zErrMsg, sqlite3_error_string(pParse->rc),
          482  +    sqlite3SetString(&pParse->zErrMsg, sqlite3ErrStr(pParse->rc),
   483    483                       (char*)0);
   484    484     }
   485    485     if( pParse->zErrMsg ){
   486    486       if( pzErrMsg && *pzErrMsg==0 ){
   487    487         *pzErrMsg = pParse->zErrMsg;
   488    488       }else{
   489    489         sqliteFree(pParse->zErrMsg);

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.353 2004/05/31 18:51:58 drh Exp $
           46  +** $Id: vdbe.c,v 1.354 2004/05/31 23:56:43 danielk1977 Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
  2267   2267         case SQLITE_BUSY: {
  2268   2268           if( db->xBusyCallback==0 ){
  2269   2269             p->pc = pc;
  2270   2270             p->rc = SQLITE_BUSY;
  2271   2271             p->pTos = pTos;
  2272   2272             return SQLITE_BUSY;
  2273   2273           }else if( (*db->xBusyCallback)(db->pBusyArg, "", busy++)==0 ){
  2274         -          sqlite3SetString(&p->zErrMsg, sqlite3_error_string(rc), (char*)0);
         2274  +          sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0);
  2275   2275             busy = 0;
  2276   2276           }
  2277   2277           break;
  2278   2278         }
  2279   2279         case SQLITE_READONLY: {
  2280   2280           rc = SQLITE_OK;
  2281   2281           /* Fall thru into the next case */
................................................................................
  2469   2469         case SQLITE_BUSY: {
  2470   2470           if( db->xBusyCallback==0 ){
  2471   2471             p->pc = pc;
  2472   2472             p->rc = SQLITE_BUSY;
  2473   2473             p->pTos = &pTos[1 + (pOp->p2<=0)]; /* Operands must remain on stack */
  2474   2474             return SQLITE_BUSY;
  2475   2475           }else if( (*db->xBusyCallback)(db->pBusyArg, pOp->p3, ++busy)==0 ){
  2476         -          sqlite3SetString(&p->zErrMsg, sqlite3_error_string(rc), (char*)0);
         2476  +          sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0);
  2477   2477             busy = 0;
  2478   2478           }
  2479   2479           break;
  2480   2480         }
  2481   2481         case SQLITE_OK: {
  2482   2482           int flags = sqlite3BtreeFlags(pCur->pCursor);
  2483   2483           pCur->intKey = (flags & BTREE_INTKEY)!=0;
................................................................................
  4523   4523   
  4524   4524     /* Jump to here for any other kind of fatal error.  The "rc" variable
  4525   4525     ** should hold the error number.
  4526   4526     */
  4527   4527   abort_due_to_error:
  4528   4528     if( p->zErrMsg==0 ){
  4529   4529       if( sqlite3_malloc_failed ) rc = SQLITE_NOMEM;
  4530         -    sqlite3SetString(&p->zErrMsg, sqlite3_error_string(rc), (char*)0);
         4530  +    sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0);
  4531   4531     }
  4532   4532     goto vdbe_halt;
  4533   4533   
  4534   4534     /* Jump to here if the sqlite3_interrupt() API sets the interrupt
  4535   4535     ** flag.
  4536   4536     */
  4537   4537   abort_due_to_interrupt:
................................................................................
  4538   4538     assert( db->flags & SQLITE_Interrupt );
  4539   4539     db->flags &= ~SQLITE_Interrupt;
  4540   4540     if( db->magic!=SQLITE_MAGIC_BUSY ){
  4541   4541       rc = SQLITE_MISUSE;
  4542   4542     }else{
  4543   4543       rc = SQLITE_INTERRUPT;
  4544   4544     }
  4545         -  sqlite3SetString(&p->zErrMsg, sqlite3_error_string(rc), (char*)0);
         4545  +  sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0);
  4546   4546     goto vdbe_halt;
  4547   4547   }

Changes to src/vdbeaux.c.

   562    562       db->flags &= ~SQLITE_Interrupt;
   563    563       if( db->magic!=SQLITE_MAGIC_BUSY ){
   564    564         p->rc = SQLITE_MISUSE;
   565    565       }else{
   566    566         p->rc = SQLITE_INTERRUPT;
   567    567       }
   568    568       rc = SQLITE_ERROR;
   569         -    sqlite3SetString(&p->zErrMsg, sqlite3_error_string(p->rc), (char*)0);
          569  +    sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(p->rc), (char*)0);
   570    570     }else{
   571    571       Op *pOp = &p->aOp[i];
   572    572       Mem *pMem = p->aStack;
   573    573       pMem->flags = MEM_Int;
   574    574       pMem->type = SQLITE_INTEGER;
   575    575       pMem->i = i;                                /* Program counter */
   576    576       pMem++;
................................................................................
   931    931   int sqlite3VdbeReset(Vdbe *p, char **pzErrMsg){
   932    932     sqlite *db = p->db;
   933    933     int i;
   934    934     int (*xFunc)(Btree *pBt) = 0;  /* Function to call on each btree backend */
   935    935     int needXcommit = 0;
   936    936   
   937    937     if( p->magic!=VDBE_MAGIC_RUN && p->magic!=VDBE_MAGIC_HALT ){
   938         -    sqlite3SetString(pzErrMsg, sqlite3_error_string(SQLITE_MISUSE), (char*)0);
          938  +    sqlite3SetString(pzErrMsg, sqlite3ErrStr(SQLITE_MISUSE), (char*)0);
   939    939       sqlite3Error(p->db, SQLITE_MISUSE, 0 ,0);
   940    940       db->activeVdbeCnt--;
   941    941       return SQLITE_MISUSE;
   942    942     }
   943    943     if( p->zErrMsg ){
   944    944       sqlite3Error(p->db, p->rc, "%s", p->zErrMsg, 0);
   945    945       if( pzErrMsg && *pzErrMsg==0 ){
   946    946         *pzErrMsg = p->zErrMsg;
   947    947       }else{
   948    948         sqliteFree(p->zErrMsg);
   949    949       }
   950    950       p->zErrMsg = 0;
   951    951     }else if( p->rc ){
   952         -    sqlite3SetString(pzErrMsg, sqlite3_error_string(p->rc), (char*)0);
          952  +    sqlite3SetString(pzErrMsg, sqlite3ErrStr(p->rc), (char*)0);
   953    953       sqlite3Error(p->db, p->rc, 0);
   954    954     }else{
   955    955       sqlite3Error(p->db, SQLITE_OK, 0);
   956    956     }
   957    957     Cleanup(p);
   958    958   
   959    959     /* Figure out which function to call on the btree backends that
................................................................................
  1038   1038   ** the result code.  Write any error message text into *pzErrMsg.
  1039   1039   */
  1040   1040   int sqlite3VdbeFinalize(Vdbe *p, char **pzErrMsg){
  1041   1041     int rc;
  1042   1042     sqlite *db;
  1043   1043   
  1044   1044     if( p->magic!=VDBE_MAGIC_RUN && p->magic!=VDBE_MAGIC_HALT ){
  1045         -    sqlite3SetString(pzErrMsg, sqlite3_error_string(SQLITE_MISUSE), (char*)0);
         1045  +    sqlite3SetString(pzErrMsg, sqlite3ErrStr(SQLITE_MISUSE), (char*)0);
  1046   1046       if( p->magic==VDBE_MAGIC_INIT ){
  1047         -      sqlite3Error(p->db, SQLITE_MISUSE, sqlite3_error_string(SQLITE_MISUSE),0);
         1047  +      sqlite3Error(p->db, SQLITE_MISUSE, 0);
  1048   1048       }
  1049   1049       return SQLITE_MISUSE;
  1050   1050     }
  1051   1051     db = p->db;
  1052   1052     rc = sqlite3VdbeReset(p, pzErrMsg);
  1053   1053     sqlite3VdbeDelete(p);
  1054   1054     if( db->want_to_close && db->pVdbe==0 ){