/ Check-in [fe548561]
Login

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

Overview
Comment:Fixes so that compiling and testing works when SQLITE_OMIT_AUTOVACUUM is defined. (CVS 2218)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fe548561a0e7a696fd453372f4427cf3e3f19d20
User & Date: danielk1977 2005-01-16 09:06:34
Context
2005-01-16
11:07
Changes to make sure tests work when SQLITE_DEFAULT_AUTOVACUUM is defined. (CVS 2219) check-in: 6237c294 user: danielk1977 tags: trunk
09:06
Fixes so that compiling and testing works when SQLITE_OMIT_AUTOVACUUM is defined. (CVS 2218) check-in: fe548561 user: danielk1977 tags: trunk
08:00
Move duplicate code to update pointer-map wrt overflow pages into a function. (CVS 2217) check-in: a5c21214 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.235 2005/01/16 08:00:01 danielk1977 Exp $
           12  +** $Id: btree.c,v 1.236 2005/01/16 09:06:34 danielk1977 Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** For a detailed discussion of BTrees, refer to
    16     16   **
    17     17   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    18     18   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    19     19   **     Publishing Company, Reading, Massachusetts.
................................................................................
  3722   3722     u8 *apDiv[NB];               /* Divider cells in pParent */
  3723   3723     int cntNew[NB+2];            /* Index in aCell[] of cell after i-th page */
  3724   3724     int szNew[NB+2];             /* Combined size of cells place on i-th page */
  3725   3725     u8 **apCell;                 /* All cells begin balanced */
  3726   3726     int *szCell;                 /* Local size of all cells in apCell[] */
  3727   3727     u8 *aCopy[NB];               /* Space for holding data of apCopy[] */
  3728   3728     u8 *aSpace;                  /* Space to hold copies of dividers cells */
  3729         -#ifndef SQLITE_OMIT_VACUUM
         3729  +#ifndef SQLITE_OMIT_AUTOVACUUM
  3730   3730     u8 *aFrom = 0;
  3731   3731   #endif
  3732   3732   
  3733   3733     /* 
  3734   3734     ** Find the parent page.
  3735   3735     */
  3736   3736     assert( pPage->isInit );
................................................................................
  4223   4223     MemPage *pChild;             /* The only child page of pPage */
  4224   4224     Pgno pgnoChild;              /* Page number for pChild */
  4225   4225     int rc = SQLITE_OK;          /* Return code from subprocedures */
  4226   4226     Btree *pBt;                  /* The main BTree structure */
  4227   4227     int mxCellPerPage;           /* Maximum number of cells per page */
  4228   4228     u8 **apCell;                 /* All cells from pages being balanced */
  4229   4229     int *szCell;                 /* Local size of all cells */
  4230         -  int i;
  4231   4230   
  4232   4231     assert( pPage->pParent==0 );
  4233   4232     assert( pPage->nCell==0 );
  4234   4233     pBt = pPage->pBt;
  4235   4234     mxCellPerPage = MX_CELL(pBt);
  4236   4235     apCell = sqliteMallocRaw( mxCellPerPage*(sizeof(u8*)+sizeof(int)) );
  4237   4236     if( apCell==0 ) return SQLITE_NOMEM;
................................................................................
  4353   4352     if( pChild->nOverflow ){
  4354   4353       pChild->nFree = 0;
  4355   4354     }
  4356   4355     assert( pChild->nCell==pPage->nCell );
  4357   4356     zeroPage(pPage, pChild->aData[0] & ~PTF_LEAF);
  4358   4357     put4byte(&pPage->aData[pPage->hdrOffset+8], pgnoChild);
  4359   4358     TRACE(("BALANCE: copy root %d into %d\n", pPage->pgno, pChild->pgno));
         4359  +#ifndef SQLITE_OMIT_AUTOVACUUM
  4360   4360     if( pBt->autoVacuum ){
  4361   4361       int i;
  4362   4362       rc = ptrmapPut(pBt, pChild->pgno, PTRMAP_BTREE, pPage->pgno);
  4363   4363       if( rc ) return rc;
  4364   4364       for(i=0; i<pChild->nCell; i++){
  4365   4365         rc = ptrmapPutOvfl(pChild, i);
  4366   4366         if( rc!=SQLITE_OK ){
  4367   4367           return rc;
  4368   4368         }
  4369   4369       }
  4370   4370     }
         4371  +#endif
  4371   4372     rc = balance_nonroot(pChild);
  4372   4373     releasePage(pChild);
  4373   4374     return rc;
  4374   4375   }
  4375   4376   
  4376   4377   /*
  4377   4378   ** Decide if the page pPage needs to be balanced.  If balancing is

Changes to test/autovacuum_crash.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12     12   # This file runs the tests in the file crash.test with auto-vacuum enabled
    13     13   # databases.
    14     14   #
    15         -# $Id: autovacuum_crash.test,v 1.1 2004/11/08 09:51:09 danielk1977 Exp $
           15  +# $Id: autovacuum_crash.test,v 1.2 2005/01/16 09:06:34 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
           19  +
           20  +# If this build of the library does not support auto-vacuum, omit this
           21  +# whole file.
           22  +ifcapable {!autovacuum} {
           23  +  finish_test
           24  +  return
           25  +}
           26  +
    19     27   rename finish_test really_finish_test2
    20     28   proc finish_test {} {}
    21     29   set ISQUICK 1
    22     30   
    23     31   rename sqlite3 real_sqlite3
    24     32   proc sqlite3 {args} {
    25     33     set r [eval "real_sqlite3 $args"]

Changes to test/autovacuum_ioerr.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12     12   # This file runs the tests in the file crash.test with auto-vacuum enabled
    13     13   # databases.
    14     14   #
    15         -# $Id: autovacuum_ioerr.test,v 1.1 2005/01/11 10:25:07 danielk1977 Exp $
           15  +# $Id: autovacuum_ioerr.test,v 1.2 2005/01/16 09:06:34 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
           19  +
           20  +# If this build of the library does not support auto-vacuum, omit this
           21  +# whole file.
           22  +ifcapable {!autovacuum} {
           23  +  finish_test
           24  +  return
           25  +}
           26  +
    19     27   rename finish_test really_finish_test2
    20     28   proc finish_test {} {}
    21     29   set ISQUICK 1
    22     30   
    23     31   rename sqlite3 real_sqlite3
    24     32   proc sqlite3 {args} {
    25     33     set r [eval "real_sqlite3 $args"]

Changes to test/autovacuum_ioerr2.test.

    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing for correct handling of I/O errors
    13     13   # such as writes failing because the disk is full.
    14     14   # 
    15     15   # The tests in this file use special facilities that are only
    16     16   # available in the SQLite test fixture.
    17     17   #
    18         -# $Id: autovacuum_ioerr2.test,v 1.2 2005/01/15 12:45:51 danielk1977 Exp $
           18  +# $Id: autovacuum_ioerr2.test,v 1.3 2005/01/16 09:06:34 danielk1977 Exp $
    19     19   
    20     20   set testdir [file dirname $argv0]
    21     21   source $testdir/tester.tcl
           22  +
           23  +# If this build of the library does not support auto-vacuum, omit this
           24  +# whole file.
           25  +ifcapable {!autovacuum} {
           26  +  finish_test
           27  +  return
           28  +}
    22     29   
    23     30   proc opendb {} {
    24     31     catch {file delete -force test.db}
    25     32     catch {file delete -force test.db-journal}
    26     33     sqlite3 db test.db
    27     34     execsql {pragma auto_vacuum = 1}
    28     35     execsql {SELECT * FROM sqlite_master}

Changes to test/crash.test.

    16     16   # module "crashtest" compiled with the special "os_test.c" backend is used.
    17     17   # The os_test.c simulates the kind of file corruption that can occur
    18     18   # when writes are happening at the moment of power loss.
    19     19   # 
    20     20   # The special crash-test module with its os_test.c backend only works
    21     21   # on Unix.
    22     22   #
    23         -# $Id: crash.test,v 1.15 2005/01/15 12:45:51 danielk1977 Exp $
           23  +# $Id: crash.test,v 1.16 2005/01/16 09:06:34 danielk1977 Exp $
    24     24   
    25     25   set testdir [file dirname $argv0]
    26     26   source $testdir/tester.tcl
    27     27   
    28     28   # set repeats 100
    29     29   set repeats 10
    30     30   
................................................................................
    64     64   proc signature {} {
    65     65     return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
    66     66   }
    67     67   proc signature2 {} {
    68     68     return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc2}]
    69     69   }
    70     70   
    71         -# This variable is set to 1 if the databases being used support auto-vacuum.
    72         -# This is because some of the tests in this file verify file-size, which is
    73         -# slightly larger for auto-vacuum databases.
    74         -set AUTOVACUUM [db eval {pragma auto_vacuum}]
    75         -
    76     71   #--------------------------------------------------------------------------
    77     72   # Simple crash test:
    78     73   #
    79     74   # crash-1.1: Create a database with a table with two rows.
    80     75   # crash-1.2: Run a 'DELETE FROM abc WHERE a = 1' that crashes during
    81     76   #            the first journal-sync.
    82     77   # crash-1.3: Ensure the database is in the same state as after crash-1.1.
................................................................................
   346    341       INSERT INTO abc SELECT * FROM abc;
   347    342       INSERT INTO abc SELECT * FROM abc;
   348    343       INSERT INTO abc SELECT * FROM abc;
   349    344     }
   350    345   } {}
   351    346   do_test crash-5.2 {
   352    347     expr [file size test.db] / 1024
   353         -} [expr $AUTOVACUUM ? 11 : 10]
          348  +} [expr [string match [execsql {pragma auto_vacuum}] 1] ? 11 : 10]
   354    349   set sig [signature]
   355    350   do_test crash-5.3 {
   356    351   # The SQL below is used to expose a bug that existed in
   357    352   # sqlite3pager_movepage() during development of the auto-vacuum feature. It
   358    353   # functions as follows:
   359    354   # 
   360    355   # 1: Begin a transaction.
................................................................................
   423    418     puts -nonewline $f "\00\00\00\00"
   424    419     close $f
   425    420   } {}
   426    421   do_test crash-7.2 {
   427    422     signature
   428    423   } $sig
   429    424   
   430         -# The AUTOVACUUM was changed above.  We have to reset it for
   431         -# other scripts that run as part of "fulltest"
   432         -#
   433         -set AUTOVACUUM $sqlite_options(default_autovacuum)
   434         -
   435    425   finish_test

Changes to test/ioerr.test.

    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing for correct handling of I/O errors
    13     13   # such as writes failing because the disk is full.
    14     14   # 
    15     15   # The tests in this file use special facilities that are only
    16     16   # available in the SQLite test fixture.
    17     17   #
    18         -# $Id: ioerr.test,v 1.13 2005/01/14 13:50:13 danielk1977 Exp $
           18  +# $Id: ioerr.test,v 1.14 2005/01/16 09:06:34 danielk1977 Exp $
    19     19   
    20     20   set testdir [file dirname $argv0]
    21     21   source $testdir/tester.tcl
    22     22   
    23         -set ::AV [execsql {pragma auto_vacuum}]
    24         -
    25     23   # Usage: do_ioerr_test <test number> <options...>
    26     24   #
    27     25   # The first argument, <test number>, is an integer used to name the
    28     26   # tests executed by this proc. Options are as follows:
    29     27   #
    30     28   #     -tclprep          TCL script to run to prepare test.
    31     29   #     -sqlprep          SQL script to run to prepare test.
................................................................................
   106    104     SELECT * FROM t1;
   107    105     BEGIN TRANSACTION;
   108    106     INSERT INTO t1 VALUES(1,2,3);
   109    107     INSERT INTO t1 VALUES(4,5,6);
   110    108     COMMIT;
   111    109     SELECT * FROM t1;
   112    110     DELETE FROM t1 WHERE a<100;
   113         -} -exclude [expr [execsql {pragma auto_vacuum}] ? 8 : 0]
          111  +} -exclude [expr [string match [execsql {pragma auto_vacuum}] 1] ? 8 : 0]
   114    112   
   115    113   
   116    114   proc cksum {{db db}} {
   117    115     set txt [$db eval {
   118    116         SELECT name, type, sql FROM sqlite_master order by name
   119    117     }]\n
   120    118     foreach tbl [$db eval {
................................................................................
   224    222   do_ioerr_test 5 -sqlprep {
   225    223     ATTACH 'test2.db' AS test2;
   226    224   } -sqlbody {
   227    225     BEGIN;
   228    226     CREATE TABLE t1(a,b,c);
   229    227     CREATE TABLE test2.t2(a,b,c);
   230    228     COMMIT;
   231         -} -exclude [expr [execsql {pragma auto_vacuum}] ? 8 : 0]
          229  +} -exclude [expr [string match [execsql {pragma auto_vacuum}] 1] ? 8 : 0]
   232    230   
   233    231   # Test IO errors when replaying two hot journals from a 2-file 
   234    232   # transaction. This test only runs on UNIX.
   235    233   if {$tcl_platform(platform)=="unix" && [file exists ./crashtest]} {
   236    234     do_ioerr_test 6 -tclprep {
   237    235       set rc [crashsql 2 test2.db-journal {
   238    236         ATTACH 'test2.db' as aux;
................................................................................
   280    278   # } -sqlbody {
   281    279   #   BEGIN;
   282    280   #   INSERT INTO abc VALUES(1, 2, 3);
   283    281   #   COMMIT;
   284    282   # }
   285    283   
   286    284   finish_test
   287         -
   288         -
   289    285   
   290    286   

Changes to test/misuse.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the SQLITE_MISUSE detection logic.
    14     14   # This test file leaks memory and file descriptors.
    15     15   #
    16         -# $Id: misuse.test,v 1.8 2004/11/14 21:56:31 drh Exp $
           16  +# $Id: misuse.test,v 1.9 2005/01/16 09:06:34 danielk1977 Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   proc catchsql2 {sql} {
    22     22     set r [
    23     23       catch {
................................................................................
    36     36   
    37     37   
    38     38   # Make sure the test logic works
    39     39   #
    40     40   do_test misuse-1.1 {
    41     41     db close
    42     42     catch {file delete -force test2.db}
           43  +  catch {file delete -force test2.db-journal}
    43     44     set ::DB [sqlite3 db test2.db]
    44     45     execsql {
    45     46       CREATE TABLE t1(a,b);
    46     47       INSERT INTO t1 VALUES(1,2);
    47     48     }
    48     49     catchsql2 {
    49     50       SELECT * FROM t1