$(TOP)/src/expr.c $(TOP)/src/func.c $(TOP)/src/insert.c $(TOP)/src/os.c \
$(TOP)/src/os_os2.c $(TOP)/src/os_unix.c $(TOP)/src/os_win.c \
$(TOP)/src/pager.c $(TOP)/src/pragma.c $(TOP)/src/prepare.c \
- $(TOP)/src/printf.c $(TOP)/src/select.c $(TOP)/src/tokenize.c \
+ $(TOP)/src/printf.c $(TOP)/src/random.c \
+ $(TOP)/src/select.c $(TOP)/src/tokenize.c \
$(TOP)/src/utf.c $(TOP)/src/util.c $(TOP)/src/vdbeapi.c $(TOP)/src/vdbeaux.c \
$(TOP)/src/vdbe.c $(TOP)/src/vdbemem.c $(TOP)/src/where.c parse.c
-C Work\saround\susing\s(regexp)\sin\sthe\s(ifcapable)\sfunction\sof\sthe\stest\ssuite.\sSo\sthat\ssimpler\sversions\sof\stcl\scan\scall\sit.\s(CVS\s4713)
-D 2008-01-16T08:24:46
+C Get\sall\stests\srunning\swithout\smemory\sleaks.\s(CVS\s4714)
+D 2008-01-16T17:46:38
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F ext/icu/icu.c 12e763d288d23b5a49de37caa30737b971a2f1e2
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F ltmain.sh 56abb507100ed2d4261f6dd1653dec3cf4066387
-F main.mk fdf2d0c24ac01a17d3a608e7c86e9d6a399f5a43
+F main.mk 5ffa15b4f43f4e9720f216b6d8fc7cb96e6e4411
F mkdll.sh 5f8438dcac98e795d7df6529159a1ec566de0183
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb
F src/os_os2.h c3f7d0af7e3453d1d7aa81b06c0a56f5a226530b
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
-F src/os_unix.c 4e67737fec1d1c950e9c3723b424829f7bc22fc9
+F src/os_unix.c e4daef7628f690fa2b188af3632fb18f96525946
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c c832d528ea774c7094d887749d71884984c9034c
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pragma.c b4e77e057990bb2c295c63327406d9bcbf6c9c08
F src/prepare.c c31a879d6795f4765fd0b113675c6debbc96b7fd
F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
-F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da
+F src/random.c 02ef38b469237482f1ea14a78b2087cfbaec48bd
F src/select.c 578f7b01047b20349ead5a36d7e64274a61bea80
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 0691a3d52dc37cf6ac2f74838e5ff8ae1055ac9b
F src/sqliteLimit.h ee4430f88f69bf63527967bb35ca52af7b0ccb1e
F src/table.c 1aeb9eab57b4235db86fe15a35dec76fb445a9c4
F src/tclsqlite.c 9923abeffc9b3d7dad58e92b319661521f60debf
-F src/test1.c 537fea45996bd33d4885c3c1f53761da14011e9b
+F src/test1.c 64912c1e65bdc3eccf3b80c5cc092b163831b367
F src/test2.c 77b34303883b9d722c65a6879bb0163a400e3789
F src/test3.c df62cd5c971dc1ae0be0a1842f9df3390934e7a6
F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736
F src/util.c 05f31144bbd3f1a24f4139ae029c42545cb72624
F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0
-F src/vdbe.c f36700465fe35af303d33d59fef03779d93b2570
+F src/vdbe.c 1c58599437d048a2d14c5ce04e4576d2e3e78dfc
F src/vdbe.h a9166e1601f5b74c20516a74182773a20baee43e
F src/vdbeInt.h 31bd686595356284d5484592e2dc6e58025aa346
F src/vdbeapi.c cb8c427a3ab646490c83204a98e94eff03ee2e89
F test/btree9.test 5d8711b241145b90f65dd1795d5dd8290846fa5e
F test/busy.test 0271c854738e23ad76e10d4096a698e5af29d211
F test/cache.test 3ff445c445742a7b6b9ba6e1d62a25263f9424b9
-F test/capi2.test 3c5066836cbaa9923bcc8282c010aa227bb5efd4
+F test/capi2.test cc64df7560a96f848f919ea2926c60acf639684b
F test/capi3.test 432fabf9c6402ed8ff1ae291e01f0e04b64df3ea
F test/capi3b.test 664eb55318132f292f2c436f90906f578cad6b97
F test/capi3c.test 0b089837ee65a17dd73ea171c4dee5d7ea79dabb
F test/crash.test 1b6ac8410689ff78028887f445062dc897c9ac89
F test/crash2.test 26d7a4c5520201e5de2c696ea51ab946b59dc0e9
F test/crash3.test 0b09687ae1a3ccbcefdfaeb4b963e26e36255d76
-F test/crash4.test d9fefcede579aba418777d81a49f122d0a52369e
+F test/crash4.test 02ff4f15c149ca1e88a5c299b4896c84d9450c3b
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test 199cf68f44e5d9e87a0b8afc7130fdeb4def3272
F test/date.test b2bd57ff2ab6185b9322306f7b68fa647d63c857
F test/insert3.test 9a4ef3526fd3cca8b05278020ec3100448b4c677
F test/insert4.test 6919ddacd79c2cfeb9785b0f84217f9cb14853b5
F test/insert5.test 509017213328147d3acdfa2c441bfd82362dda41
-F test/interrupt.test 81555fb0f8179bb2d0dc7151fd75428223f93cf2
+F test/interrupt.test 42e7cf98646fd9cb4a3b131a93ed3c50b9e149f1
F test/intpkey.test 537669fd535f62632ca64828e435b9e54e8d677f
F test/io.test 80a7a7f1a2792e037d447b03e8c22ee1f6eaf339
-F test/ioerr.test ae429185a3a11a318aa7ec64e2188e6119e43bca
+F test/ioerr.test 5382046b2ef19b9084652e7d2d1e82ab33c0deda
F test/ioerr2.test e3d52c40f43f9b61da9b38951a737e7b84ebae96
F test/ioerr3.test 6f62c1b40365e87d58589def770f35b5d63539e1
F test/join.test af0443185378b64878750aa1cf4b83c216f246b4
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
F test/lock4.test f358fa835dff485d462072eee991111f09e87441
F test/main.test 05f585bb70c05caac3e047903b517cbb319ed204
-F test/malloc.test debc0cb41b7031b316353b949960a70e444fd301
-F test/malloc2.test 850471731efad72af5a7748e366a371933ff0b64
-F test/malloc3.test e484ae14cac9f25e50eb7a6ef59b0d9ef1faecab
+F test/malloc.test 760f346ba190fae9d5b6e495b844c9ce4db989cb
+F test/malloc2.test bacb55551f6f4dc58c538589a8d3e29b127ef8d0
+F test/malloc3.test 5d3839afd98bff92b82d13405f41c96e77ac2a6b
F test/malloc4.test f0e5e0f639f61e2776a6c3f5308f836b3ad8b3c7
F test/malloc5.test 18f3f71756e775a17ce4d0c49d76fb0027dda066
F test/malloc6.test d05fd71ef3c5983d10e0a6d728ea4a502a45a9e4
F test/mallocA.test 5ee8d42ff90e5b1aeee6fb645e73ffcb35bffd21
F test/mallocAll.test 2a2222a5e447be6c6579055a9a26e507e4586f4e
F test/mallocB.test 83bdbea443cc81758a57b0287807b0941218819a
-F test/mallocC.test 6f02fa2b4baa943bc6d6db323d5d07067967e728
+F test/mallocC.test 9daac0aa8e5b0afa7b0a3fb0cd792f02fe0cc838
F test/mallocD.test d638fb8f214b47fd31edfae8af738b92bd943dc0
F test/mallocE.test e15333c394d7c330c8372a7cdf7b0f7c16573082
F test/mallocF.test e1804792a6365ad43589b26608850a38e491170a
-F test/malloc_common.tcl b47137fb36e95fdafb0267745afefcd6b0a5b9dc
+F test/malloc_common.tcl 773db5a49300d650f6578eb44d42ad7dd11f8563
F test/manydb.test 8de36b8d33aab5ef295b11d9e95310aeded31af8
F test/memdb.test a67bda4ff90a38f2b19f6c7f95aa7289e051d893
F test/memleak.test d2d2a1ff7105d32dc3fdf691458cf6cba58c7217
F test/tableapi.test 92651a95c23cf955e92407928e640536402fa3cc
F test/tclsqlite.test 3fac87cb1059c46b8fa8a60b553f4f1adb0fb6d9
F test/temptable.test 19b851b9e3e64d91e9867619b2a3f5fffee6e125
-F test/tester.tcl 9ec2de42f310d5c85945a793d118b595b62526dc
+F test/tester.tcl f851528e033e40b2c708eebf09c6ab4cb27c47d4
F test/thread001.test 8fbd9559da0bbdc273e00318c7fd66c162020af7
F test/thread002.test 2c4ad2c386f60f6fe268cd91c769ee35b3c1fd0b
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
F test/update.test 7669ca789d62c258b678e8aa7a22a57eac10f2cf
F test/utf16.test 20e2d9ba0d57e952a18b1ac8deab9ad49e082893
F test/utf16align.test 7360e84472095518c56746f76b1f9d4dce99fb4d
-F test/vacuum.test cf839fc3ff24d601057319bbb5c700ce9c8e0fb0
-F test/vacuum2.test bbd8412d74e8da5657ac4b43d05097bd6d9d749e
+F test/vacuum.test 7493b09398d576b69a8b2f55bac92d50a9b8e796
+F test/vacuum2.test 970acadc2b4c3342fa2584410d96eae2c2b37c25
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
F test/view.test 7e15fa1ba3267ddaa9ae96b6daf519f23f95b43e
F test/vtab1.test bd905d1d43637a700308da6ffcc4e014c27e2f0a
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P a13d3e953f1a3e451e8708a8ef064aa1d72cb4e9
-R 58a662df8c8fdddfe7a6980f15d2e446
-U danielk1977
-Z 1556b8cb2220031cd0813fc8b184cf26
+P 3aa5606bd4bd750a365454f42ab07826320f5b98
+R c504240cc22c2c769bef9b23e2b21009
+U drh
+Z 8d9f2dc043e5920fdb52614a59dd6687
-3aa5606bd4bd750a365454f42ab07826320f5b98
\ No newline at end of file
+5807921f5a6e2e08f2c9e79aa91d8c587d64de74
\ No newline at end of file
static int unixTruncate(sqlite3_file *id, i64 nByte){
int rc;
assert( id );
+ SimulateIOError( return SQLITE_IOERR_TRUNCATE );
rc = ftruncate(((unixFile*)id)->h, (off_t)nByte);
- SimulateIOError( rc=1 );
if( rc ){
return SQLITE_IOERR_TRUNCATE;
}else{
** Random numbers are used by some of the database backends in order
** to generate random integer keys for tables or random filenames.
**
-** $Id: random.c,v 1.20 2007/08/21 13:51:23 drh Exp $
+** $Id: random.c,v 1.21 2008/01/16 17:46:38 drh Exp $
*/
#include "sqliteInt.h"
+/* All threads share a single random number generator.
+** This structure is the current state of the generator.
+*/
+static struct sqlite3PrngType {
+ unsigned char isInit; /* True if initialized */
+ unsigned char i, j; /* State variables */
+ unsigned char s[256]; /* State variables */
+} sqlite3Prng;
+
/*
** Get a single 8-bit random value from the RC4 PRNG. The Mutex
** must be held while executing this routine.
static int randomByte(void){
unsigned char t;
- /* All threads share a single random number generator.
- ** This structure is the current state of the generator.
- */
- static struct {
- unsigned char isInit; /* True if initialized */
- unsigned char i, j; /* State variables */
- unsigned char s[256]; /* State variables */
- } prng;
/* Initialize the state of the random number generator once,
** the first time this routine is called. The seed value does
** encryption. The RC4 algorithm is being used as a PRNG (pseudo-random
** number generator) not as an encryption device.
*/
- if( !prng.isInit ){
+ if( !sqlite3Prng.isInit ){
int i;
char k[256];
- prng.j = 0;
- prng.i = 0;
+ sqlite3Prng.j = 0;
+ sqlite3Prng.i = 0;
sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k);
for(i=0; i<256; i++){
- prng.s[i] = i;
+ sqlite3Prng.s[i] = i;
}
for(i=0; i<256; i++){
- prng.j += prng.s[i] + k[i];
- t = prng.s[prng.j];
- prng.s[prng.j] = prng.s[i];
- prng.s[i] = t;
+ sqlite3Prng.j += sqlite3Prng.s[i] + k[i];
+ t = sqlite3Prng.s[sqlite3Prng.j];
+ sqlite3Prng.s[sqlite3Prng.j] = sqlite3Prng.s[i];
+ sqlite3Prng.s[i] = t;
}
- prng.isInit = 1;
+ sqlite3Prng.isInit = 1;
}
/* Generate and return single random byte
*/
- prng.i++;
- t = prng.s[prng.i];
- prng.j += t;
- prng.s[prng.i] = prng.s[prng.j];
- prng.s[prng.j] = t;
- t += prng.s[prng.i];
- return prng.s[t];
+ sqlite3Prng.i++;
+ t = sqlite3Prng.s[sqlite3Prng.i];
+ sqlite3Prng.j += t;
+ sqlite3Prng.s[sqlite3Prng.i] = sqlite3Prng.s[sqlite3Prng.j];
+ sqlite3Prng.s[sqlite3Prng.j] = t;
+ t += sqlite3Prng.s[sqlite3Prng.i];
+ return sqlite3Prng.s[t];
}
/*
}
sqlite3_mutex_leave(mutex);
}
+
+#ifdef SQLITE_TEST
+/*
+** For testing purposes, we sometimes want to preserve the state of
+** PRNG and restore the PRNG to its saved state at a later time.
+*/
+static struct sqlite3PrngType sqlite3SavedPrng;
+void sqlite3SavePrngState(void){
+ memcpy(&sqlite3SavedPrng, &sqlite3Prng, sizeof(sqlite3Prng));
+}
+void sqlite3RestorePrngState(void){
+ memcpy(&sqlite3Prng, &sqlite3SavedPrng, sizeof(sqlite3Prng));
+}
+void sqlite3ResetPrngState(void){
+ sqlite3Prng.isInit = 0;
+}
+#endif /* SQLITE_TEST */
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test1.c,v 1.281 2007/12/13 21:54:11 drh Exp $
+** $Id: test1.c,v 1.282 2008/01/16 17:46:38 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
return TCL_OK;
}
+/*
+** tclcmd: save_prng_state
+*/
+static int save_prng_state(
+ ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int objc, /* Number of arguments */
+ Tcl_Obj *CONST objv[] /* Command arguments */
+){
+ extern void sqlite3SavePrngState(void);
+ sqlite3SavePrngState();
+ return TCL_OK;
+}
+/*
+** tclcmd: restore_prng_state
+*/
+static int restore_prng_state(
+ ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int objc, /* Number of arguments */
+ Tcl_Obj *CONST objv[] /* Command arguments */
+){
+ extern void sqlite3RestorePrngState(void);
+ sqlite3RestorePrngState();
+ return TCL_OK;
+}
+/*
+** tclcmd: reset_prng_state
+*/
+static int reset_prng_state(
+ ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int objc, /* Number of arguments */
+ Tcl_Obj *CONST objv[] /* Command arguments */
+){
+ extern void sqlite3ResetPrngState(void);
+ sqlite3ResetPrngState();
+ return TCL_OK;
+}
+
/*
** Register commands with the TCL interpreter.
{ "sqlite3_enable_load_extension", test_enable_load, 0},
{ "sqlite3_extended_result_codes", test_extended_result_codes, 0},
+ { "save_prng_state", save_prng_state, 0 },
+ { "restore_prng_state", restore_prng_state, 0 },
+ { "reset_prng_state", reset_prng_state, 0 },
+
/* sqlite3_column_*() API */
{ "sqlite3_column_count", test_column_count ,0 },
{ "sqlite3_data_count", test_data_count ,0 },
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
-** $Id: vdbe.c,v 1.695 2008/01/12 21:35:57 drh Exp $
+** $Id: vdbe.c,v 1.696 2008/01/16 17:46:38 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
** may be NULL. If it is not NULL, then the update-hook
** (sqlite3.xUpdateCallback) is invoked following a successful insert.
**
+** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically
+** allocated, then ownership of P2 is transferred to the pseudo-cursor
+** and register P2 becomes ephemeral. If the cursor is changed, the
+** value of register P2 will then change. Make sure this does not
+** cause any problems.)
+**
** This instruction only works on tables. The equivalent instruction
** for indices is OP_IdxInsert.
*/
pC->nData = pData->n;
if( pData->flags & MEM_Dyn ){
pC->pData = pData->z;
- pData->flags = MEM_Null;
+ pData->flags &= ~MEM_Dyn;
+ pData->flags |= MEM_Ephem;
}else{
pC->pData = sqlite3_malloc( pC->nData+2 );
if( !pC->pData ) goto no_mem;
# This file implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API.
#
-# $Id: capi2.test,v 1.34 2007/08/22 00:39:21 drh Exp $
+# $Id: capi2.test,v 1.35 2008/01/16 17:46:38 drh Exp $
#
set testdir [file dirname $argv0]
ifcapable {explain} {
do_test capi2-7.12 {
-btree_breakpoint
set x [stepsql $DB {EXPLAIN SELECT * FROM t1}]
lindex $x 0
} {0}
CREATE VIEW view2 AS SELECT * FROM tab1 limit 10 offset 10;
}
} {}
- breakpoint
do_test capi2-13.2 {
check_origins {SELECT col2, col1 FROM view2}
} [list {main tab1 col2} {main tab1 col1}]
# This file contains additional tests to verify that SQLite database
# file survive a power loss or OS crash.
#
-# $Id: crash4.test,v 1.2 2008/01/09 23:21:25 drh Exp $
+# $Id: crash4.test,v 1.3 2008/01/16 17:46:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
return
}
-# Generate a checksum based on the contents of the database. If the
-# checksum of two databases is the same, and the integrity-check passes
-# for both, the two databases are identical.
-#
-proc cksum {{db db}} {
- set ret [list]
- ifcapable tempdb {
- set sql {
- SELECT name FROM sqlite_master WHERE type = 'table' UNION
- SELECT name FROM sqlite_temp_master WHERE type = 'table' UNION
- SELECT 'sqlite_master' UNION
- SELECT 'sqlite_temp_master'
- }
- } else {
- set sql {
- SELECT name FROM sqlite_master WHERE type = 'table' UNION
- SELECT 'sqlite_master'
- }
- }
- set tbllist [$db eval $sql]
- set txt {}
- foreach tbl $tbllist {
- append txt [$db eval "SELECT * FROM $tbl"]
- }
- return [md5 $txt]
-}
# A sequence of SQL commands:
#
# the state of the database prior to any of these statements.
#
set crash4_cksum_set {}
-lappend crash4_cksum_set [cksum db]
+lappend crash4_cksum_set [allcksum db]
foreach cmd $sql_cmd_list {
db eval $cmd
- lappend crash4_cksum_set [cksum db]
+ lappend crash4_cksum_set [allcksum db]
}
# Run the sequence of SQL statements shown above repeatedly.
sqlite3 db test.db
integrity_check crash4-1.$cnt.2
do_test crash4-1.$cnt.3 {
- set x [lsearch $::crash4_cksum_set [cksum db]]
+ set x [lsearch $::crash4_cksum_set [allcksum db]]
expr {$x>=0}
} {1}
}
# This file implements regression tests for SQLite library. The
# focus of this script is the sqlite_interrupt() API.
#
-# $Id: interrupt.test,v 1.15 2007/06/13 16:49:49 danielk1977 Exp $
+# $Id: interrupt.test,v 1.16 2008/01/16 17:46:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set DB [sqlite3_connection_pointer db]
-# Compute a checksum on the entire database.
-#
-proc cksum {{db db}} {
- set txt [$db eval {SELECT name, type, sql FROM sqlite_master}]\n
- foreach tbl [$db eval {SELECT name FROM sqlite_master WHERE type='table'}] {
- append txt [$db eval "SELECT * FROM $tbl"]\n
- }
- foreach prag {default_synchronous default_cache_size} {
- append txt $prag-[$db eval "PRAGMA $prag"]\n
- }
- set cksum [string length $txt]-[md5 $txt]
- # puts $cksum-[file size test.db]
- return $cksum
-}
-
# This routine attempts to execute the sql in $sql. It triggers an
# interrupt at progressively later and later points during the processing
# and checks to make sure SQLITE_INTERRUPT is returned. Eventually,
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
-# $Id: ioerr.test,v 1.33 2007/10/09 08:29:32 danielk1977 Exp $
+# $Id: ioerr.test,v 1.34 2008/01/16 17:46:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# These tests can't be run on windows because the windows version of
# SQLite holds a mandatory exclusive lock on journal files it has open.
#
-btree_breakpoint
if {$tcl_platform(platform)!="windows"} {
do_ioerr_test ioerr-7 -tclprep {
db close
# to see what happens in the library if a malloc were to really fail
# due to an out-of-memory situation.
#
-# $Id: malloc.test,v 1.53 2007/11/28 22:36:41 drh Exp $
+# $Id: malloc.test,v 1.54 2008/01/16 17:46:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# This block tests that malloc() failures that occur whilst commiting
# a multi-file transaction are handled correctly.
#
+breakpoint
do_malloc_test 9 -sqlprep {
ATTACH 'test2.db' as test2;
CREATE TABLE abc1(a, b, c);
sqlite3_extended_result_codes db2 1
db2 eval {SELECT * FROM sqlite_master}
db2 close
-}
+}
# This block tests malloc() failures that occur within calls to
# sqlite3_create_function().
# Recovery from malloc() failures is automatic. But we keep these
# tests around because you can never have too many test cases.
#
-# $Id: malloc2.test,v 1.9 2007/11/05 15:30:13 danielk1977 Exp $
+# $Id: malloc2.test,v 1.10 2008/01/16 17:46:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
sqlite3_extended_result_codes db 1
-# Generate a checksum based on the contents of the database. If the
-# checksum of two databases is the same, and the integrity-check passes
-# for both, the two databases are identical.
-#
-proc cksum {db} {
- set ret [list]
- ifcapable tempdb {
- set sql {
- SELECT name FROM sqlite_master WHERE type = 'table' UNION
- SELECT name FROM sqlite_temp_master WHERE type = 'table' UNION
- SELECT 'sqlite_master' UNION
- SELECT 'sqlite_temp_master'
- }
- } else {
- set sql {
- SELECT name FROM sqlite_master WHERE type = 'table' UNION
- SELECT 'sqlite_master'
- }
- }
- set tbllist [$db eval $sql]
- set txt {}
- foreach tbl $tbllist {
- append txt [$db eval "SELECT * FROM $tbl"]
- }
- # puts txt=$txt
- return [md5 $txt]
-}
-
proc do_malloc2_test {tn args} {
array set ::mallocopts $args
- set sum [cksum db]
+ set sum [allcksum db]
for {set ::n 1} {true} {incr ::n} {
# Checksum the database.
do_test malloc2-$tn.$::n.5 {
- cksum db
+ allcksum db
} $sum
integrity_check malloc2-$tn.$::n.6
# correctly. The emphasis of these tests are the _prepare(), _step() and
# _finalize() calls.
#
-# $Id: malloc3.test,v 1.18 2007/12/13 21:54:11 drh Exp $
+# $Id: malloc3.test,v 1.19 2008/01/16 17:46:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::run_test_script [list]
proc TEST {id t} {lappend ::run_test_script -test [list $id $t]}
proc PREP {p} {lappend ::run_test_script -prep [string trim $p]}
+proc DEBUG {s} {lappend ::run_test_script -debug $s}
# SQL --
#
set sql {
BEGIN;DELETE FROM abc;
}
-for {set i 1} {$i < 100} {incr i} {
+for {set i 1} {$i < 15} {incr i} {
set a $i
set b "String value $i"
set c [string repeat X $i]
while {$pc*2 < [llength $arglist]} {
# Id of this iteration:
- set iterid "(pc $pc).(iFail $iFail)"
set k [lindex $arglist [expr 2 * $pc]]
+ set iterid "pc=$pc.iFail=$iFail$k"
set v [lindex $arglist [expr 2 * $pc + 1]]
switch -- $k {
-test {
foreach {id script} $v {}
- set testid "malloc3-(test $id).$iterid"
- eval $script
incr pc
}
incr pc
}
+ -debug {
+ eval $v
+ incr pc
+ }
+
default { error "Unknown switch: $k" }
}
}
# This file tests aspects of the malloc failure while parsing
# CREATE TABLE statements in auto_vacuum mode.
#
-# $Id: mallocC.test,v 1.7 2007/10/03 08:46:45 danielk1977 Exp $
+# $Id: mallocC.test,v 1.8 2008/01/16 17:46:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
return
}
-# Generate a checksum based on the contents of the database. If the
-# checksum of two databases is the same, and the integrity-check passes
-# for both, the two databases are identical.
-#
-proc cksum {db} {
- set ret [list]
- ifcapable tempdb {
- set sql {
- SELECT name FROM sqlite_master WHERE type = 'table' UNION
- SELECT name FROM sqlite_temp_master WHERE type = 'table' UNION
- SELECT 'sqlite_master' UNION
- SELECT 'sqlite_temp_master'
- }
- } else {
- set sql {
- SELECT name FROM sqlite_master WHERE type = 'table' UNION
- SELECT 'sqlite_master'
- }
- }
- set tbllist [$db eval $sql]
- set txt {}
- foreach tbl $tbllist {
- append txt [$db eval "SELECT * FROM $tbl"]
- }
- # puts txt=$txt
- return [md5 $txt]
-}
-
proc do_mallocC_test {tn args} {
array set ::mallocopts $args
- set sum [cksum db]
+ #set sum [allcksum db]
for {set ::n 1} {true} {incr ::n} {
# Checksum the database.
#do_test mallocC-$tn.$::n.3 {
- # cksum db
+ # allcksum db
#} $sum
#integrity_check mallocC-$tn.$::n.4
# This file contains common code used by many different malloc tests
# within the test suite.
#
-# $Id: malloc_common.tcl,v 1.9 2007/10/03 08:46:45 danielk1977 Exp $
+# $Id: malloc_common.tcl,v 1.10 2008/01/16 17:46:38 drh Exp $
# If we did not compile with malloc testing enabled, then do nothing.
#
} else {
set start 0
}
+ save_prng_state
foreach ::iRepeat {0 1} {
set ::go 1
#
set zRepeat "transient"
if {$::iRepeat} {set zRepeat "persistent"}
+ restore_prng_state
+ foreach file [glob -nocomplain test.db-mj*] {file delete -force $file}
do_test ${tn}.${zRepeat}.${::n} {
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
-# $Id: tester.tcl,v 1.99 2008/01/16 08:24:46 danielk1977 Exp $
+# $Id: tester.tcl,v 1.100 2008/01/16 17:46:38 drh Exp $
set tcl_precision 15
array set ::ioerropts $args
set ::go 1
+ #reset_prng_state
+ save_prng_state
for {set n $::ioerropts(-start)} {$::go} {incr n} {
set ::TN $n
incr ::ioerropts(-count) -1
if {[info exists ::ioerropts(-exclude)]} {
if {[lsearch $::ioerropts(-exclude) $n]!=-1} continue
}
+ restore_prng_state
# Delete the files test.db and test2.db, then execute the TCL and
# SQL (in that order) to prepare for the test case.
if {$::ioerropts(-cksum)} {
set checksum [cksum]
}
-
+
# Set the Nth IO error to fail.
do_test $testname.$n.2 [subst {
set ::sqlite_io_error_persist $::ioerropts(-persist)
return $rc
}
}
- # The test repeats as long as $::go is true.
- set ::go [expr {$::sqlite_io_error_pending<=0}]
+ # The test repeats as long as $::go is non-zero. $::go starts out
+ # as 1. When a test runs to completion without hitting an I/O
+ # error, that means there is no point in continuing with this test
+ # case so set $::go to zero.
+ #
+ if {$::sqlite_io_error_pending>0} {
+ set ::go 0
+ set q 0
+ set ::sqlite_io_error_pending 0
+ } else {
+ set q 1
+ }
+
set s [expr $::sqlite_io_error_hit==0]
set ::sqlite_io_error_hit 0
# 1. We never hit the IO error and the SQL returned OK
# 2. An IO error was hit and the SQL failed
#
- expr { ($s && !$r && !$::go) || (!$s && $r && $::go) }
+ expr { ($s && !$r && !$q) || (!$s && $r && $q) }
} {1}
# If an IO error occured, then the checksum of the database should
unset ::ioerropts
}
-# Return a checksum based on the contents of database 'db'.
+# Return a checksum based on the contents of the main database associated
+# with connection $db
#
proc cksum {{db db}} {
set txt [$db eval {
return $cksum
}
+# Generate a checksum based on the contents of the main and temp tables
+# database $db. If the checksum of two databases is the same, and the
+# integrity-check passes for both, the two databases are identical.
+#
+proc allcksum {db} {
+ set ret [list]
+ ifcapable tempdb {
+ set sql {
+ SELECT name FROM sqlite_master WHERE type = 'table' UNION
+ SELECT name FROM sqlite_temp_master WHERE type = 'table' UNION
+ SELECT 'sqlite_master' UNION
+ SELECT 'sqlite_temp_master' ORDER BY 1
+ }
+ } else {
+ set sql {
+ SELECT name FROM sqlite_master WHERE type = 'table' UNION
+ SELECT 'sqlite_master' ORDER BY 1
+ }
+ }
+ set tbllist [$db eval $sql]
+ set txt {}
+ foreach tbl $tbllist {
+ append txt [$db eval "SELECT * FROM $tbl"]
+ }
+ foreach prag {default_cache_size} {
+ append txt $prag-[$db eval "PRAGMA $prag"]\n
+ }
+ # puts txt=$txt
+ return [md5 $txt]
+}
+
+
+
# Copy file $from into $to. This is used because some versions of
# TCL for windows (notably the 8.4.1 binary package shipped with the
# current mingw release) have a broken "file copy" command.
# This file implements regression tests for SQLite library. The
# focus of this file is testing the VACUUM statement.
#
-# $Id: vacuum.test,v 1.38 2006/10/04 11:55:50 drh Exp $
+# $Id: vacuum.test,v 1.39 2008/01/16 17:46:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
}
set fcnt 1
-proc cksum {{db db}} {
- set sql "SELECT name, type, sql FROM sqlite_master ORDER BY name, type"
- set txt [$db eval $sql]\n
- set sql "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
- foreach tbl [$db eval $sql] {
- append txt [$db eval "SELECT * FROM $tbl"]\n
- }
- foreach prag {default_cache_size} {
- append txt $prag-[$db eval "PRAGMA $prag"]\n
- }
- if 0 {
- global fcnt
- set fd [open dump$fcnt.txt w]
- puts -nonewline $fd $txt
- close $fd
- incr fcnt
- }
- set cksum [string length $txt]-[md5 $txt]
- # puts $cksum-[file size test.db]
- return $cksum
-}
do_test vacuum-1.1 {
execsql {
BEGIN;
DROP TABLE t2;
}
set ::size1 [file size test.db]
- set ::cksum [cksum]
+ set ::cksum [allcksum]
expr {$::cksum!=""}
} {1}
do_test vacuum-1.2 {
execsql {
VACUUM;
}
- cksum
+ allcksum
} $cksum
ifcapable vacuum {
do_test vacuum-1.3 {
}
execsql $sql_script
set ::size1 [file size test.db]
- set ::cksum [cksum]
+ set ::cksum [allcksum]
expr {$::cksum!=""}
} {1}
do_test vacuum-1.5 {
execsql {
VACUUM;
}
- cksum
+ allcksum
} $cksum
ifcapable vacuum {
DROP TABLE t4;
DROP TABLE t5;
} db2
- set ::cksum [cksum db2]
+ set ::cksum [allcksum db2]
catchsql {
VACUUM
}
} {0 {}}
do_test vacuum-2.3 {
- cksum
+ allcksum
} $cksum
do_test vacuum-2.4 {
catch {db2 eval {SELECT count(*) FROM sqlite_master}}
- cksum db2
+ allcksum db2
} $cksum
# Make sure the schema cookie is incremented by vacuum.
INSERT INTO autoinc(b) VALUES('there');
DELETE FROM autoinc;
}
- set ::cksum [cksum]
+ set ::cksum [allcksum]
expr {$::cksum!=""}
} {1}
do_test vacuum-9.2 {
execsql {
VACUUM;
}
- cksum
+ allcksum
} $::cksum
do_test vacuum-9.3 {
execsql {
INSERT INTO autoinc(b) VALUES('one');
INSERT INTO autoinc(b) VALUES('two');
}
- set ::cksum [cksum]
+ set ::cksum [allcksum]
expr {$::cksum!=""}
} {1}
do_test vacuum-9.4 {
execsql {
VACUUM;
}
- cksum
+ allcksum
} $::cksum
}
# This file implements regression tests for SQLite library. The
# focus of this file is testing the VACUUM statement.
#
-# $Id: vacuum2.test,v 1.5 2007/12/06 17:41:28 drh Exp $
+# $Id: vacuum2.test,v 1.6 2008/01/16 17:46:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
sqlite3 db2 test.db
set pageSize [db eval {pragma page_size}]
-# Compute a checksum on the content of a database
-#
-proc cksum {{db db}} {
- set sql "SELECT name, type, sql FROM sqlite_master ORDER BY name, type"
- set txt [$db eval $sql]\n
- set sql "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
- foreach tbl [$db eval $sql] {
- append txt [$db eval "SELECT * FROM $tbl"]\n
- }
- foreach prag {default_cache_size} {
- append txt $prag-[$db eval "PRAGMA $prag"]\n
- }
- set cksum [string length $txt]-[md5 $txt]
- return $cksum
-}
-
# We are currently not autovacuuming so the database should be 3 pages
# in size. 1 page for each of sqlite_master, t1, and t2.
#
}
expr {[file size test.db]/$pageSize}
} {3}
-set cksum [cksum]
+set cksum [allcksum]
do_test vacuum2-3.2 {
- cksum db2
+ allcksum db2
} $cksum
# Convert the database to an autovacuumed database.
expr {[file size test.db]/$pageSize}
} {4}
do_test vacuum2-3.4 {
- cksum db2
+ allcksum db2
} $cksum
do_test vacuum2-3.5 {
- cksum
+ allcksum
} $cksum
do_test vacuum2-3.6 {
execsql {PRAGMA integrity_check} db2
expr {[file size test.db]/$pageSize}
} {3}
do_test vacuum2-3.14 {
- cksum db2
+ allcksum db2
} $cksum
do_test vacuum2-3.15 {
- cksum
+ allcksum
} $cksum
do_test vacuum2-3.16 {
execsql {PRAGMA integrity_check} db2