/ Check-in [ae04d2d1]
Login

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

Overview
Comment:Avoid unnecessary calls to sqlite3_step() with null prepared statements while parsing the schema.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ae04d2d15d3d96f607adb394a631d96cd4cf2c1d
User & Date: drh 2010-04-09 09:14:05
Context
2010-04-09
15:34
Candidate fix for a pager bug associated with sqlite3PagerMovepage(). check-in: 8c046eb6 user: drh tags: trunk
09:14
Avoid unnecessary calls to sqlite3_step() with null prepared statements while parsing the schema. check-in: ae04d2d1 user: drh tags: trunk
2010-04-08
17:35
Fix a typo in a comment. No changes to code. check-in: 332cb551 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/prepare.c.

    69     69       corruptSchema(pData, argv[0], 0);
    70     70     }else if( argv[2] && argv[2][0] ){
    71     71       /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
    72     72       ** But because db->init.busy is set to 1, no VDBE code is generated
    73     73       ** or executed.  All the parser does is build the internal data
    74     74       ** structures that describe the table, index, or view.
    75     75       */
    76         -    char *zErr;
    77     76       int rc;
           77  +    sqlite3_stmt *pStmt;
           78  +
    78     79       assert( db->init.busy );
    79     80       db->init.iDb = iDb;
    80     81       db->init.newTnum = atoi(argv[1]);
    81     82       db->init.orphanTrigger = 0;
    82         -    rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);
           83  +    rc = sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
    83     84       db->init.iDb = 0;
    84         -    assert( rc!=SQLITE_OK || zErr==0 );
    85     85       if( SQLITE_OK!=rc ){
    86     86         if( db->init.orphanTrigger ){
    87     87           assert( iDb==1 );
    88     88         }else{
    89     89           pData->rc = rc;
    90     90           if( rc==SQLITE_NOMEM ){
    91     91             db->mallocFailed = 1;
    92     92           }else if( rc!=SQLITE_INTERRUPT && rc!=SQLITE_LOCKED ){
    93         -          corruptSchema(pData, argv[0], zErr);
           93  +          corruptSchema(pData, argv[0], sqlite3_errmsg(db));
    94     94           }
    95     95         }
    96         -      sqlite3DbFree(db, zErr);
    97     96       }
           97  +    sqlite3_finalize(pStmt);
    98     98     }else if( argv[0]==0 ){
    99     99       corruptSchema(pData, 0, 0);
   100    100     }else{
   101    101       /* If the SQL column is blank it means this is an index that
   102    102       ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
   103    103       ** constraint for a CREATE TABLE.  The index should have already
   104    104       ** been created when we processed the CREATE TABLE.  All we have