/ Check-in [0da229b8]
Login

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

Overview
Comment:When parsing the schema, ignore any SQL that does not begin with "CREATE". Cherrypick of [d3c00d61581c].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.8.6
Files: files | file ages | folders
SHA1: 0da229b81ad29d731789c86abadf2abc9bfcd738
User & Date: dan 2015-05-20 19:57:02
Context
2015-05-20
20:21
Fix a bug caused by cherrypicking from a branch that assumes sqlite3_stricmp() can handle NULL arguments. check-in: 2c649cdf user: dan tags: branch-3.8.6
19:57
When parsing the schema, ignore any SQL that does not begin with "CREATE". Cherrypick of [d3c00d61581c]. check-in: 0da229b8 user: dan tags: branch-3.8.6
19:53
Detect and report oversized records constructed from multiple zeroblobs. Cherrypick of [9e139afd9211]. check-in: 4a08f6b8 user: dan tags: branch-3.8.6
2015-04-16
00:26
When parsing the schema, ignore any SQL that does not begin with "CREATE". check-in: d3c00d61 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/prepare.c.

    63     63       return 1;
    64     64     }
    65     65   
    66     66     assert( iDb>=0 && iDb<db->nDb );
    67     67     if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */
    68     68     if( argv[1]==0 ){
    69     69       corruptSchema(pData, argv[0], 0);
    70         -  }else if( argv[2] && argv[2][0] ){
           70  +  }else if( sqlite3_strnicmp(argv[2],"create ",7)==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     76       int rc;
    77     77       sqlite3_stmt *pStmt;
................................................................................
    94     94             db->mallocFailed = 1;
    95     95           }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){
    96     96             corruptSchema(pData, argv[0], sqlite3_errmsg(db));
    97     97           }
    98     98         }
    99     99       }
   100    100       sqlite3_finalize(pStmt);
   101         -  }else if( argv[0]==0 ){
   102         -    corruptSchema(pData, 0, 0);
          101  +  }else if( argv[0]==0 || (argv[2]!=0 && argv[2][0]!=0) ){
          102  +    corruptSchema(pData, argv[0], 0);
   103    103     }else{
   104    104       /* If the SQL column is blank it means this is an index that
   105    105       ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
   106    106       ** constraint for a CREATE TABLE.  The index should have already
   107    107       ** been created when we processed the CREATE TABLE.  All we have
   108    108       ** to do here is record the root page number for that index.
   109    109       */

Changes to test/analyze.test.

   355    355       UPDATE sqlite_master SET sql='nonsense' WHERE name='sqlite_stat1';
   356    356     }
   357    357     db close
   358    358     catch { sqlite3 db test.db }
   359    359     catchsql {
   360    360       ANALYZE
   361    361     }
   362         -} {1 {malformed database schema (sqlite_stat1) - near "nonsense": syntax error}}
          362  +} {1 {malformed database schema (sqlite_stat1)}}
   363    363   
   364    364   finish_test

Changes to test/index3.test.

    47     47     execsql {
    48     48       PRAGMA writable_schema=on;
    49     49       UPDATE sqlite_master SET sql='nonsense';
    50     50     }
    51     51     db close
    52     52     catch { sqlite3 db test.db }
    53     53     catchsql { DROP INDEX i1 }
    54         -} {1 {malformed database schema (t1) - near "nonsense": syntax error}}
           54  +} {1 {malformed database schema (t1)}}
    55     55   
    56     56   finish_test

Changes to test/trigger7.test.

   110    110     execsql {
   111    111       PRAGMA writable_schema=on;
   112    112       UPDATE sqlite_master SET sql='nonsense';
   113    113     }
   114    114     db close
   115    115     catch { sqlite3 db test.db }
   116    116     catchsql { DROP TRIGGER t2r5 }
   117         -} {1 {malformed database schema (t2r12) - near "nonsense": syntax error}}
          117  +} {1 {malformed database schema (t2r12)}}
   118    118   
   119    119   finish_test