Back to index

lightning-sunbird  0.9+nobinonly
prepare.c
Go to the documentation of this file.
00001 /*
00002 ** 2005 May 25
00003 **
00004 ** The author disclaims copyright to this source code.  In place of
00005 ** a legal notice, here is a blessing:
00006 **
00007 **    May you do good and not evil.
00008 **    May you find forgiveness for yourself and forgive others.
00009 **    May you share freely, never taking more than you give.
00010 **
00011 *************************************************************************
00012 ** This file contains the implementation of the sqlite3_prepare()
00013 ** interface, and routines that contribute to loading the database schema
00014 ** from disk.
00015 **
00016 ** $Id: prepare.c,v 1.2.2.5 2006/05/22 19:12:32 brettw%gmail.com Exp $
00017 */
00018 #include "sqliteInt.h"
00019 #include "os.h"
00020 #include <ctype.h>
00021 
00022 /*
00023 ** Fill the InitData structure with an error message that indicates
00024 ** that the database is corrupt.
00025 */
00026 static void corruptSchema(InitData *pData, const char *zExtra){
00027   if( !sqlite3MallocFailed() ){
00028     sqlite3SetString(pData->pzErrMsg, "malformed database schema",
00029        zExtra!=0 && zExtra[0]!=0 ? " - " : (char*)0, zExtra, (char*)0);
00030   }
00031 }
00032 
00033 /*
00034 ** This is the callback routine for the code that initializes the
00035 ** database.  See sqlite3Init() below for additional information.
00036 ** This routine is also called from the OP_ParseSchema opcode of the VDBE.
00037 **
00038 ** Each callback contains the following information:
00039 **
00040 **     argv[0] = name of thing being created
00041 **     argv[1] = root page number for table or index.  NULL for trigger or view.
00042 **     argv[2] = SQL text for the CREATE statement.
00043 **     argv[3] = "1" for temporary files, "0" for main database, "2" or more
00044 **               for auxiliary database files.
00045 **
00046 */
00047 int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
00048   InitData *pData = (InitData*)pInit;
00049   sqlite3 *db = pData->db;
00050   int iDb;
00051 
00052   if( sqlite3MallocFailed() ){
00053     return SQLITE_NOMEM;
00054   }
00055 
00056   assert( argc==4 );
00057   if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */
00058   if( argv[1]==0 || argv[3]==0 ){
00059     corruptSchema(pData, 0);
00060     return 1;
00061   }
00062   iDb = atoi(argv[3]);
00063   assert( iDb>=0 && iDb<db->nDb );
00064   if( argv[2] && argv[2][0] ){
00065     /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
00066     ** But because db->init.busy is set to 1, no VDBE code is generated
00067     ** or executed.  All the parser does is build the internal data
00068     ** structures that describe the table, index, or view.
00069     */
00070     char *zErr;
00071     int rc;
00072     assert( db->init.busy );
00073     db->init.iDb = iDb;
00074     db->init.newTnum = atoi(argv[1]);
00075     rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);
00076     db->init.iDb = 0;
00077     assert( rc!=SQLITE_OK || zErr==0 );
00078     if( SQLITE_OK!=rc ){
00079       if( rc==SQLITE_NOMEM ){
00080         sqlite3FailedMalloc();
00081       }else{
00082         corruptSchema(pData, zErr);
00083       }
00084       sqlite3_free(zErr);
00085       return rc;
00086     }
00087   }else{
00088     /* If the SQL column is blank it means this is an index that
00089     ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
00090     ** constraint for a CREATE TABLE.  The index should have already
00091     ** been created when we processed the CREATE TABLE.  All we have
00092     ** to do here is record the root page number for that index.
00093     */
00094     Index *pIndex;
00095     pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zName);
00096     if( pIndex==0 || pIndex->tnum!=0 ){
00097       /* This can occur if there exists an index on a TEMP table which
00098       ** has the same name as another index on a permanent index.  Since
00099       ** the permanent table is hidden by the TEMP table, we can also
00100       ** safely ignore the index on the permanent table.
00101       */
00102       /* Do Nothing */;
00103     }else{
00104       pIndex->tnum = atoi(argv[1]);
00105     }
00106   }
00107   return 0;
00108 }
00109 
00110 /*
00111 ** Attempt to read the database schema and initialize internal
00112 ** data structures for a single database file.  The index of the
00113 ** database file is given by iDb.  iDb==0 is used for the main
00114 ** database.  iDb==1 should never be used.  iDb>=2 is used for
00115 ** auxiliary databases.  Return one of the SQLITE_ error codes to
00116 ** indicate success or failure.
00117 */
00118 static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
00119   int rc;
00120   BtCursor *curMain;
00121   int size;
00122   Table *pTab;
00123   Db *pDb;
00124   char const *azArg[5];
00125   char zDbNum[30];
00126   int meta[10];
00127   InitData initData;
00128   char const *zMasterSchema;
00129   char const *zMasterName = SCHEMA_TABLE(iDb);
00130 
00131   /*
00132   ** The master database table has a structure like this
00133   */
00134   static const char master_schema[] = 
00135      "CREATE TABLE sqlite_master(\n"
00136      "  type text,\n"
00137      "  name text,\n"
00138      "  tbl_name text,\n"
00139      "  rootpage integer,\n"
00140      "  sql text\n"
00141      ")"
00142   ;
00143 #ifndef SQLITE_OMIT_TEMPDB
00144   static const char temp_master_schema[] = 
00145      "CREATE TEMP TABLE sqlite_temp_master(\n"
00146      "  type text,\n"
00147      "  name text,\n"
00148      "  tbl_name text,\n"
00149      "  rootpage integer,\n"
00150      "  sql text\n"
00151      ")"
00152   ;
00153 #else
00154   #define temp_master_schema 0
00155 #endif
00156 
00157   assert( iDb>=0 && iDb<db->nDb );
00158   assert( db->aDb[iDb].pSchema );
00159 
00160   /* zMasterSchema and zInitScript are set to point at the master schema
00161   ** and initialisation script appropriate for the database being
00162   ** initialised. zMasterName is the name of the master table.
00163   */
00164   if( !OMIT_TEMPDB && iDb==1 ){
00165     zMasterSchema = temp_master_schema;
00166   }else{
00167     zMasterSchema = master_schema;
00168   }
00169   zMasterName = SCHEMA_TABLE(iDb);
00170 
00171   /* Construct the schema tables.  */
00172   sqlite3SafetyOff(db);
00173   azArg[0] = zMasterName;
00174   azArg[1] = "1";
00175   azArg[2] = zMasterSchema;
00176   sprintf(zDbNum, "%d", iDb);
00177   azArg[3] = zDbNum;
00178   azArg[4] = 0;
00179   initData.db = db;
00180   initData.pzErrMsg = pzErrMsg;
00181   rc = sqlite3InitCallback(&initData, 4, (char **)azArg, 0);
00182   if( rc!=SQLITE_OK ){
00183     sqlite3SafetyOn(db);
00184     return rc;
00185   }
00186   pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName);
00187   if( pTab ){
00188     pTab->readOnly = 1;
00189   }
00190   sqlite3SafetyOn(db);
00191 
00192   /* Create a cursor to hold the database open
00193   */
00194   pDb = &db->aDb[iDb];
00195   if( pDb->pBt==0 ){
00196     if( !OMIT_TEMPDB && iDb==1 ){
00197       DbSetProperty(db, 1, DB_SchemaLoaded);
00198     }
00199     return SQLITE_OK;
00200   }
00201   rc = sqlite3BtreeCursor(pDb->pBt, MASTER_ROOT, 0, 0, 0, &curMain);
00202   if( rc!=SQLITE_OK && rc!=SQLITE_EMPTY ){
00203     sqlite3SetString(pzErrMsg, sqlite3ErrStr(rc), (char*)0);
00204     return rc;
00205   }
00206 
00207   /* Get the database meta information.
00208   **
00209   ** Meta values are as follows:
00210   **    meta[0]   Schema cookie.  Changes with each schema change.
00211   **    meta[1]   File format of schema layer.
00212   **    meta[2]   Size of the page cache.
00213   **    meta[3]   Use freelist if 0.  Autovacuum if greater than zero.
00214   **    meta[4]   Db text encoding. 1:UTF-8 3:UTF-16 LE 4:UTF-16 BE
00215   **    meta[5]   The user cookie. Used by the application.
00216   **    meta[6]   
00217   **    meta[7]
00218   **    meta[8]
00219   **    meta[9]
00220   **
00221   ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to
00222   ** the possible values of meta[4].
00223   */
00224   if( rc==SQLITE_OK ){
00225     int i;
00226     for(i=0; rc==SQLITE_OK && i<sizeof(meta)/sizeof(meta[0]); i++){
00227       rc = sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]);
00228     }
00229     if( rc ){
00230       sqlite3SetString(pzErrMsg, sqlite3ErrStr(rc), (char*)0);
00231       sqlite3BtreeCloseCursor(curMain);
00232       return rc;
00233     }
00234   }else{
00235     memset(meta, 0, sizeof(meta));
00236   }
00237   pDb->pSchema->schema_cookie = meta[0];
00238 
00239   /* If opening a non-empty database, check the text encoding. For the
00240   ** main database, set sqlite3.enc to the encoding of the main database.
00241   ** For an attached db, it is an error if the encoding is not the same
00242   ** as sqlite3.enc.
00243   */
00244   if( meta[4] ){  /* text encoding */
00245     if( iDb==0 ){
00246       /* If opening the main database, set ENC(db). */
00247       ENC(db) = (u8)meta[4];
00248       db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 6, 0);
00249     }else{
00250       /* If opening an attached database, the encoding much match ENC(db) */
00251       if( meta[4]!=ENC(db) ){
00252         sqlite3BtreeCloseCursor(curMain);
00253         sqlite3SetString(pzErrMsg, "attached databases must use the same"
00254             " text encoding as main database", (char*)0);
00255         return SQLITE_ERROR;
00256       }
00257     }
00258   }else{
00259     DbSetProperty(db, iDb, DB_Empty);
00260   }
00261   pDb->pSchema->enc = ENC(db);
00262 
00263   size = meta[2];
00264   if( size==0 ){ size = MAX_PAGES; }
00265   pDb->pSchema->cache_size = size;
00266   sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
00267 
00268   /*
00269   ** file_format==1    Version 3.0.0.
00270   ** file_format==2    Version 3.1.3.  // ALTER TABLE ADD COLUMN
00271   ** file_format==3    Version 3.1.4.  // ditto but with non-NULL defaults
00272   ** file_format==4    Version 3.3.0.  // DESC indices.  Boolean constants
00273   */
00274   pDb->pSchema->file_format = meta[1];
00275   if( pDb->pSchema->file_format==0 ){
00276     pDb->pSchema->file_format = 1;
00277   }
00278   if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
00279     sqlite3BtreeCloseCursor(curMain);
00280     sqlite3SetString(pzErrMsg, "unsupported file format", (char*)0);
00281     return SQLITE_ERROR;
00282   }
00283 
00284 
00285   /* Read the schema information out of the schema tables
00286   */
00287   assert( db->init.busy );
00288   if( rc==SQLITE_EMPTY ){
00289     /* For an empty database, there is nothing to read */
00290     rc = SQLITE_OK;
00291   }else{
00292     char *zSql;
00293     zSql = sqlite3MPrintf(
00294         "SELECT name, rootpage, sql, '%s' FROM '%q'.%s",
00295         zDbNum, db->aDb[iDb].zName, zMasterName);
00296     sqlite3SafetyOff(db);
00297     rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);
00298     sqlite3SafetyOn(db);
00299     sqliteFree(zSql);
00300 #ifndef SQLITE_OMIT_ANALYZE
00301     if( rc==SQLITE_OK ){
00302       sqlite3AnalysisLoad(db, iDb);
00303     }
00304 #endif
00305     sqlite3BtreeCloseCursor(curMain);
00306   }
00307   if( sqlite3MallocFailed() ){
00308     /* sqlite3SetString(pzErrMsg, "out of memory", (char*)0); */
00309     rc = SQLITE_NOMEM;
00310     sqlite3ResetInternalSchema(db, 0);
00311   }
00312   if( rc==SQLITE_OK ){
00313     DbSetProperty(db, iDb, DB_SchemaLoaded);
00314   }else{
00315     sqlite3ResetInternalSchema(db, iDb);
00316   }
00317   return rc;
00318 }
00319 
00320 /*
00321 ** Initialize all database files - the main database file, the file
00322 ** used to store temporary tables, and any additional database files
00323 ** created using ATTACH statements.  Return a success code.  If an
00324 ** error occurs, write an error message into *pzErrMsg.
00325 **
00326 ** After a database is initialized, the DB_SchemaLoaded bit is set
00327 ** bit is set in the flags field of the Db structure. If the database
00328 ** file was of zero-length, then the DB_Empty flag is also set.
00329 */
00330 int sqlite3Init(sqlite3 *db, char **pzErrMsg){
00331   int i, rc;
00332   int called_initone = 0;
00333   
00334   if( db->init.busy ) return SQLITE_OK;
00335   rc = SQLITE_OK;
00336   db->init.busy = 1;
00337   for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
00338     if( DbHasProperty(db, i, DB_SchemaLoaded) || i==1 ) continue;
00339     rc = sqlite3InitOne(db, i, pzErrMsg);
00340     if( rc ){
00341       sqlite3ResetInternalSchema(db, i);
00342     }
00343     called_initone = 1;
00344   }
00345 
00346   /* Once all the other databases have been initialised, load the schema
00347   ** for the TEMP database. This is loaded last, as the TEMP database
00348   ** schema may contain references to objects in other databases.
00349   */
00350 #ifndef SQLITE_OMIT_TEMPDB
00351   if( rc==SQLITE_OK && db->nDb>1 && !DbHasProperty(db, 1, DB_SchemaLoaded) ){
00352     rc = sqlite3InitOne(db, 1, pzErrMsg);
00353     if( rc ){
00354       sqlite3ResetInternalSchema(db, 1);
00355     }
00356     called_initone = 1;
00357   }
00358 #endif
00359 
00360   db->init.busy = 0;
00361   if( rc==SQLITE_OK && called_initone ){
00362     sqlite3CommitInternalChanges(db);
00363   }
00364 
00365   return rc; 
00366 }
00367 
00368 /*
00369 ** This routine is a no-op if the database schema is already initialised.
00370 ** Otherwise, the schema is loaded. An error code is returned.
00371 */
00372 int sqlite3ReadSchema(Parse *pParse){
00373   int rc = SQLITE_OK;
00374   sqlite3 *db = pParse->db;
00375   if( !db->init.busy ){
00376     rc = sqlite3Init(db, &pParse->zErrMsg);
00377   }
00378   if( rc!=SQLITE_OK ){
00379     pParse->rc = rc;
00380     pParse->nErr++;
00381   }
00382   return rc;
00383 }
00384 
00385 
00386 /*
00387 ** Check schema cookies in all databases.  If any cookie is out
00388 ** of date, return 0.  If all schema cookies are current, return 1.
00389 */
00390 static int schemaIsValid(sqlite3 *db){
00391   int iDb;
00392   int rc;
00393   BtCursor *curTemp;
00394   int cookie;
00395   int allOk = 1;
00396 
00397   for(iDb=0; allOk && iDb<db->nDb; iDb++){
00398     Btree *pBt;
00399     pBt = db->aDb[iDb].pBt;
00400     if( pBt==0 ) continue;
00401     rc = sqlite3BtreeCursor(pBt, MASTER_ROOT, 0, 0, 0, &curTemp);
00402     if( rc==SQLITE_OK ){
00403       rc = sqlite3BtreeGetMeta(pBt, 1, (u32 *)&cookie);
00404       if( rc==SQLITE_OK && cookie!=db->aDb[iDb].pSchema->schema_cookie ){
00405         allOk = 0;
00406       }
00407       sqlite3BtreeCloseCursor(curTemp);
00408     }
00409   }
00410   return allOk;
00411 }
00412 
00413 /*
00414 ** Convert a schema pointer into the iDb index that indicates
00415 ** which database file in db->aDb[] the schema refers to.
00416 **
00417 ** If the same database is attached more than once, the first
00418 ** attached database is returned.
00419 */
00420 int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){
00421   int i = -1000000;
00422 
00423   /* If pSchema is NULL, then return -1000000. This happens when code in 
00424   ** expr.c is trying to resolve a reference to a transient table (i.e. one
00425   ** created by a sub-select). In this case the return value of this 
00426   ** function should never be used.
00427   **
00428   ** We return -1000000 instead of the more usual -1 simply because using
00429   ** -1000000 as incorrectly using -1000000 index into db->aDb[] is much 
00430   ** more likely to cause a segfault than -1 (of course there are assert()
00431   ** statements too, but it never hurts to play the odds).
00432   */
00433   if( pSchema ){
00434     for(i=0; i<db->nDb; i++){
00435       if( db->aDb[i].pSchema==pSchema ){
00436         break;
00437       }
00438     }
00439     assert( i>=0 &&i>=0 &&  i<db->nDb );
00440   }
00441   return i;
00442 }
00443 
00444 /*
00445 ** Compile the UTF-8 encoded SQL statement zSql into a statement handle.
00446 */
00447 int sqlite3_prepare(
00448   sqlite3 *db,              /* Database handle. */
00449   const char *zSql,         /* UTF-8 encoded SQL statement. */
00450   int nBytes,               /* Length of zSql in bytes. */
00451   sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */
00452   const char** pzTail       /* OUT: End of parsed string */
00453 ){
00454   Parse sParse;
00455   char *zErrMsg = 0;
00456   int rc = SQLITE_OK;
00457   int i;
00458 
00459   /* Assert that malloc() has not failed */
00460   assert( !sqlite3MallocFailed() );
00461 
00462   assert( ppStmt );
00463   *ppStmt = 0;
00464   if( sqlite3SafetyOn(db) ){
00465     return SQLITE_MISUSE;
00466   }
00467 
00468   /* If any attached database schemas are locked, do not proceed with
00469   ** compilation. Instead return SQLITE_LOCKED immediately.
00470   */
00471   for(i=0; i<db->nDb; i++) {
00472     Btree *pBt = db->aDb[i].pBt;
00473     if( pBt && sqlite3BtreeSchemaLocked(pBt) ){
00474       const char *zDb = db->aDb[i].zName;
00475       sqlite3Error(db, SQLITE_LOCKED, "database schema is locked: %s", zDb);
00476       sqlite3SafetyOff(db);
00477       return SQLITE_LOCKED;
00478     }
00479   }
00480   
00481   memset(&sParse, 0, sizeof(sParse));
00482   sParse.db = db;
00483   if( nBytes>=0 && zSql[nBytes]!=0 ){
00484     char *zSqlCopy = sqlite3StrNDup(zSql, nBytes);
00485     sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg);
00486     sParse.zTail += zSql - zSqlCopy;
00487     sqliteFree(zSqlCopy);
00488   }else{
00489     sqlite3RunParser(&sParse, zSql, &zErrMsg);
00490   }
00491 
00492   if( sqlite3MallocFailed() ){
00493     sParse.rc = SQLITE_NOMEM;
00494   }
00495   if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
00496   if( sParse.checkSchema && !schemaIsValid(db) ){
00497     sParse.rc = SQLITE_SCHEMA;
00498   }
00499   if( sParse.rc==SQLITE_SCHEMA ){
00500     sqlite3ResetInternalSchema(db, 0);
00501   }
00502   if( pzTail ) *pzTail = sParse.zTail;
00503   rc = sParse.rc;
00504 
00505 #ifndef SQLITE_OMIT_EXPLAIN
00506   if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){
00507     if( sParse.explain==2 ){
00508       sqlite3VdbeSetNumCols(sParse.pVdbe, 3);
00509       sqlite3VdbeSetColName(sParse.pVdbe, 0, COLNAME_NAME, "order", P3_STATIC);
00510       sqlite3VdbeSetColName(sParse.pVdbe, 1, COLNAME_NAME, "from", P3_STATIC);
00511       sqlite3VdbeSetColName(sParse.pVdbe, 2, COLNAME_NAME, "detail", P3_STATIC);
00512     }else{
00513       sqlite3VdbeSetNumCols(sParse.pVdbe, 5);
00514       sqlite3VdbeSetColName(sParse.pVdbe, 0, COLNAME_NAME, "addr", P3_STATIC);
00515       sqlite3VdbeSetColName(sParse.pVdbe, 1, COLNAME_NAME, "opcode", P3_STATIC);
00516       sqlite3VdbeSetColName(sParse.pVdbe, 2, COLNAME_NAME, "p1", P3_STATIC);
00517       sqlite3VdbeSetColName(sParse.pVdbe, 3, COLNAME_NAME, "p2", P3_STATIC);
00518       sqlite3VdbeSetColName(sParse.pVdbe, 4, COLNAME_NAME, "p3", P3_STATIC);
00519     }
00520   } 
00521 #endif
00522 
00523   if( sqlite3SafetyOff(db) ){
00524     rc = SQLITE_MISUSE;
00525   }
00526   if( rc==SQLITE_OK ){
00527     *ppStmt = (sqlite3_stmt*)sParse.pVdbe;
00528   }else if( sParse.pVdbe ){
00529     sqlite3_finalize((sqlite3_stmt*)sParse.pVdbe);
00530   }
00531 
00532   if( zErrMsg ){
00533     sqlite3Error(db, rc, "%s", zErrMsg);
00534     sqliteFree(zErrMsg);
00535   }else{
00536     sqlite3Error(db, rc, 0);
00537   }
00538 
00539   rc = sqlite3ApiExit(db, rc);
00540   sqlite3ReleaseThreadData();
00541   return rc;
00542 }
00543 
00544 #ifndef SQLITE_OMIT_UTF16
00545 /*
00546 ** Compile the UTF-16 encoded SQL statement zSql into a statement handle.
00547 */
00548 int sqlite3_prepare16(
00549   sqlite3 *db,              /* Database handle. */ 
00550   const void *zSql,         /* UTF-8 encoded SQL statement. */
00551   int nBytes,               /* Length of zSql in bytes. */
00552   sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */
00553   const void **pzTail       /* OUT: End of parsed string */
00554 ){
00555   /* This function currently works by first transforming the UTF-16
00556   ** encoded string to UTF-8, then invoking sqlite3_prepare(). The
00557   ** tricky bit is figuring out the pointer to return in *pzTail.
00558   */
00559   char *zSql8;
00560   const char *zTail8 = 0;
00561   int rc = SQLITE_OK;
00562 
00563   if( sqlite3SafetyCheck(db) ){
00564     return SQLITE_MISUSE;
00565   }
00566   zSql8 = sqlite3utf16to8(zSql, nBytes);
00567   if( zSql8 ){
00568     rc = sqlite3_prepare(db, zSql8, -1, ppStmt, &zTail8);
00569   }
00570 
00571   if( zTail8 && pzTail ){
00572     /* If sqlite3_prepare returns a tail pointer, we calculate the
00573     ** equivalent pointer into the UTF-16 string by counting the unicode
00574     ** characters between zSql8 and zTail8, and then returning a pointer
00575     ** the same number of characters into the UTF-16 string.
00576     */
00577     int chars_parsed = sqlite3utf8CharLen(zSql8, zTail8-zSql8);
00578     *pzTail = (u8 *)zSql + sqlite3utf16ByteLen(zSql, chars_parsed);
00579   }
00580   sqliteFree(zSql8); 
00581   return sqlite3ApiExit(db, rc);
00582 }
00583 #endif /* SQLITE_OMIT_UTF16 */