/ Check-in [bf78acb9]
Login

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

Overview
Comment:Add test case to verify [d03d63d77e] works.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bf78acb9dfacde0f08a5b3ceac13480f12a06168
User & Date: dan 2011-04-07 15:24:08
Context
2011-04-07
19:56
Change two new internal functions in where.c from global to file scope. check-in: 5bbfa17d user: drh tags: trunk
15:24
Add test case to verify [d03d63d77e] works. check-in: bf78acb9 user: dan tags: trunk
14:47
When searching a list of freelist trunk pages looking for a specific page to allocate, avoid unnecessary journalling of the unchanged trunk pages towards the start of the list. check-in: d03d63d7 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/incrvacuum2.test.

    19     19   # If this build of the library does not support auto-vacuum, omit this
    20     20   # whole file.
    21     21   ifcapable {!autovacuum || !pragma} {
    22     22     finish_test
    23     23     return
    24     24   }
    25     25   
           26  +set testprefix incrvacuum2
    26     27   
    27     28   # Create a database in incremental vacuum mode that has many
    28     29   # pages on the freelist.
    29     30   #
    30     31   do_test incrvacuum2-1.1 {
    31     32     execsql {
    32     33       PRAGMA page_size=1024;
................................................................................
   127    128       BEGIN;
   128    129       DELETE FROM abc;
   129    130       PRAGMA incremental_vacuum;
   130    131       COMMIT;
   131    132     }
   132    133   } {}
   133    134   
   134         -integrity_check incremental2-3.3
          135  +integrity_check incrvacuum2-3.3
          136  +
          137  +ifcapable wal {
          138  +  # At one point, when a specific page was being extracted from the b-tree
          139  +  # free-list (e.g. during an incremental-vacuum), all trunk pages that
          140  +  # occurred before the specific page in the free-list trunk were being
          141  +  # written to the journal or wal file. This is not necessary. Only the 
          142  +  # extracted page and the page that contains the pointer to it need to
          143  +  # be journalled.
          144  +  #
          145  +  # This problem was fixed by [d03d63d77e] (just before 3.7.6 release).
          146  +  #
          147  +  # This test case builds a database containing many free pages. Then runs
          148  +  # "PRAGMA incremental_vacuum(1)" until the db contains zero free pages.
          149  +  # Each "PRAGMA incremental_vacuum(1)" should modify at most 4 pages. The
          150  +  # worst case is when a trunk page is removed from the end of the db file.
          151  +  # In this case pages written are:
          152  +  #
          153  +  #   1. The previous trunk page (that contains a pointer to the recycled
          154  +  #      trunk page), and
          155  +  #   2. The leaf page transformed into a trunk page to replace the recycled
          156  +  #      page, and
          157  +  #   3. The trunk page that contained a pointer to the leaf page used 
          158  +  #      in (2), and
          159  +  #   4. Page 1. Page 1 is always updated, even in WAL mode, since it contains
          160  +  #      the "number of free-list pages" field.
          161  +  #
          162  +  db close
          163  +  forcedelete test.db
          164  +  sqlite3 db test.db
          165  +
          166  +  do_execsql_test 4.1 {
          167  +    PRAGMA page_size = 512;
          168  +    PRAGMA auto_vacuum = 2;
          169  +    CREATE TABLE t1(x);
          170  +    INSERT INTO t1 VALUES(randomblob(400));
          171  +    INSERT INTO t1 SELECT * FROM t1;            --    2
          172  +    INSERT INTO t1 SELECT * FROM t1;            --    4
          173  +    INSERT INTO t1 SELECT * FROM t1;            --    8
          174  +    INSERT INTO t1 SELECT * FROM t1;            --   16
          175  +    INSERT INTO t1 SELECT * FROM t1;            --   32
          176  +    INSERT INTO t1 SELECT * FROM t1;            --  128
          177  +    INSERT INTO t1 SELECT * FROM t1;            --  256
          178  +    INSERT INTO t1 SELECT * FROM t1;            --  512
          179  +    INSERT INTO t1 SELECT * FROM t1;            -- 1024
          180  +    INSERT INTO t1 SELECT * FROM t1;            -- 2048
          181  +    INSERT INTO t1 SELECT * FROM t1;            -- 4096
          182  +    INSERT INTO t1 SELECT * FROM t1;            -- 8192
          183  +    DELETE FROM t1 WHERE oid>512;
          184  +    DELETE FROM t1;
          185  +  }
          186  +
          187  +  do_test 4.2 {
          188  +    execsql { 
          189  +      PRAGMA journal_mode = WAL;
          190  +      PRAGMA incremental_vacuum(1);
          191  +      PRAGMA wal_checkpoint;
          192  +    }
          193  +    file size test.db-wal
          194  +  } {1640}
          195  +
          196  +  do_test 4.3 {
          197  +    db close
          198  +    sqlite3 db test.db
          199  +    set maxsz 0
          200  +    while {[file size test.db] > [expr 512*3]} {
          201  +      execsql { PRAGMA wal_checkpoint }
          202  +      execsql { PRAGMA incremental_vacuum(1) }
          203  +      set newsz [file size test.db-wal]
          204  +      if {$newsz>$maxsz} {set maxsz $newsz}
          205  +    }
          206  +    set maxsz 
          207  +  } {2176}
          208  +}
   135    209   
   136    210   finish_test