/ Check-in [3a09f560]
Login

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

Overview
Comment:Update some test cases that deal with corrupt databases.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: 3a09f5605ac7c6e503eb10acfdc607010414d917
User & Date: dan 2014-02-28 18:39:51
Context
2014-03-01
19:44
Remove the vdbeRecordCompareLargeHeader function. Fix some other details. check-in: 3861e853 user: dan tags: experimental
2014-02-28
18:39
Update some test cases that deal with corrupt databases. check-in: 3a09f560 user: dan tags: experimental
09:48
Minor tweak to vdbeRecordCompareInt(). check-in: 284bde0e user: dan tags: experimental
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

  3593   3593       case 9:
  3594   3594         lhs = 1;
  3595   3595         break;
  3596   3596   
  3597   3597       /* This case could be removed without changing the results of running
  3598   3598       ** this code. Including it causes gcc to generate a faster switch 
  3599   3599       ** statement (since the range of switch targets now starts at zero and
  3600         -    ** is contiguous)) but does not cause any duplicate code to be generated
         3600  +    ** is contiguous) but does not cause any duplicate code to be generated
  3601   3601       ** (as gcc is clever enough to combine the two like cases). Other 
  3602   3602       ** compilers might be similar.  */ 
  3603   3603       case 0: case 7:
  3604   3604         return vdbeRecordCompare(nKey1, pKey1, szHdr, 1, pPKey2);
  3605   3605   
  3606   3606       default:
  3607   3607         return vdbeRecordCompare(nKey1, pKey1, szHdr, 1, pPKey2);

Changes to src/vdbemem.c.

   909    909         nByte = sizeof(Mem) * nCol + ROUND8(sizeof(UnpackedRecord));
   910    910         pRec = (UnpackedRecord*)sqlite3DbMallocZero(db, nByte);
   911    911         if( pRec ){
   912    912           pRec->pKeyInfo = sqlite3KeyInfoOfIndex(p->pParse, pIdx);
   913    913           if( pRec->pKeyInfo ){
   914    914             assert( pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField==nCol );
   915    915             assert( pRec->pKeyInfo->enc==ENC(db) );
   916         -          pRec->flags = UNPACKED_PREFIX_MATCH;
   917    916             pRec->aMem = (Mem *)((u8*)pRec + ROUND8(sizeof(UnpackedRecord)));
   918    917             for(i=0; i<nCol; i++){
   919    918               pRec->aMem[i].flags = MEM_Null;
   920    919               pRec->aMem[i].memType = MEM_Null;
   921    920               pRec->aMem[i].db = db;
   922    921             }
   923    922           }else{

Changes to test/analyze9.test.

   322    322   #-------------------------------------------------------------------------
   323    323   # The following tests experiment with adding corrupted records to the
   324    324   # 'sample' column of the sqlite_stat4 table.
   325    325   #
   326    326   reset_db
   327    327   sqlite3_db_config_lookaside db 0 0 0
   328    328   
          329  +database_may_be_corrupt
   329    330   do_execsql_test 7.1 {
   330    331     CREATE TABLE t1(a, b);
   331    332     CREATE INDEX i1 ON t1(a, b);
   332    333     INSERT INTO t1 VALUES(1, 1);
   333    334     INSERT INTO t1 VALUES(2, 2);
   334    335     INSERT INTO t1 VALUES(3, 3);
   335    336     INSERT INTO t1 VALUES(4, 4);
................................................................................
   361    362   
   362    363   do_execsql_test 7.5 {
   363    364     ANALYZE;
   364    365     UPDATE sqlite_stat4 SET nlt = '0 0 0';
   365    366     ANALYZE sqlite_master;
   366    367     SELECT * FROM t1 WHERE a = 5;
   367    368   } {5 5}
          369  +
          370  +database_never_corrupt
   368    371   
   369    372   #-------------------------------------------------------------------------
   370    373   #
   371    374   reset_db
   372    375   do_execsql_test 8.1 {
   373    376     CREATE TABLE t1(x TEXT);
   374    377     CREATE INDEX i1 ON t1(x);

Changes to test/corruptG.test.

    72     72       SELECT rowid FROM t1 WHERE a='abc' and b='xyz123456789XYZ';
    73     73     }
    74     74     # The following test result is brittle.  The point above is to try to
    75     75     # force a buffer overread by a corrupt database file.  If we get an
    76     76     # incorrect answer from a corrupt database file, that is OK.  If the
    77     77     # result below changes, that just means that "undefined behavior" has
    78     78     # changed.
    79         -} {0 52}
           79  +} {/0 .*/}
    80     80   
    81     81   finish_test

Changes to test/pragma.test.

  1598   1598   } {100}
  1599   1599   
  1600   1600   set mainerr {*** in database main ***
  1601   1601   Multiple uses for byte 672 of page 15}
  1602   1602   set auxerr {*** in database aux ***
  1603   1603   Multiple uses for byte 672 of page 15}
  1604   1604   
         1605  +set mainerr {/{\*\*\* in database main \*\*\*
         1606  +Multiple uses for byte 672 of page 15}.*/}
         1607  +set auxerr {/{\*\*\* in database aux \*\*\*
         1608  +Multiple uses for byte 672 of page 15}.*/}
         1609  +
  1605   1610   do_test 22.2 {
  1606   1611     catch { db close }
  1607   1612     sqlite3 db testerr.db
  1608   1613     execsql { PRAGMA integrity_check }
  1609         -} [list $mainerr]
         1614  +} $mainerr
  1610   1615   
  1611   1616   do_test 22.3.1 {
  1612   1617     catch { db close }
  1613   1618     sqlite3 db test.db
  1614   1619     execsql { 
  1615   1620       ATTACH 'testerr.db' AS 'aux';
  1616   1621       PRAGMA integrity_check;
  1617   1622     }
  1618         -} [list $auxerr]
         1623  +} $auxerr
  1619   1624   do_test 22.3.2 {
  1620   1625     execsql { PRAGMA main.integrity_check; }
  1621   1626   } {ok}
  1622   1627   do_test 22.3.3 {
  1623   1628     execsql { PRAGMA aux.integrity_check; }
  1624         -} [list $auxerr]
         1629  +} $auxerr
  1625   1630   
  1626   1631   do_test 22.4.1 {
  1627   1632     catch { db close }
  1628   1633     sqlite3 db testerr.db
  1629   1634     execsql { 
  1630   1635       ATTACH 'test.db' AS 'aux';
  1631   1636       PRAGMA integrity_check;
  1632   1637     }
  1633         -} [list $mainerr]
         1638  +} $mainerr
  1634   1639   do_test 22.4.2 {
  1635   1640     execsql { PRAGMA main.integrity_check; }
  1636         -} [list $mainerr]
         1641  +} $mainerr
  1637   1642   do_test 22.4.3 {
  1638   1643     execsql { PRAGMA aux.integrity_check; }
  1639   1644   } {ok}
  1640   1645   
  1641   1646   db close
  1642   1647   forcedelete test.db test.db-wal test.db-journal
  1643   1648   sqlite3 db test.db