Added SQLITE_TESTCTRL_INITMODE for improved testability.
FossilOrigin-Name: 98e029134dc1300d3ecb48b41b5107ec69ba85db
This commit is contained in:
commit
0699f29a14
22
manifest
22
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\ssome\sduplicated\stest\snames.
|
||||
D 2015-01-29T19:27:31.114
|
||||
C Added\sSQLITE_TESTCTRL_INITMODE\sfor\simproved\stestability.
|
||||
D 2015-01-30T15:52:26.210
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 5407a688f4d77a05c18a8142be8ae5a2829dd610
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -195,7 +195,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
|
||||
F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
|
||||
F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770
|
||||
F src/loadext.c 86bd4e2fccd520b748cba52492ab60c4a770f660
|
||||
F src/main.c 341fcc5601a8ca84389fa32bcf5a857f65af8dd0
|
||||
F src/main.c 81ddebf2feb9cbd8c8ea160cdd979503f645d505
|
||||
F src/malloc.c 740db54387204c9a2eb67c6d98e68b08e9ef4eab
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987
|
||||
@ -230,8 +230,8 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
|
||||
F src/resolve.c f6c46d3434439ab2084618d603e6d6dbeb0d6ada
|
||||
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
|
||||
F src/select.c 1f2087523007c42900ffcbdeaef06a23ad9329fc
|
||||
F src/shell.c efd35900484377d2159189968c3445afefee3e41
|
||||
F src/sqlite.h.in 9dfc99d6533d36d6a549c4f3f01cacc8be956ada
|
||||
F src/shell.c ed7cf7c29fb1a23d47179affc89cb447868fc976
|
||||
F src/sqlite.h.in 6910064681444efb5c467472499b56bb6bcee0f4
|
||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
||||
F src/sqliteInt.h eaf210295b551d4e40e622aec1b2261c0b28f844
|
||||
@ -239,7 +239,7 @@ F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
||||
F src/status.c 81712116e826b0089bb221b018929536b2b5406f
|
||||
F src/table.c e7a09215315a978057fb42c640f890160dbcc45e
|
||||
F src/tclsqlite.c b8014393a96a9781bb635c8b1f52fc9b77a2bfcf
|
||||
F src/test1.c 00a74fbc6604e1bcd240726a9ff8d0cc123374e7
|
||||
F src/test1.c 5dcdade99e77b7b9f7760106c80a83cf50f10e1e
|
||||
F src/test2.c 577961fe48961b2f2e5c8b56ee50c3f459d3359d
|
||||
F src/test3.c 64d2afdd68feac1bb5e2ffb8226c8c639f798622
|
||||
F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e
|
||||
@ -655,6 +655,7 @@ F test/index7.test 917cf1e1c7439bb155abbeabec511b28945e157b
|
||||
F test/indexedby.test b2f22f3e693a53813aa3f50b812eb609ba6df1ec
|
||||
F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d
|
||||
F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
|
||||
F test/initmode.test 38bbaefeb47e034a162856e664a0da3b95e6999b
|
||||
F test/insert.test 38742b5e9601c8f8d76e9b7555f7270288c2d371
|
||||
F test/insert2.test 4f3a04d168c728ed5ec2c88842e772606c7ce435
|
||||
F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30
|
||||
@ -1237,7 +1238,8 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 53429689d4fcf472edbc89cc50b5e69ba3270634
|
||||
R 5b41e9df20f2feb8a0c6b2313c845804
|
||||
U mistachkin
|
||||
Z 0e7b28947abc40f4a90f6b77b2bfb10f
|
||||
P 1797158db2a818134c5cba1578f69ed85948b980 3a6e2afe408d2b0c8166d00def2048568169d87a
|
||||
R 4fa14bf275b60ddd661b9bd3fb0ea0dd
|
||||
T +closed 3a6e2afe408d2b0c8166d00def2048568169d87a
|
||||
U drh
|
||||
Z b68a5e615b7688be627f33067b9af11c
|
||||
|
@ -1 +1 @@
|
||||
1797158db2a818134c5cba1578f69ed85948b980
|
||||
98e029134dc1300d3ecb48b41b5107ec69ba85db
|
12
src/main.c
12
src/main.c
@ -3598,6 +3598,18 @@ int sqlite3_test_control(int op, ...){
|
||||
if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
/* sqlite3_test_control(SQLITE_TESTCTRL_INITMODE, db, busy, iDb, newTnum);
|
||||
**
|
||||
** Set the db->init.busy, db->init.iDb, and db->init.tnum fields.
|
||||
*/
|
||||
case SQLITE_TESTCTRL_INITMODE: {
|
||||
sqlite3 *db = va_arg(ap, sqlite3*);
|
||||
db->init.busy = va_arg(ap,int);
|
||||
db->init.iDb = va_arg(ap,int);
|
||||
db->init.newTnum = va_arg(ap,int);
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
#endif /* SQLITE_OMIT_BUILTIN_TEST */
|
||||
|
13
src/shell.c
13
src/shell.c
@ -3536,6 +3536,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
{ "scratchmalloc", SQLITE_TESTCTRL_SCRATCHMALLOC },
|
||||
{ "byteorder", SQLITE_TESTCTRL_BYTEORDER },
|
||||
{ "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT },
|
||||
{ "initmode", SQLITE_TESTCTRL_INITMODE },
|
||||
};
|
||||
int testctrl = -1;
|
||||
int rc = 0;
|
||||
@ -3628,6 +3629,18 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
break;
|
||||
#endif
|
||||
|
||||
case SQLITE_TESTCTRL_INITMODE:
|
||||
if( nArg==5 ){
|
||||
rc = sqlite3_test_control(testctrl, p->db,
|
||||
integerValue(azArg[2]),
|
||||
integerValue(azArg[3]),
|
||||
integerValue(azArg[4]));
|
||||
}else{
|
||||
fprintf(stderr,"Usage: .testctrl initmode fBusy iDb newTnum\n");
|
||||
rc = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case SQLITE_TESTCTRL_BITVEC_TEST:
|
||||
case SQLITE_TESTCTRL_FAULT_INSTALL:
|
||||
case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS:
|
||||
|
@ -6260,7 +6260,8 @@ int sqlite3_test_control(int op, ...);
|
||||
#define SQLITE_TESTCTRL_BYTEORDER 22
|
||||
#define SQLITE_TESTCTRL_ISINIT 23
|
||||
#define SQLITE_TESTCTRL_SORTER_MMAP 24
|
||||
#define SQLITE_TESTCTRL_LAST 24
|
||||
#define SQLITE_TESTCTRL_INITMODE 25
|
||||
#define SQLITE_TESTCTRL_LAST 25
|
||||
|
||||
/*
|
||||
** CAPI3REF: SQLite Runtime Status
|
||||
|
18
src/test1.c
18
src/test1.c
@ -5914,7 +5914,8 @@ static int test_test_control(
|
||||
int i;
|
||||
} aVerb[] = {
|
||||
{ "SQLITE_TESTCTRL_LOCALTIME_FAULT", SQLITE_TESTCTRL_LOCALTIME_FAULT },
|
||||
{ "SQLITE_TESTCTRL_SORTER_MMAP", SQLITE_TESTCTRL_SORTER_MMAP },
|
||||
{ "SQLITE_TESTCTRL_SORTER_MMAP", SQLITE_TESTCTRL_SORTER_MMAP },
|
||||
{ "SQLITE_TESTCTRL_INITMODE", SQLITE_TESTCTRL_INITMODE },
|
||||
};
|
||||
int iVerb;
|
||||
int iFlag;
|
||||
@ -5955,6 +5956,21 @@ static int test_test_control(
|
||||
sqlite3_test_control(SQLITE_TESTCTRL_SORTER_MMAP, db, val);
|
||||
break;
|
||||
}
|
||||
|
||||
case SQLITE_TESTCTRL_INITMODE: {
|
||||
int fBusy, iDb, newTnum;
|
||||
sqlite3 *db;
|
||||
if( objc!=6 ){
|
||||
Tcl_WrongNumArgs(interp, 2, objv, "DB fBusy iDb newTnum");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( getDbPointer(interp, Tcl_GetString(objv[2]), &db) ) return TCL_ERROR;
|
||||
if( Tcl_GetIntFromObj(interp, objv[3], &fBusy) ) return TCL_ERROR;
|
||||
if( Tcl_GetIntFromObj(interp, objv[4], &iDb) ) return TCL_ERROR;
|
||||
if( Tcl_GetIntFromObj(interp, objv[5], &newTnum) ) return TCL_ERROR;
|
||||
sqlite3_test_control(SQLITE_TESTCTRL_INITMODE, db, fBusy, iDb, newTnum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Tcl_ResetResult(interp);
|
||||
|
100
test/initmode.test
Normal file
100
test/initmode.test
Normal file
@ -0,0 +1,100 @@
|
||||
# 2015-01-30
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file implements tests for SQLite library.
|
||||
#
|
||||
# The focus of this file is adding extra entries in the symbol table
|
||||
# using sqlite3_test_control(SQLITE_TESTCTRL_INITMODE) and verifying that
|
||||
# SQLite handles those as expected.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix initmode
|
||||
|
||||
# Create a bunch of data to sort against
|
||||
#
|
||||
do_test initmode-1.0 {
|
||||
execsql {
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d NOT NULL);
|
||||
CREATE INDEX t1b ON t1(b);
|
||||
CREATE UNIQUE INDEX t1c ON t1(c);
|
||||
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)
|
||||
INSERT INTO t1(a,b,c,d) SELECT i,1000+i,2000+i,3000+i FROM c;
|
||||
}
|
||||
set t1_root [db one {SELECT rootpage FROM sqlite_master WHERE name='t1'}]
|
||||
set t1a_root [db one {SELECT rootpage FROM sqlite_master WHERE name='t1a'}]
|
||||
set t1b_root [db one {SELECT rootpage FROM sqlite_master WHERE name='t1b'}]
|
||||
|
||||
# Create a shadow table that uses the same b-tree as t1 but which does
|
||||
# not have the indexes
|
||||
#
|
||||
sqlite3_test_control SQLITE_TESTCTRL_INITMODE db 1 0 $t1_root
|
||||
db eval {CREATE TABLE xt1(a,b,c,d)}
|
||||
sqlite3_test_control SQLITE_TESTCTRL_INITMODE db 0 0 0
|
||||
|
||||
# Create triggers to record changes to xt1.
|
||||
#
|
||||
db eval {
|
||||
CREATE TEMP TABLE chnglog(desc TEXT);
|
||||
CREATE TEMP TRIGGER xt1_del AFTER DELETE ON xt1 BEGIN
|
||||
INSERT INTO chnglog VALUES(
|
||||
printf('DELETE t1: rowid=%d, a=%s, b=%s, c=%s, d=%s',
|
||||
old.rowid, quote(old.a), quote(old.b), quote(old.c),
|
||||
quote(old.d)));
|
||||
END;
|
||||
CREATE TEMP TRIGGER xt1_ins AFTER INSERT ON xt1 BEGIN
|
||||
INSERT INTO chnglog VALUES(
|
||||
printf('INSERT t1: rowid=%d, a=%s, b=%s, c=%s, d=%s',
|
||||
new.rowid, quote(new.a), quote(new.b), quote(new.c),
|
||||
quote(new.d)));
|
||||
END;
|
||||
}
|
||||
} {}
|
||||
|
||||
# The xt1 table has separate xt1.rowid and xt1.a columns. The xt1.rowid
|
||||
# column corresponds to t1.rowid and t1.a, but the xt1.a column is always
|
||||
# NULL
|
||||
#
|
||||
do_execsql_test initmode-1.1 {
|
||||
SELECT rowid FROM xt1 WHERE a IS NOT NULL;
|
||||
} {}
|
||||
do_execsql_test initmode-1.2 {
|
||||
SELECT a,b,c,d FROM t1 EXCEPT SELECT rowid,b,c,d FROM xt1;
|
||||
SELECT rowid,b,c,d FROM xt1 EXCEPT SELECT a,b,c,d FROM t1;
|
||||
} {}
|
||||
|
||||
|
||||
# Make changes via the xt1 shadow table. This will not update the
|
||||
# indexes on t1 nor check the uniqueness constraint on t1.c nor check
|
||||
# the NOT NULL constraint on t1.d, resulting in a logically inconsistent
|
||||
# database.
|
||||
#
|
||||
do_execsql_test initmode-1.3 {
|
||||
DELETE FROM xt1 WHERE rowid=5;
|
||||
INSERT INTO xt1(rowid,a,b,c,d) VALUES(99,'hello',1099,2022,NULL);
|
||||
SELECT * FROM chnglog ORDER BY rowid;
|
||||
} [list \
|
||||
{DELETE t1: rowid=5, a=NULL, b=1005, c=2005, d=3005} \
|
||||
{INSERT t1: rowid=99, a='hello', b=1099, c=2022, d=NULL} \
|
||||
]
|
||||
|
||||
do_execsql_test initmode-1.4a {
|
||||
PRAGMA integrity_check;
|
||||
} {/NULL value in t1.d/}
|
||||
do_execsql_test initmode-1.4b {
|
||||
PRAGMA integrity_check;
|
||||
} {/row # missing from index t1b/}
|
||||
do_execsql_test initmode-1.4c {
|
||||
PRAGMA integrity_check;
|
||||
} {/row # missing from index t1c/}
|
||||
|
||||
finish_test
|
Loading…
Reference in New Issue
Block a user