/ Check-in [82952d08]
Login

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

Overview
Comment:Verify that the schema has not changed before running PRAGMA table_info, index_list, index_info, and foreign_key_list.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 82952d08f3e3aa80a7f51e80dbc89742cb4a09f0
User & Date: drh 2013-02-14 16:16:05
Context
2013-02-15
04:21
Check for a NULL handle prior to manually calling winClose. check-in: 843e1c54 user: mistachkin tags: trunk
2013-02-14
16:16
Verify that the schema has not changed before running PRAGMA table_info, index_list, index_info, and foreign_key_list. check-in: 82952d08 user: drh tags: trunk
2013-02-13
22:54
On WinCE, fill in the winFile structure after winceCreateLock has succeeded. check-in: ec13544c user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

   954    954         int i, k;
   955    955         int nHidden = 0;
   956    956         Column *pCol;
   957    957         Index *pPk;
   958    958         for(pPk=pTab->pIndex; pPk && pPk->autoIndex!=2; pPk=pPk->pNext){}
   959    959         sqlite3VdbeSetNumCols(v, 6);
   960    960         pParse->nMem = 6;
          961  +      sqlite3CodeVerifySchema(pParse, iDb);
   961    962         sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", SQLITE_STATIC);
   962    963         sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
   963    964         sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "type", SQLITE_STATIC);
   964    965         sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "notnull", SQLITE_STATIC);
   965    966         sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "dflt_value", SQLITE_STATIC);
   966    967         sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "pk", SQLITE_STATIC);
   967    968         sqlite3ViewGetColumnNames(pParse, pTab);
................................................................................
   999   1000       if( sqlite3ReadSchema(pParse) ) goto pragma_out;
  1000   1001       pIdx = sqlite3FindIndex(db, zRight, zDb);
  1001   1002       if( pIdx ){
  1002   1003         int i;
  1003   1004         pTab = pIdx->pTable;
  1004   1005         sqlite3VdbeSetNumCols(v, 3);
  1005   1006         pParse->nMem = 3;
         1007  +      sqlite3CodeVerifySchema(pParse, iDb);
  1006   1008         sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC);
  1007   1009         sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC);
  1008   1010         sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC);
  1009   1011         for(i=0; i<pIdx->nColumn; i++){
  1010   1012           int cnum = pIdx->aiColumn[i];
  1011   1013           sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
  1012   1014           sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2);
................................................................................
  1025   1027       if( pTab ){
  1026   1028         v = sqlite3GetVdbe(pParse);
  1027   1029         pIdx = pTab->pIndex;
  1028   1030         if( pIdx ){
  1029   1031           int i = 0; 
  1030   1032           sqlite3VdbeSetNumCols(v, 3);
  1031   1033           pParse->nMem = 3;
         1034  +        sqlite3CodeVerifySchema(pParse, iDb);
  1032   1035           sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
  1033   1036           sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
  1034   1037           sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
  1035   1038           while(pIdx){
  1036   1039             sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
  1037   1040             sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
  1038   1041             sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);
................................................................................
  1088   1091       if( pTab ){
  1089   1092         v = sqlite3GetVdbe(pParse);
  1090   1093         pFK = pTab->pFKey;
  1091   1094         if( pFK ){
  1092   1095           int i = 0; 
  1093   1096           sqlite3VdbeSetNumCols(v, 8);
  1094   1097           pParse->nMem = 8;
         1098  +        sqlite3CodeVerifySchema(pParse, iDb);
  1095   1099           sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "id", SQLITE_STATIC);
  1096   1100           sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "seq", SQLITE_STATIC);
  1097   1101           sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "table", SQLITE_STATIC);
  1098   1102           sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "from", SQLITE_STATIC);
  1099   1103           sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "to", SQLITE_STATIC);
  1100   1104           sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "on_update", SQLITE_STATIC);
  1101   1105           sqlite3VdbeSetColName(v, 6, COLNAME_NAME, "on_delete", SQLITE_STATIC);

Changes to test/pragma.test.

  1622   1622   do_test 22.4.2 {
  1623   1623     execsql { PRAGMA main.integrity_check; }
  1624   1624   } [list $mainerr]
  1625   1625   do_test 22.4.3 {
  1626   1626     execsql { PRAGMA aux.integrity_check; }
  1627   1627   } {ok}
  1628   1628   
         1629  +db close
         1630  +forcedelete test.db test.db-wal test.db-journal
         1631  +sqlite3 db test.db
         1632  +sqlite3 db2 test.db
         1633  +do_test 23.1 {
         1634  +  db eval {
         1635  +    CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);
         1636  +    CREATE INDEX i1 ON t1(b,c);
         1637  +    CREATE INDEX i2 ON t1(c,d);
         1638  +    CREATE TABLE t2(x INTEGER REFERENCES t1);
         1639  +  }
         1640  +  db2 eval {SELECT name FROM sqlite_master}
         1641  +} {t1 i1 i2 t2}
         1642  +do_test 23.2 {
         1643  +  db eval {
         1644  +    DROP INDEX i2;
         1645  +    CREATE INDEX i2 ON t1(c,d,b);
         1646  +  }
         1647  +  db2 eval {PRAGMA index_info(i2)}
         1648  +} {0 2 c 1 3 d 2 1 b}
         1649  +do_test 23.3 {
         1650  +  db eval {
         1651  +    CREATE INDEX i3 ON t1(d,b,c);
         1652  +  }
         1653  +  db2 eval {PRAGMA index_list(t1)}
         1654  +} {0 i3 0 1 i2 0 2 i1 0}
         1655  +do_test 23.4 {
         1656  +  db eval {
         1657  +    ALTER TABLE t1 ADD COLUMN e;
         1658  +  }
         1659  +  db2 eval {
         1660  +    PRAGMA table_info(t1);
         1661  +  }
         1662  +} {/4 e {} 0 {} 0/}
         1663  +do_test 23.5 {
         1664  +  db eval {
         1665  +    DROP TABLE t2;
         1666  +    CREATE TABLE t2(x, y INTEGER REFERENCES t1);
         1667  +  }
         1668  +  db2 eval {
         1669  +    PRAGMA foreign_key_list(t2);
         1670  +  }
         1671  +} {0 0 t1 y {} {NO ACTION} {NO ACTION} NONE}
         1672  +
  1629   1673   finish_test