/ Check-in [0747b558]
Login

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

Overview
Comment:Ensure the test suite can run with either SQLITE_OMIT_AUTOVACUUM or SQLITE_DEFAULT_AUTOVACUUM=1 defined. (CVS 2087)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0747b55882cf218c03b443e1eadec9eb19889554
User & Date: danielk1977 2004-11-10 15:27:38
Context
2004-11-11
01:50
Add documentation for DEFAULT CURRENT_TIME & co. (CVS 2088) check-in: c85f13f8 user: danielk1977 tags: trunk
2004-11-10
15:27
Ensure the test suite can run with either SQLITE_OMIT_AUTOVACUUM or SQLITE_DEFAULT_AUTOVACUUM=1 defined. (CVS 2087) check-in: 0747b558 user: danielk1977 tags: trunk
12:34
Fix expr.test so that it works when the date-time functions are compiled out of the library. (CVS 2086) check-in: 540ce7de user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.176 2004/11/08 09:26:10 danielk1977 Exp $
           21  +** @(#) $Id: pager.c,v 1.177 2004/11/10 15:27:38 danielk1977 Exp $
    22     22   */
    23     23   #include "sqliteInt.h"
    24     24   #include "os.h"
    25     25   #include "pager.h"
    26     26   #include <assert.h>
    27     27   #include <string.h>
    28     28   
................................................................................
  3327   3327     */
  3328   3328     pPgOld = pager_lookup(pPager, pgno);
  3329   3329     if( pPgOld ){
  3330   3330       assert( pPgOld->nRef==0 );
  3331   3331       unlinkHashChain(pPager, pPgOld);
  3332   3332       pPgOld->dirty = 0;
  3333   3333       if( pPgOld->needSync ){
         3334  +      assert( pPgOld->inJournal );
         3335  +      pPg->inJournal = 1;
  3334   3336         pPg->needSync = 1;
  3335   3337       }
  3336   3338     }
  3337   3339   
  3338   3340     /* Change the page number for pPg and insert it into the new hash-chain. */
  3339   3341     pPg->pgno = pgno;
  3340   3342     h = pager_hash(pgno);

Changes to src/sqliteInt.h.

     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     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.336 2004/11/09 12:44:39 danielk1977 Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.337 2004/11/10 15:27:38 danielk1977 Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** These #defines should enable >2GB file support on Posix if the
    21     21   ** underlying operating system supports it.  If the OS lacks
................................................................................
   102    102   ** a minimum.
   103    103   */
   104    104   /* #define SQLITE_OMIT_AUTHORIZATION  1 */
   105    105   /* #define SQLITE_OMIT_INMEMORYDB     1 */
   106    106   /* #define SQLITE_OMIT_VACUUM         1 */
   107    107   /* #define SQLITE_OMIT_DATETIME_FUNCS 1 */
   108    108   /* #define SQLITE_OMIT_PROGRESS_CALLBACK 1 */
          109  +/* #define SQLITE_OMIT_AUTOVACUUM */
   109    110   
   110    111   /*
   111    112   ** GCC does not define the offsetof() macro so we'll have to do it
   112    113   ** ourselves.
   113    114   */
   114    115   #ifndef offsetof
   115    116   #define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the printf() interface to SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.108 2004/11/05 23:46:15 drh Exp $
           16  +** $Id: test1.c,v 1.109 2004/11/10 15:27:38 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include "os.h"
    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   
................................................................................
  2559   2559     Tcl_SetVar2(interp, "sqlite_options", "bloblit", "1", TCL_GLOBAL_ONLY);
  2560   2560   #endif
  2561   2561   #ifdef SQLITE_OMIT_REINDEX
  2562   2562     Tcl_SetVar2(interp, "sqlite_options", "reindex", "0", TCL_GLOBAL_ONLY);
  2563   2563   #else
  2564   2564     Tcl_SetVar2(interp, "sqlite_options", "reindex", "1", TCL_GLOBAL_ONLY);
  2565   2565   #endif
         2566  +
         2567  +#ifdef SQLITE_OMIT_AUTOVACUUM
         2568  +  Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "0", TCL_GLOBAL_ONLY);
         2569  +#else
         2570  +  Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "1", TCL_GLOBAL_ONLY);
         2571  +#if SQLITE_DEFAULT_AUTOVACUUM==0
         2572  +  Tcl_SetVar2(interp,"sqlite_options","default_autovacuum","0",TCL_GLOBAL_ONLY);
         2573  +#else
         2574  +  Tcl_SetVar2(interp,"sqlite_options","default_autovacuum","1",TCL_GLOBAL_ONLY);
         2575  +#endif
         2576  +#endif /* SQLITE_OMIT_AUTOVACUUM */
  2566   2577   }
  2567   2578   
  2568   2579   /*
  2569   2580   ** Register commands with the TCL interpreter.
  2570   2581   */
  2571   2582   int Sqlitetest1_Init(Tcl_Interp *interp){
  2572   2583     extern int sqlite3_search_count;

Changes to test/attach3.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is testing the ATTACH and DETACH commands
    13     13   # and schema changes to attached databases.
    14     14   #
    15         -# $Id: attach3.test,v 1.12 2004/11/05 05:20:40 drh Exp $
           15  +# $Id: attach3.test,v 1.13 2004/11/10 15:27:38 danielk1977 Exp $
    16     16   #
    17     17   
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     21   
    22     22   # Create tables t1 and t2 in the main database
................................................................................
    51     51       SELECT * FROM sqlite_master WHERE name = 't3';
    52     52     }
    53     53   } {}
    54     54   do_test attach3-1.4 {
    55     55     execsql {
    56     56       SELECT * FROM aux.sqlite_master WHERE name = 't3';
    57     57     }
    58         -} {table t3 t3 4 {CREATE TABLE t3(e, f)}}
           58  +} "table t3 t3 [expr $AUTOVACUUM?5:4] {CREATE TABLE t3(e, f)}"
    59     59   do_test attach3-1.5 {
    60     60     execsql {
    61     61       INSERT INTO t3 VALUES(1, 2);
    62     62       SELECT * FROM t3;
    63     63     }
    64     64   } {1 2}
    65     65   
................................................................................
    74     74       SELECT * FROM sqlite_master WHERE name = 'i1';
    75     75     }
    76     76   } {}
    77     77   do_test attach3-2.3 {
    78     78     execsql {
    79     79       SELECT * FROM aux.sqlite_master WHERE name = 'i1';
    80     80     }
    81         -} {index i1 t3 5 {CREATE INDEX i1 on t3(e)}}
           81  +} "index i1 t3 [expr $AUTOVACUUM?6:5] {CREATE INDEX i1 on t3(e)}"
    82     82   
    83     83   # Drop the index on the aux database table.
    84     84   do_test attach3-3.1 {
    85     85     execsql {
    86     86       DROP INDEX aux.i1;
    87     87       SELECT * FROM aux.sqlite_master WHERE name = 'i1';
    88     88     }
    89     89   } {}
    90     90   do_test attach3-3.2 {
    91     91     execsql {
    92     92       CREATE INDEX aux.i1 on t3(e);
    93     93       SELECT * FROM aux.sqlite_master WHERE name = 'i1';
    94     94     }
    95         -} {index i1 t3 5 {CREATE INDEX i1 on t3(e)}}
           95  +} "index i1 t3 [expr $AUTOVACUUM?6:5] {CREATE INDEX i1 on t3(e)}"
    96     96   do_test attach3-3.3 {
    97     97     execsql {
    98     98       DROP INDEX i1;
    99     99       SELECT * FROM aux.sqlite_master WHERE name = 'i1';
   100    100     }
   101    101   } {}
   102    102   

Changes to test/autovacuum.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the SELECT statement.
    13     13   #
    14         -# $Id: autovacuum.test,v 1.10 2004/11/08 12:32:50 danielk1977 Exp $
           14  +# $Id: autovacuum.test,v 1.11 2004/11/10 15:27:38 danielk1977 Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
           18  +
           19  +# If this build of the library does not support auto-vacuum, omit this
           20  +# whole file.
           21  +ifcapable {!autovacuum} {
           22  +  finish_test
           23  +  return
           24  +}
    18     25   
    19     26   # Return a string $len characters long. The returned string is $char repeated
    20     27   # over and over. For example, [make_str abc 8] returns "abcabcab".
    21     28   proc make_str {char len} {
    22     29     set str [string repeat $char. $len]
    23     30     return [string range $str 0 [expr $len-1]]
    24     31   }
................................................................................
   454    461   do_test autovacuum-3.4 {
   455    462     db close
   456    463     file delete -force test.db
   457    464     sqlite3 db test.db
   458    465     execsql {
   459    466       PRAGMA auto_vacuum;
   460    467     }
   461         -} {0}
          468  +} $AUTOVACUUM
   462    469   do_test autovacuum-3.5 {
   463    470     execsql {
   464    471       CREATE TABLE av1(x);
   465    472       PRAGMA auto_vacuum;
   466    473     }
   467         -} {0}
          474  +} $AUTOVACUUM
   468    475   do_test autovacuum-3.6 {
   469    476     execsql {
   470    477       PRAGMA auto_vacuum = 1;
   471    478       PRAGMA auto_vacuum;
   472    479     }
   473         -} {0}
          480  +} $AUTOVACUUM
   474    481   do_test autovacuum-3.7 {
   475    482     execsql {
   476    483       DROP TABLE av1;
   477    484     }
   478    485     file_pages
   479         -} {2}
          486  +} [expr $AUTOVACUUM?1:2]
   480    487   
   481    488   finish_test
   482    489   

Changes to test/btree.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is btree database backend
    13     13   #
    14         -# $Id: btree.test,v 1.32 2004/11/10 11:55:14 danielk1977 Exp $
           14  +# $Id: btree.test,v 1.33 2004/11/10 15:27:38 danielk1977 Exp $
    15     15   
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
           19  +
           20  +ifcapable default_autovacuum {
           21  +  finish_test
           22  +  return
           23  +}
    19     24   
    20     25   # Basic functionality.  Open and close a database.
    21     26   #
    22     27   do_test btree-1.1 {
    23     28     file delete -force test1.bt
    24     29     file delete -force test1.bt-journal
    25     30     set rc [catch {btree_open test1.bt 2000 0} ::b1]

Changes to test/enc2.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The focus of
    12     12   # this file is testing the SQLite routines used for converting between the
    13     13   # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
    14     14   # UTF-16be).
    15     15   #
    16         -# $Id: enc2.test,v 1.17 2004/06/30 08:20:16 danielk1977 Exp $
           16  +# $Id: enc2.test,v 1.18 2004/11/10 15:27:38 danielk1977 Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # The rough organisation of tests in this file is:
    22     22   #
    23     23   # enc2.1.*: Simple tests with a UTF-8 db.
................................................................................
   416    416       CREATE TABLE abc(a, b, c);
   417    417     } db2
   418    418   } {}
   419    419   do_test enc2-7.4 {
   420    420     execsql {
   421    421       SELECT * FROM sqlite_master;
   422    422     }
   423         -} {table abc abc 2 {CREATE TABLE abc(a, b, c)}}
          423  +} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"
   424    424   do_test enc2-7.5 {
   425    425     execsql {
   426    426       PRAGMA encoding;
   427    427     }
   428    428   } {UTF-8}
   429    429   
   430    430   db close

Changes to test/insert.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the INSERT statement.
    13     13   #
    14         -# $Id: insert.test,v 1.20 2004/11/07 13:01:50 drh Exp $
           14  +# $Id: insert.test,v 1.21 2004/11/10 15:27:38 danielk1977 Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Try to insert into a non-existant table.
    20     20   #
    21     21   do_test insert-1.1 {
................................................................................
   241    241     # Verify that table "test1" begins on page 3.  This should be the same
   242    242     # page number used by "t4" above.
   243    243     #
   244    244     # Update for v3 - the first table now begins on page 2 of each file, not 3.
   245    245     execsql {
   246    246       SELECT rootpage FROM sqlite_master WHERE name='test1';
   247    247     }
   248         -} {2}
          248  +} [expr $AUTOVACUUM?3:2]
   249    249   do_test insert-5.5 {
   250    250     # Verify that "t4" begins on page 3.
   251    251     #
   252    252     # Update for v3 - the first table now begins on page 2 of each file, not 3.
   253    253     execsql {
   254    254       SELECT rootpage FROM sqlite_temp_master WHERE name='t4';
   255    255     }

Changes to test/interrupt.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is the sqlite_interrupt() API.
    13     13   #
    14         -# $Id: interrupt.test,v 1.6 2004/11/04 04:42:28 drh Exp $
           14  +# $Id: interrupt.test,v 1.7 2004/11/10 15:27:38 danielk1977 Exp $
    15     15   
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Compute a checksum on the entire database.
    21     21   #
................................................................................
    98     98     interrupt_test interrupt-2.2 {VACUUM} {} 100
    99     99   }
   100    100   do_test interrupt-2.3 {
   101    101     execsql {
   102    102       SELECT md5sum(a || b) FROM t1;
   103    103     }
   104    104   } $cksum
   105         -ifcapable vacuum {
          105  +ifcapable vacuum&&!$AUTOVACUUM {
   106    106     do_test interrupt-2.4 {
   107    107       expr {$::origsize>[file size test.db]}
   108    108     } 1
   109    109   }
   110    110   integrity_check interrupt-2.5
   111    111   
   112    112   # Ticket #594.  If an interrupt occurs in the middle of a transaction

Changes to test/lock2.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is database locks between competing processes.
    13     13   #
    14         -# $Id: lock2.test,v 1.3 2004/07/22 15:02:26 drh Exp $
           14  +# $Id: lock2.test,v 1.4 2004/11/10 15:27:38 danielk1977 Exp $
    15     15   
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Launch another testfixture process to be controlled by this one. A
    21     21   # channel name is returned that may be passed as the first argument to proc
................................................................................
   140    140       COMMIT;
   141    141     }
   142    142   } {0 {}}
   143    143   do_test lock2-1.9 {
   144    144     execsql {
   145    145       SELECT * FROM sqlite_master;
   146    146     }
   147         -} {table abc abc 2 {CREATE TABLE abc(a, b, c)}}
          147  +} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"
   148    148   do_test lock2-1.10 {
   149    149     testfixture $::tf1 {
   150    150       db eval {
   151    151         SELECT * FROM sqlite_master;
   152    152       }
   153    153     }
   154         -} {table abc abc 2 {CREATE TABLE abc(a, b, c)}}
          154  +} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"
   155    155   
   156    156   catch {testfixture $::tf1 {db close}}
   157    157   catch {close $::tf1}
   158    158   
   159    159   finish_test

Changes to test/pagesize.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   # This file implements tests for the page_size PRAGMA.
    13     13   #
    14         -# $Id: pagesize.test,v 1.7 2004/11/04 04:42:28 drh Exp $
           14  +# $Id: pagesize.test,v 1.8 2004/11/10 15:27:38 danielk1977 Exp $
    15     15   
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   do_test pagesize-1.1 {
    21     21     execsql {PRAGMA page_size}
................................................................................
    83     83       sqlite3 db test.db
    84     84       execsql {
    85     85         PRAGMA page_size
    86     86       }
    87     87     } $PGSZ
    88     88     do_test pagesize-2.$PGSZ.3 {
    89     89       file size test.db
    90         -  } [expr {$PGSZ*2}]
           90  +  } [expr {$PGSZ*($AUTOVACUUM?3:2)}]
    91     91     ifcapable {vacuum} {
    92     92       do_test pagesize-2.$PGSZ.4 {
    93     93         execsql {VACUUM}
    94     94       } {}
    95     95     }
    96     96     integrity_check pagesize-2.$PGSZ.5
    97     97     do_test pagesize-2.$PGSZ.6 {

Changes to test/tester.tcl.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements some common TCL routines used for regression
    12     12   # testing the SQLite library
    13     13   #
    14         -# $Id: tester.tcl,v 1.40 2004/11/03 13:59:06 drh Exp $
           14  +# $Id: tester.tcl,v 1.41 2004/11/10 15:27:38 danielk1977 Exp $
    15     15   
    16     16   # Make sure tclsqlite3 was compiled correctly.  Abort now with an
    17     17   # error message if not.
    18     18   #
    19     19   if {[sqlite3 -tcl-uses-utf]} {
    20     20     if {"\u1234"=="u1234"} {
    21     21       puts stderr "***** BUILD PROBLEM *****"
................................................................................
   237    237     }
   238    238   }
   239    239   
   240    240   # Evaluate a boolean expression of capabilities.  If true, execute the
   241    241   # code.  Omit the code if false.
   242    242   #
   243    243   proc ifcapable {expr code} {
   244         -  regsub -all {[a-z]+} $expr {$::sqlite_options(&)} e2
          244  +  regsub -all {[a-z_]+} $expr {$::sqlite_options(&)} e2
   245    245     if !($e2) return
   246    246     return -code [catch {uplevel 1 $code}]
   247    247   }
          248  +
          249  +# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
          250  +# to non-zero, then set the global variable $AUTOVACUUM to 1.
          251  +set AUTOVACUUM $sqlite_options(default_autovacuum)
          252  +

Changes to test/vacuum.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the VACUUM statement.
    13     13   #
    14         -# $Id: vacuum.test,v 1.28 2004/11/04 04:42:28 drh Exp $
           14  +# $Id: vacuum.test,v 1.29 2004/11/10 15:27:38 danielk1977 Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # If the VACUUM statement is disabled in the current build, skip all
    20     20   # the tests in this file.
    21     21   #
    22     22   ifcapable {!vacuum} {
    23     23     finish_test
    24     24     return
           25  +}
           26  +if $AUTOVACUUM {
           27  +  finish_test
           28  +  return
    25     29   }
    26     30   
    27     31   set fcnt 1
    28     32   proc cksum {{db db}} {
    29     33     set sql "SELECT name, type, sql FROM sqlite_master ORDER BY name, type"
    30     34     set txt [$db eval $sql]\n
    31     35     set sql "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"