/ Check-in [5b1b6970]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Make sure the sqlite3BtreeCount() routine does not leave index cursors in an inconsistent state, as doing so might result in an assertion fault inside of sqlite3BtreeKey() called from saveAllCursors() if content is deleted out from under the statement that issued the sqlite3BtreeCount() call.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5b1b697040116048e464b3ebab8395fe088e389a
User & Date: drh 2014-12-16 00:08:31
Context
2014-12-16
00:20
Enhanced "stress2" testing in the threadtest3.c test program. check-in: ae43539e user: drh tags: trunk
00:08
Make sure the sqlite3BtreeCount() routine does not leave index cursors in an inconsistent state, as doing so might result in an assertion fault inside of sqlite3BtreeKey() called from saveAllCursors() if content is deleted out from under the statement that issued the sqlite3BtreeCount() call. check-in: 5b1b6970 user: drh tags: trunk
2014-12-15
16:27
Add new test file e_walauto.test. check-in: 62ef4514 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  8274   8274       ** caller.
  8275   8275       */
  8276   8276       if( pPage->leaf ){
  8277   8277         do {
  8278   8278           if( pCur->iPage==0 ){
  8279   8279             /* All pages of the b-tree have been visited. Return successfully. */
  8280   8280             *pnEntry = nEntry;
  8281         -          return SQLITE_OK;
         8281  +          return moveToRoot(pCur);
  8282   8282           }
  8283   8283           moveToParent(pCur);
  8284   8284         }while ( pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell );
  8285   8285   
  8286   8286         pCur->aiIdx[pCur->iPage]++;
  8287   8287         pPage = pCur->apPage[pCur->iPage];
  8288   8288       }

Changes to test/pragma.test.

   450    450   } {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in index t1a} {NULL value in t1x.a}}
   451    451   do_execsql_test pragma-3.21 {
   452    452     PRAGMA integrity_check(3);
   453    453   } {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in index t1a}}
   454    454   do_execsql_test pragma-3.22 {
   455    455     PRAGMA integrity_check(2);
   456    456   } {{non-unique entry in index t1a} {NULL value in t1x.a}}
   457         -do_execsql_test pragma-3.21 {
          457  +do_execsql_test pragma-3.23 {
   458    458     PRAGMA integrity_check(1);
   459    459   } {{non-unique entry in index t1a}}
          460  +
          461  +# PRAGMA integrity check (or more specifically the sqlite3BtreeCount()
          462  +# interface) used to leave index cursors in an inconsistent state
          463  +# which could result in an assertion fault in sqlite3BtreeKey()
          464  +# called from saveCursorPosition() if content is removed from the
          465  +# index while the integrity_check is still running.  This test verifies
          466  +# that problem has been fixed.
          467  +#
          468  +do_test pragma-3.30 {
          469  +  db close
          470  +  delete_file test.db
          471  +  sqlite3 db test.db
          472  +  db eval {
          473  +    CREATE TABLE t1(a,b,c);
          474  +    WITH RECURSIVE
          475  +      c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)
          476  +    INSERT INTO t1(a,b,c) SELECT i, printf('xyz%08x',i), 2000-i FROM c;
          477  +    CREATE INDEX t1a ON t1(a);
          478  +    CREATE INDEX t1bc ON t1(b,c);
          479  +  }
          480  +  db eval {PRAGMA integrity_check} {
          481  +     db eval {DELETE FROM t1}
          482  +  }
          483  +} {}
   460    484   
   461    485   # Test modifying the cache_size of an attached database.
   462    486   ifcapable pager_pragmas&&attach {
   463    487   do_test pragma-4.1 {
   464    488     execsql {
   465    489       ATTACH 'test2.db' AS aux;
   466    490       pragma aux.cache_size;