/ Check-in [23eac52e]
Login

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

Overview
Comment:Fix a problem in rbu vacuum on tables with a large sqlite_master table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rbu-vacuum
Files: files | file ages | folders
SHA1: 23eac52e987996afe8db847921aef434cebd25b5
User & Date: dan 2016-04-21 15:26:26
Context
2016-04-21
16:44
If a call to sqlite3rbu_close() on an rbu handle opened by sqlite3rbu_vacuum() returns other than SQLITE_OK, delete the contents of the rbu_state table. This ensures that if an RBU vacuum operation either completes successfully or encounters an error, the next call to sqlite3rbu_vacuum() with the same parameters starts a new RBU vacuum operation. Closed-Leaf check-in: 6e4ac704 user: dan tags: rbu-vacuum
15:26
Fix a problem in rbu vacuum on tables with a large sqlite_master table. check-in: 23eac52e user: dan tags: rbu-vacuum
2016-04-20
20:08
Add a documentation comment for sqlite3rbu_vacuum() to sqlite3rbu.h. check-in: da5c753d user: dan tags: rbu-vacuum
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rbu/rbuvacuum.test.

   237    237     do_rbu_vacuum_test 1.9.1 $step
   238    238     do_execsql_test 1.9.2 {
   239    239       PRAGMA main.page_size;
   240    240       PRAGMA main.auto_vacuum;
   241    241       PRAGMA main.user_version;
   242    242       PRAGMA main.application_id;
   243    243     } {8192 2 412 413}
          244  +
          245  +  # Vacuum a database with a large sqlite_master table.
          246  +  #
          247  +  reset_db
          248  +  do_test 1.10.1 {
          249  +    for {set i 1} {$i < 50} {incr i} {
          250  +      execsql "PRAGMA page_size = 1024"
          251  +      execsql "CREATE TABLE t$i (a, b, c, PRIMARY KEY(a, b));"
          252  +      execsql "
          253  +        INSERT INTO t$i VALUES(1, 2, 3);
          254  +        INSERT INTO t$i VALUES(4, 5, 6);
          255  +      "
          256  +    }
          257  +  } {}
          258  +  do_rbu_vacuum_test 1.10.2 $step
   244    259   }
   245    260   
   246    261   #-------------------------------------------------------------------------
   247    262   # Test some error cases:
   248    263   #
   249    264   #   2.1.* the db being vacuumed being in wal mode already.
   250    265   #   2.2.* database modified mid vacuum.

Changes to ext/rbu/sqlite3rbu.c.

  3948   3948             rbuPutU32(&aBuf[52], iRoot);      /* largest root page number */
  3949   3949             rbuPutU32(&aBuf[36], 0);          /* number of free pages */
  3950   3950             rbuPutU32(&aBuf[32], 0);          /* first page on free list trunk */
  3951   3951             rbuPutU32(&aBuf[28], 1);          /* size of db file in pages */
  3952   3952             rbuPutU32(&aBuf[24], pRbu->pRbuFd->iCookie+1);  /* Change counter */
  3953   3953   
  3954   3954             if( iAmt>100 ){
  3955         -            assert( iAmt>=101 );
  3956         -            memset(&aBuf[101], 0, iAmt-101);
         3955  +            memset(&aBuf[100], 0, iAmt-100);
  3957   3956               rbuPutU16(&aBuf[105], iAmt & 0xFFFF);
         3957  +            aBuf[100] = 0x0D;
  3958   3958             }
  3959   3959           }
  3960   3960         }
  3961   3961   #endif
  3962   3962       }
  3963   3963       if( rc==SQLITE_OK && iOfst==0 && (p->openFlags & SQLITE_OPEN_MAIN_DB) ){
  3964   3964         /* These look like magic numbers. But they are stable, as they are part