Index: ext/expert/sqlite3expert.c ================================================================== --- ext/expert/sqlite3expert.c +++ ext/expert/sqlite3expert.c @@ -642,10 +642,11 @@ 0, /* xFindFunction - function overloading */ 0, /* xRename - rename the table */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ + 0, /* xShadowName */ }; return sqlite3_create_module(p->dbv, "expert", &expertModule, (void*)p); } /* Index: ext/fts3/fts3.c ================================================================== --- ext/fts3/fts3.c +++ ext/fts3/fts3.c @@ -3843,13 +3843,28 @@ assert( p->mxSavepoint >= iSavepoint ); TESTONLY( p->mxSavepoint = iSavepoint ); sqlite3Fts3PendingTermsClear(p); return SQLITE_OK; } + +/* +** Return true if zName is the extension on one of the shadow tables used +** by this module. +*/ +static int fts3ShadowName(const char *zName){ + static const char *azName[] = { + "content", "docsize", "segdir", "segments", "stat", + }; + unsigned int i; + for(i=0; i=0} {incr i -1} { do_execsql_test 2.$i.1 { BEGIN; UPDATE t1_data SET block = substr(block, 1, $i) WHERE rowid=$lrowid; } @@ -246,10 +247,11 @@ } } #-------------------------------------------------------------------- reset_db +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 6.1 { CREATE VIRTUAL TABLE x5 USING fts5(tt); INSERT INTO x5 VALUES('a'); INSERT INTO x5 VALUES('a a'); INSERT INTO x5 VALUES('a a a'); Index: ext/fts5/test/fts5corrupt3.test ================================================================== --- ext/fts5/test/fts5corrupt3.test +++ ext/fts5/test/fts5corrupt3.test @@ -49,10 +49,11 @@ }] set L [db one {SELECT length(block) FROM t1_data WHERE rowid = $rowid}] set {} {} } {} +sqlite3_db_config db DEFENSIVE 0 for {set i 0} {$i < $L} {incr i} { do_test 1.2.$i { catchsql { BEGIN; UPDATE t1_data SET block = substr(block, 1, $i) WHERE id = $rowid; @@ -84,10 +85,11 @@ #------------------------------------------------------------------------- # Test that missing leaf pages are recognized as corruption. # reset_db do_test 3.0 { create_t1 } {} +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 3.1 { SELECT count(*) FROM t1_data; } {105} @@ -156,10 +158,11 @@ #------------------------------------------------------------------------- # Test that segments that end unexpectedly are identified as corruption. # reset_db +sqlite3_db_config db DEFENSIVE 0 do_test 4.0 { execsql { CREATE VIRTUAL TABLE t1 USING fts5(x); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); } @@ -180,10 +183,11 @@ lset var end [expr $end - $i] set struct [binary format c* $var] db close sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 db eval { BEGIN; UPDATE t1_data SET block = $struct WHERE id=10; } @@ -255,10 +259,11 @@ } #------------------------------------------------------------------------ # reset_db +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 6.1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a); INSERT INTO t1 VALUES('bbbbb ccccc'); SELECT quote(block) FROM t1_data WHERE rowid>100; } {X'000000180630626262626201020201056363636363010203040A'} @@ -271,10 +276,11 @@ INSERT INTO t1(t1) VALUES('integrity-check'); } {1 {database disk image is malformed}} #------- reset_db +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 6.2.0 { CREATE VIRTUAL TABLE t1 USING fts5(a); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); INSERT INTO t1 VALUES('aa bb cc dd ee'); SELECT pgno, quote(term) FROM t1_idx; @@ -286,10 +292,11 @@ INSERT INTO t1(t1) VALUES('integrity-check'); } {1 {database disk image is malformed}} #------- reset_db +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 6.3.0 { CREATE VIRTUAL TABLE t1 USING fts5(a); INSERT INTO t1 VALUES('abc abcdef abcdefghi'); SELECT quote(block) FROM t1_data WHERE id>100; } {X'0000001C043061626301020204036465660102030703676869010204040808'} @@ -360,10 +367,11 @@ INSERT INTO t5 VALUES( rnddoc(10000) ); INSERT INTO t5(t5) VALUES('optimize'); } } {} +sqlite3_db_config db DEFENSIVE 0 do_test 7.1 { foreach i [db eval { SELECT rowid FROM t5_data WHERE rowid>100 }] { db eval BEGIN db eval {DELETE FROM t5_data WHERE rowid = $i} set r [catchsql { INSERT INTO t5(t5) VALUES('integrity-check')} ] @@ -381,10 +389,11 @@ do_execsql_test 8.1 { CREATE VIRTUAL TABLE t1 USING fts5(x, y); INSERT INTO t1 VALUES('one', 'two'); } +sqlite3_db_config db DEFENSIVE 0 do_test 9.1.1 { set blob "12345678" ;# cookie append blob "0105" ;# 1 level, total of 5 segments append blob "06" ;# write counter append blob "0002" ;# first level has 0 segments merging, 2 other. Index: ext/fts5/test/fts5first.test ================================================================== --- ext/fts5/test/fts5first.test +++ ext/fts5/test/fts5first.test @@ -91,6 +91,5 @@ do_catchsql_test 3.3 { SELECT * FROM x2('^a'); } {1 {fts5: phrase queries are not supported (detail!=full)}} finish_test - Index: ext/fts5/test/fts5integrity.test ================================================================== --- ext/fts5/test/fts5integrity.test +++ ext/fts5/test/fts5integrity.test @@ -69,10 +69,11 @@ } {1 1 1 1 1} do_execsql_test 4.1 { INSERT INTO aa(aa) VALUES('integrity-check'); } +sqlite3_db_config db DEFENSIVE 0 do_catchsql_test 4.2 { BEGIN; UPDATE aa_docsize SET sz = X'44' WHERE rowid = 3; INSERT INTO aa(aa) VALUES('integrity-check'); } {1 {database disk image is malformed}} Index: ext/fts5/test/fts5rank.test ================================================================== --- ext/fts5/test/fts5rank.test +++ ext/fts5/test/fts5rank.test @@ -161,6 +161,5 @@ do_execsql_test 5.1 { SELECT rowid FROM ttt('word') WHERE rowid BETWEEN 30 AND 40 ORDER BY rank; } {30 31 32 33 34 35 36 37 38 39 40} finish_test - Index: ext/fts5/test/fts5rebuild.test ================================================================== --- ext/fts5/test/fts5rebuild.test +++ ext/fts5/test/fts5rebuild.test @@ -37,10 +37,11 @@ do_execsql_test 1.4 { INSERT INTO f1(f1) VALUES('integrity-check'); } {} +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 1.5 { DELETE FROM f1_data; } {} do_catchsql_test 1.6 { Index: ext/fts5/test/fts5rowid.test ================================================================== --- ext/fts5/test/fts5rowid.test +++ ext/fts5/test/fts5rowid.test @@ -68,10 +68,11 @@ set res [db one {SELECT count(*) FROM x1_data}] do_execsql_test 2.3 { SELECT count(fts5_decode(rowid, block)) FROM x1_data; } $res +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 2.4 { UPDATE x1_data SET block = X''; SELECT count(fts5_decode(rowid, block)) FROM x1_data; } $res Index: ext/fts5/test/fts5version.test ================================================================== --- ext/fts5/test/fts5version.test +++ ext/fts5/test/fts5version.test @@ -34,13 +34,14 @@ do_execsql_test 1.3 { SELECT rowid FROM t1 WHERE t1 MATCH 'a'; } {1} +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 1.4 { UPDATE t1_config set v=5 WHERE k='version'; -} +} do_test 1.5 { db close sqlite3 db test.db catchsql { SELECT * FROM t1 WHERE t1 MATCH 'a' } @@ -51,13 +52,14 @@ sqlite3 db test.db catchsql { INSERT INTO t1 VALUES('x y z') } } {1 {invalid fts5 file format (found 5, expected 4) - run 'rebuild'}} do_test 1.7 { + sqlite3_db_config db DEFENSIVE 0 execsql { DELETE FROM t1_config WHERE k='version' } db close sqlite3 db test.db catchsql { SELECT * FROM t1 WHERE t1 MATCH 'a' } } {1 {invalid fts5 file format (found 0, expected 4) - run 'rebuild'}} finish_test Index: ext/fts5/test/fts5vocab.test ================================================================== --- ext/fts5/test/fts5vocab.test +++ ext/fts5/test/fts5vocab.test @@ -418,10 +418,11 @@ if {[detail_is_none]} { set resc [row_to_col $resr] } do_execsql_test 8.1.1 { SELECT * FROM x1_r; } $resr do_execsql_test 8.1.2 { SELECT * FROM x1_c } $resc +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 8.2 { PRAGMA writable_schema = 1; UPDATE sqlite_master SET sql = 'CREATE VIRTUAL TABLE x1 USING fts5(a, detail=%DETAIL%)' WHERE name = 'x1'; @@ -479,6 +480,5 @@ } 0 finish_test - Index: ext/fts5/test/fts5vocab2.test ================================================================== --- ext/fts5/test/fts5vocab2.test +++ ext/fts5/test/fts5vocab2.test @@ -204,6 +204,5 @@ SELECT * FROM v1; } { } finish_test - Index: ext/misc/amatch.c ================================================================== --- ext/misc/amatch.c +++ ext/misc/amatch.c @@ -1471,11 +1471,12 @@ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ - 0 /* xRollbackTo */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ /* Index: ext/misc/btreeinfo.c ================================================================== --- ext/misc/btreeinfo.c +++ ext/misc/btreeinfo.c @@ -409,10 +409,11 @@ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ + 0 /* xShadowName */ }; return sqlite3_create_module(db, "sqlite_btreeinfo", &binfo_module, 0); } #ifdef _WIN32 Index: ext/misc/closure.c ================================================================== --- ext/misc/closure.c +++ ext/misc/closure.c @@ -936,11 +936,12 @@ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ - 0 /* xRollbackTo */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ /* Index: ext/misc/completion.c ================================================================== --- ext/misc/completion.c +++ ext/misc/completion.c @@ -466,11 +466,12 @@ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ - 0 /* xRollbackTo */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ int sqlite3CompletionVtabInit(sqlite3 *db){ Index: ext/misc/explain.c ================================================================== --- ext/misc/explain.c +++ ext/misc/explain.c @@ -278,10 +278,11 @@ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ + 0, /* xShadowName */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ int sqlite3ExplainVtabInit(sqlite3 *db){ Index: ext/misc/fileio.c ================================================================== --- ext/misc/fileio.c +++ ext/misc/fileio.c @@ -886,11 +886,12 @@ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ - 0 /* xRollbackTo */ + 0, /* xRollbackTo */ + 0, /* xShadowName */ }; int rc = sqlite3_create_module(db, "fsdir", &fsdirModule, 0); return rc; } Index: ext/misc/json1.c ================================================================== --- ext/misc/json1.c +++ ext/misc/json1.c @@ -2386,11 +2386,12 @@ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ - 0 /* xRollbackTo */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ }; /* The methods of the json_tree virtual table. */ static sqlite3_module jsonTreeModule = { 0, /* iVersion */ @@ -2413,11 +2414,12 @@ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ - 0 /* xRollbackTo */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ /**************************************************************************** ** The following routines are the only publically visible identifiers in this Index: ext/misc/memstat.c ================================================================== --- ext/misc/memstat.c +++ ext/misc/memstat.c @@ -393,10 +393,11 @@ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ + 0, /* xShadowName */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ int sqlite3MemstatVtabInit(sqlite3 *db){ Index: ext/misc/stmt.c ================================================================== --- ext/misc/stmt.c +++ ext/misc/stmt.c @@ -264,10 +264,11 @@ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ + 0, /* xShadowName */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ int sqlite3StmtVtabInit(sqlite3 *db){ Index: ext/misc/templatevtab.c ================================================================== --- ext/misc/templatevtab.c +++ ext/misc/templatevtab.c @@ -246,11 +246,12 @@ /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, - /* xRollbackTo */ 0 + /* xRollbackTo */ 0, + /* xShadowName */ 0 }; #ifdef _WIN32 __declspec(dllexport) Index: ext/misc/unionvtab.c ================================================================== --- ext/misc/unionvtab.c +++ ext/misc/unionvtab.c @@ -1348,11 +1348,12 @@ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ - 0 /* xRollbackTo */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ }; int rc; rc = sqlite3_create_module(db, "unionvtab", &unionModule, 0); if( rc==SQLITE_OK ){ Index: ext/misc/vtablog.c ================================================================== --- ext/misc/vtablog.c +++ ext/misc/vtablog.c @@ -490,10 +490,11 @@ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ + 0, /* xShadowName */ }; #ifdef _WIN32 __declspec(dllexport) #endif Index: ext/rbu/rbu1.test ================================================================== --- ext/rbu/rbu1.test +++ ext/rbu/rbu1.test @@ -668,6 +668,5 @@ eval $destroy_vfs } finish_test - Index: ext/rbu/rbu10.test ================================================================== --- ext/rbu/rbu10.test +++ ext/rbu/rbu10.test @@ -183,6 +183,5 @@ list [catch { apply_rbu $rbu } msg] $msg } {0 SQLITE_DONE} finish_test - Index: ext/rbu/rbu11.test ================================================================== --- ext/rbu/rbu11.test +++ ext/rbu/rbu11.test @@ -193,6 +193,5 @@ do_test 4.7.2 { list [catch {rbu close} msg] $msg } {1 {SQLITE_ERROR - rbu_state mismatch error}} finish_test - Index: ext/rbu/rbu12.test ================================================================== --- ext/rbu/rbu12.test +++ ext/rbu/rbu12.test @@ -230,6 +230,5 @@ } [list $V1 $V2] } finish_test - Index: ext/rbu/rbu13.test ================================================================== --- ext/rbu/rbu13.test +++ ext/rbu/rbu13.test @@ -60,6 +60,5 @@ a == ( (b<<6) + (c<<5) + (d<<4) + (e<<3) + (f<<2) + (g<<1) + (h<<0) ) } {128} finish_test - Index: ext/rbu/rbu14.test ================================================================== --- ext/rbu/rbu14.test +++ ext/rbu/rbu14.test @@ -90,6 +90,5 @@ integrity_check $tn.4 } finish_test - Index: ext/rbu/rbu3.test ================================================================== --- ext/rbu/rbu3.test +++ ext/rbu/rbu3.test @@ -201,7 +201,5 @@ } 1 do_test 6.1 { sqlite3rbu_internal_test } {} finish_test - - Index: ext/rbu/rbu5.test ================================================================== --- ext/rbu/rbu5.test +++ ext/rbu/rbu5.test @@ -298,9 +298,5 @@ } } finish_test - - - - Index: ext/rbu/rbu6.test ================================================================== --- ext/rbu/rbu6.test +++ ext/rbu/rbu6.test @@ -98,6 +98,5 @@ } {1 t1 5 hello} } finish_test - Index: ext/rbu/rbu7.test ================================================================== --- ext/rbu/rbu7.test +++ ext/rbu/rbu7.test @@ -104,7 +104,5 @@ 3 2 f } } finish_test - - Index: ext/rbu/rbu8.test ================================================================== --- ext/rbu/rbu8.test +++ ext/rbu/rbu8.test @@ -70,6 +70,5 @@ } integrity_check 1.3.3 finish_test - Index: ext/rbu/rbu9.test ================================================================== --- ext/rbu/rbu9.test +++ ext/rbu/rbu9.test @@ -123,6 +123,5 @@ integrity_check 2.$tn.4 } finish_test - Index: ext/rbu/rbuA.test ================================================================== --- ext/rbu/rbuA.test +++ ext/rbu/rbuA.test @@ -78,6 +78,5 @@ list [catch { rbu close } msg] $msg } {1 {SQLITE_ERROR - cannot update wal mode database}} finish_test - Index: ext/rbu/rbuB.test ================================================================== --- ext/rbu/rbuB.test +++ ext/rbu/rbuB.test @@ -57,6 +57,5 @@ db close sqlite3_shutdown test_sqlite3_log sqlite3_initialize finish_test - Index: ext/rbu/rbuC.test ================================================================== --- ext/rbu/rbuC.test +++ ext/rbu/rbuC.test @@ -137,6 +137,5 @@ } finish_test - Index: ext/rbu/rbucollate.test ================================================================== --- ext/rbu/rbucollate.test +++ ext/rbu/rbucollate.test @@ -58,6 +58,5 @@ db eval { SELECT * FROM t1 } } {a one 1 b two 2 c three 3} #forcedelete testrbu.db finish_test - Index: ext/rbu/rbucrash.test ================================================================== --- ext/rbu/rbucrash.test +++ ext/rbu/rbucrash.test @@ -143,6 +143,5 @@ do_rbu_crash_test 2.pre=$nPre.step=$is $nPre $is } } finish_test - Index: ext/rbu/rbucrash2.test ================================================================== --- ext/rbu/rbucrash2.test +++ ext/rbu/rbucrash2.test @@ -101,6 +101,5 @@ rbu close } } finish_test - Index: ext/rbu/rbudiff.test ================================================================== --- ext/rbu/rbudiff.test +++ ext/rbu/rbudiff.test @@ -298,6 +298,5 @@ } } finish_test - Index: ext/rbu/rbudor.test ================================================================== --- ext/rbu/rbudor.test +++ ext/rbu/rbudor.test @@ -54,6 +54,5 @@ do_execsql_test 1.4 { SELECT * FROM t1 } [list 1 $bigA 2 $bigB] finish_test - Index: ext/rbu/rbufault.test ================================================================== --- ext/rbu/rbufault.test +++ ext/rbu/rbufault.test @@ -232,6 +232,5 @@ } } } finish_test - Index: ext/rbu/rbufault2.test ================================================================== --- ext/rbu/rbufault2.test +++ ext/rbu/rbufault2.test @@ -53,6 +53,5 @@ finish_test - Index: ext/rbu/rbufault3.test ================================================================== --- ext/rbu/rbufault3.test +++ ext/rbu/rbufault3.test @@ -93,6 +93,5 @@ } } finish_test - Index: ext/rbu/rbufault4.test ================================================================== --- ext/rbu/rbufault4.test +++ ext/rbu/rbufault4.test @@ -61,6 +61,5 @@ } finish_test - Index: ext/rbu/rbufts.test ================================================================== --- ext/rbu/rbufts.test +++ ext/rbu/rbufts.test @@ -129,6 +129,5 @@ } {1 {SQLITE_ERROR - SQL logic error]}} finish_test - Index: ext/rbu/rbumulti.test ================================================================== --- ext/rbu/rbumulti.test +++ ext/rbu/rbumulti.test @@ -170,6 +170,5 @@ } finish_test - Index: ext/rbu/rbuprogress.test ================================================================== --- ext/rbu/rbuprogress.test +++ ext/rbu/rbuprogress.test @@ -414,6 +414,5 @@ } } finish_test - Index: ext/rbu/rburesume.test ================================================================== --- ext/rbu/rburesume.test +++ ext/rbu/rburesume.test @@ -249,6 +249,5 @@ } {60 ok} db2 close } finish_test - Index: ext/rbu/rbusave.test ================================================================== --- ext/rbu/rbusave.test +++ ext/rbu/rbusave.test @@ -100,6 +100,5 @@ SELECT * FROM t1; SELECT * FROM t2; } {1 one 1 3 3 3 4 4 4 1 one 1 3 3 3 4 4 4} finish_test - Index: ext/rbu/rbusplit.test ================================================================== --- ext/rbu/rbusplit.test +++ ext/rbu/rbusplit.test @@ -90,6 +90,5 @@ 9 9 9 } } finish_test - Index: ext/rbu/rbutemplimit.test ================================================================== --- ext/rbu/rbutemplimit.test +++ ext/rbu/rbutemplimit.test @@ -124,6 +124,5 @@ step_rbu_cachesize test.db test.db2 1000 10 1400000 } {1 SQLITE_FULL} do_test 1.6.2 { info commands rbu } {} finish_test - Index: ext/rbu/rbuvacuum.test ================================================================== --- ext/rbu/rbuvacuum.test +++ ext/rbu/rbuvacuum.test @@ -395,6 +395,5 @@ list [catch { rbu close } msg] $msg } {0 SQLITE_DONE} catch { db close } finish_test - Index: ext/rbu/rbuvacuum2.test ================================================================== --- ext/rbu/rbuvacuum2.test +++ ext/rbu/rbuvacuum2.test @@ -230,6 +230,5 @@ rbu close execsql { PRAGMA integrity_check } } {ok} finish_test - Index: ext/repair/test/checkindex01.test ================================================================== --- ext/repair/test/checkindex01.test +++ ext/repair/test/checkindex01.test @@ -345,7 +345,5 @@ {} 1,1 {} 3,3 } do_index_check_test 7.4 t7i4 { {} 1,1 {} 3,3 } - - Index: ext/rtree/geopoly.c ================================================================== --- ext/rtree/geopoly.c +++ ext/rtree/geopoly.c @@ -1723,11 +1723,11 @@ return 0; } static sqlite3_module geopolyModule = { - 2, /* iVersion */ + 3, /* iVersion */ geopolyCreate, /* xCreate - create a table */ geopolyConnect, /* xConnect - connect to an existing table */ geopolyBestIndex, /* xBestIndex - Determine search strategy */ rtreeDisconnect, /* xDisconnect - Disconnect from a table */ rtreeDestroy, /* xDestroy - Drop a table */ @@ -1746,10 +1746,11 @@ geopolyFindFunction, /* xFindFunction - function overloading */ rtreeRename, /* xRename - rename the table */ rtreeSavepoint, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ + rtreeShadowName /* xShadowName */ }; static int sqlite3_geopoly_init(sqlite3 *db){ int rc = SQLITE_OK; static const struct { Index: ext/rtree/rtree.c ================================================================== --- ext/rtree/rtree.c +++ ext/rtree/rtree.c @@ -3323,12 +3323,28 @@ } return rc; } + +/* +** Return true if zName is the extension on one of the shadow tables used +** by this module. +*/ +static int rtreeShadowName(const char *zName){ + static const char *azName[] = { + "node", "parent", "rowid" + }; + unsigned int i; + for(i=0; i0 AND x1<100 AND x2>0 AND x2<100; @@ -256,6 +258,5 @@ sqlite3_extended_errcode db } {SQLITE_CORRUPT_VTAB} finish_test - Index: ext/rtree/rtreecheck.test ================================================================== --- ext/rtree/rtreecheck.test +++ ext/rtree/rtreecheck.test @@ -59,10 +59,11 @@ INSERT INTO r1 VALUES(2, 6, 6, 6, 6); -- 9 INSERT INTO r1 VALUES(3, 7, 7, 7, 7); -- 15 INSERT INTO r1 VALUES(4, 8, 8, 8, 8); -- 21 INSERT INTO r1 VALUES(5, 9, 9, 9, 9); -- 27 " + sqlite3_db_config db DEFENSIVE 0 } setup_simple_db do_execsql_test 2.1 { SELECT rtreecheck('r1') @@ -110,10 +111,11 @@ CREATE VIRTUAL TABLE r2 USING rtree_i32(id, x1, x2); INSERT INTO r2 VALUES(2, -1*(1<<31), -1*(1<<31)+5); SELECT rtreecheck('r2') } {ok} +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 3.2 { BEGIN; UPDATE r2_node SET data = X'123456'; SELECT rtreecheck('r2')!="ok"; } {1} @@ -138,10 +140,11 @@ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<1000 ) INSERT INTO r3 SELECT i, i, i, i, i FROM x; } +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 5.1 { BEGIN; UPDATE r3_node SET data = set_int32(data, 3, 5000); UPDATE r3_node SET data = set_int32(data, 4, 5000); SELECT rtreecheck('r3')=='ok' @@ -153,6 +156,5 @@ UPDATE r3_node SET data = set_int32(data, 4, 0); SELECT rtreecheck('r3')=='ok' } 0 finish_test - Index: ext/session/sessionC.test ================================================================== --- ext/session/sessionC.test +++ ext/session/sessionC.test @@ -193,6 +193,5 @@ } {1 1 3 3} finish_test - Index: ext/session/sessionD.test ================================================================== --- ext/session/sessionD.test +++ ext/session/sessionD.test @@ -253,6 +253,5 @@ do_catchsql_test 4.5.2 { SELECT * FROM ixua.i8; } {1 {no such table: ixua.i8}} finish_test - Index: ext/session/sessionE.test ================================================================== --- ext/session/sessionE.test +++ ext/session/sessionE.test @@ -109,7 +109,5 @@ S delete finish_test - - Index: ext/session/sessionF.test ================================================================== --- ext/session/sessionF.test +++ ext/session/sessionF.test @@ -290,6 +290,5 @@ do_test 3.$tn { set res } [list {*}$result] } finish_test - Index: ext/session/sessionG.test ================================================================== --- ext/session/sessionG.test +++ ext/session/sessionG.test @@ -246,6 +246,5 @@ # db eval { SELECT * FROM t1 } { puts "$a || $b" } finish_test - Index: ext/session/sessionH.test ================================================================== --- ext/session/sessionH.test +++ ext/session/sessionH.test @@ -34,6 +34,5 @@ compare_db db db2 } {} finish_test - Index: ext/session/sessionfault2.test ================================================================== --- ext/session/sessionfault2.test +++ ext/session/sessionfault2.test @@ -280,6 +280,5 @@ faultsim_test_result {0 {}} {1 SQLITE_NOMEM} } finish_test - Index: ext/session/sessionrebase.test ================================================================== --- ext/session/sessionrebase.test +++ ext/session/sessionrebase.test @@ -472,6 +472,5 @@ } $rebasable catch { R delete } } finish_test - Index: ext/session/sessionstat1.test ================================================================== --- ext/session/sessionstat1.test +++ ext/session/sessionstat1.test @@ -306,6 +306,5 @@ sqlite3changeset_apply db2 $C xConflict execsql { SELECT * FROM sqlite_stat1 ORDER BY 1,2 } db2 } {t3 null 3} finish_test - Index: ext/session/sessionwor.test ================================================================== --- ext/session/sessionwor.test +++ ext/session/sessionwor.test @@ -52,6 +52,5 @@ } { {DELETE t1 0 X. {t one t three} {}} } finish_test - Index: src/build.c ================================================================== --- src/build.c +++ src/build.c @@ -1891,10 +1891,36 @@ }else{ pPk->nColumn = pTab->nCol; } recomputeColumnsNotIndexed(pPk); } + +/* +** Return true if zName is a shadow table name in the current database +** connection. +** +** zName is temporarily modified while this routine is running, but is +** restored to its original value prior to this routine returning. +*/ +static int isShadowTableName(sqlite3 *db, char *zName){ + char *zTail; /* Pointer to the last "_" in zName */ + Table *pTab; /* Table that zName is a shadow of */ + Module *pMod; /* Module for the virtual table */ + + zTail = strrchr(zName, '_'); + if( zTail==0 ) return 0; + *zTail = 0; + pTab = sqlite3FindTable(db, zName, 0); + *zTail = '_'; + if( pTab==0 ) return 0; + if( !IsVirtual(pTab) ) return 0; + pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]); + if( pMod==0 ) return 0; + if( pMod->pModule->iVersion<3 ) return 0; + if( pMod->pModule->xShadowName==0 ) return 0; + return pMod->pModule->xShadowName(zTail+1); +} /* ** This routine is called to report the final ")" that terminates ** a CREATE TABLE statement. ** @@ -1930,10 +1956,14 @@ return; } assert( !db->mallocFailed ); p = pParse->pNewTable; if( p==0 ) return; + + if( pSelect==0 && isShadowTableName(db, p->zName) ){ + p->tabFlags |= TF_Shadow; + } /* If the db->init.busy is 1 it means we are reading the SQL off the ** "sqlite_master" or "sqlite_temp_master" table on the disk. ** So do not write to the disk again. Extract the root page number ** for the table from the db->init.newTnum field. (The page number Index: src/dbpage.c ================================================================== --- src/dbpage.c +++ src/dbpage.c @@ -405,10 +405,11 @@ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ + 0 /* xShadowName */ }; return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0); } #elif defined(SQLITE_ENABLE_DBPAGE_VTAB) int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; } Index: src/dbstat.c ================================================================== --- src/dbstat.c +++ src/dbstat.c @@ -718,10 +718,11 @@ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ + 0 /* xShadowName */ }; return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); } #elif defined(SQLITE_ENABLE_DBSTAT_VTAB) int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } Index: src/delete.c ================================================================== --- src/delete.c +++ src/delete.c @@ -41,37 +41,52 @@ if( sqlite3IndexedByLookup(pParse, pItem) ){ pTab = 0; } return pTab; } + +/* Return true if table pTab is read-only. +** +** A table is read-only if any of the following are true: +** +** 1) It is a virtual table and no implementation of the xUpdate method +** has been provided +** +** 2) It is a system table (i.e. sqlite_master), this call is not +** part of a nested parse and writable_schema pragma has not +** been specified +** +** 3) The table is a shadow table, the database connection is in +** defensive mode, and the current sqlite3_prepare() +** is for a top-level SQL statement. +*/ +static int tabIsReadOnly(Parse *pParse, Table *pTab){ + sqlite3 *db; + if( IsVirtual(pTab) ){ + return sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0; + } + if( (pTab->tabFlags & (TF_Readonly|TF_Shadow))==0 ) return 0; + db = pParse->db; + if( (pTab->tabFlags & TF_Readonly)!=0 ){ + return sqlite3WritableSchema(db)==0 && pParse->nested==0; + } + assert( pTab->tabFlags & TF_Shadow ); + return (db->flags & SQLITE_Defensive)!=0 + && db->nVdbeExec==0 + && db->pVtabCtx==0; +} /* ** Check to make sure the given table is writable. If it is not ** writable, generate an error message and return 1. If it is ** writable return 0; */ int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){ - /* A table is not writable under the following circumstances: - ** - ** 1) It is a virtual table and no implementation of the xUpdate method - ** has been provided, or - ** 2) It is a system table (i.e. sqlite_master), this call is not - ** part of a nested parse and writable_schema pragma has not - ** been specified. - ** - ** In either case leave an error message in pParse and return non-zero. - */ - if( ( IsVirtual(pTab) - && sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0 ) - || ( (pTab->tabFlags & TF_Readonly)!=0 - && sqlite3WritableSchema(pParse->db)==0 - && pParse->nested==0) - ){ + if( tabIsReadOnly(pParse, pTab) ){ sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName); return 1; } - #ifndef SQLITE_OMIT_VIEW if( !viewOk && pTab->pSelect ){ sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName); return 1; } Index: src/main.c ================================================================== --- src/main.c +++ src/main.c @@ -3060,10 +3060,13 @@ #if defined(SQLITE_ENABLE_FTS3_TOKENIZER) | SQLITE_Fts3Tokenizer #endif #if defined(SQLITE_ENABLE_QPSG) | SQLITE_EnableQPSG +#endif +#if defined(SQLITE_DEFAULT_DEFENSIVE) + | SQLITE_Defensive #endif ; sqlite3HashInit(&db->aCollSeq); #ifndef SQLITE_OMIT_VIRTUALTABLE sqlite3HashInit(&db->aModule); Index: src/pragma.c ================================================================== --- src/pragma.c +++ src/pragma.c @@ -2475,11 +2475,12 @@ 0, /* xRollback - rollback transaction */ 0, /* xFindFunction - function overloading */ 0, /* xRename - rename the table */ 0, /* xSavepoint */ 0, /* xRelease */ - 0 /* xRollbackTo */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ }; /* ** Check to see if zTabName is really the name of a pragma. If it is, ** then register an eponymous virtual table for that pragma and return Index: src/sqlite.h.in ================================================================== --- src/sqlite.h.in +++ src/sqlite.h.in @@ -2158,31 +2158,20 @@ ** Because resetting a database is destructive and irreversible, the ** process requires the use of this obscure API and multiple steps to help ** ensure that it does not happen by accident. ** **
SQLITE_DBCONFIG_DEFENSIVE
-**
The SQLITE_DBCONFIG_DEFENSIVE option actives or deactivates the +**
The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the ** "defensive" flag for a database connection. When the defensive -** flag is enabled, some obscure features of SQLite are disabled in order -** to reduce the attack surface. Applications that run untrusted SQL -** can activate this flag to reduce the risk of zero-day exploits. -**

-** Features disabled by the defensive flag include: +** flag is enabled, language features that allow ordinary SQL to +** deliberately corrupt the database file are disabled. The disabled +** features include but are not limited to the following: **

    -**
  • The [PRAGMA writable_schema=ON] statement. -**
  • Writes to the [sqlite_dbpage] virtual table. +**
  • The [PRAGMA writable_schema=ON] statement. +**
  • Writes to the [sqlite_dbpage] virtual table. +**
  • Direct writes to shadow tables. **
-** New restrictions may be added in future releases. -**

-** To be clear: It should never be possible for hostile SQL to cause -** arbitrary memory reads, memory leaks, buffer overflows, assertion -** faults, arbitrary code execution, crashes, or other mischief, regardless -** of the value of the defensive flag. Any occurrance of these problems -** is considered a serious bug and will be fixed promptly. It is not -** necessary to enable the defensive flag in order to make SQLite secure -** against attack. The defensive flag merely provides an additional layer -** of defense against unknown vulnerabilities. **

** */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ @@ -6320,10 +6309,13 @@ /* The methods above are in version 1 of the sqlite_module object. Those ** below are for version 2 and greater. */ int (*xSavepoint)(sqlite3_vtab *pVTab, int); int (*xRelease)(sqlite3_vtab *pVTab, int); int (*xRollbackTo)(sqlite3_vtab *pVTab, int); + /* The methods above are in versions 1 and 2 of the sqlite_module object. + ** Those below are for version 3 and greater. */ + int (*xShadowName)(const char*); }; /* ** CAPI3REF: Virtual Table Indexing Information ** KEYWORDS: sqlite3_index_info Index: src/sqliteInt.h ================================================================== --- src/sqliteInt.h +++ src/sqliteInt.h @@ -1999,10 +1999,11 @@ #define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */ #define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */ #define TF_StatsUsed 0x0100 /* Query planner decisions affected by ** Index.aiRowLogEst[] values */ #define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */ +#define TF_Shadow 0x0400 /* True for a shadow table */ /* ** Test to see whether or not a table is a virtual table. This is ** done as a macro so that it will be optimized out when virtual ** table support is omitted from the build. Index: src/vacuum.c ================================================================== --- src/vacuum.c +++ src/vacuum.c @@ -164,11 +164,12 @@ saved_nChange = db->nChange; saved_nTotalChange = db->nTotalChange; saved_mTrace = db->mTrace; db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks; db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum; - db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder | SQLITE_CountRows); + db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder + | SQLITE_Defensive | SQLITE_CountRows); db->mTrace = 0; zDbMain = db->aDb[iDb].zDbSName; pMain = db->aDb[iDb].pBt; isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain)); Index: test/alter2.test ================================================================== --- test/alter2.test +++ test/alter2.test @@ -62,10 +62,11 @@ # proc alter_table {tbl sql {file_format 2}} { sqlite3 dbat test.db set s [string map {' ''} $sql] set t [string map {' ''} $tbl] + sqlite3_db_config dbat DEFENSIVE 0 dbat eval [subst { PRAGMA writable_schema = 1; UPDATE sqlite_master SET sql = '$s' WHERE name = '$t' AND type = 'table'; PRAGMA writable_schema = 0; }] @@ -89,10 +90,11 @@ #----------------------------------------------------------------------- # Some basic tests to make sure short rows are handled. # +sqlite3_db_config db DEFENSIVE 0 do_test alter2-1.1 { execsql { CREATE TABLE abc(a, b); INSERT INTO abc VALUES(1, 2); INSERT INTO abc VALUES(3, 4); Index: test/altercol.test ================================================================== --- test/altercol.test +++ test/altercol.test @@ -551,10 +551,11 @@ DROP TRIGGER tr1; CREATE INDEX x1i ON x1(i); SELECT sql FROM sqlite_master WHERE name='x1i'; } {{CREATE INDEX x1i ON x1(i)}} +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 13.1.4 { PRAGMA writable_schema = 1; UPDATE sqlite_master SET sql = 'CREATE INDEX x1i ON x1(j)' WHERE name='x1i'; } {} Index: test/alterlegacy.test ================================================================== --- test/alterlegacy.test +++ test/alterlegacy.test @@ -465,6 +465,5 @@ ALTER TABLE t1 RENAME TO tt1; } finish_test - Index: test/altertab.test ================================================================== --- test/altertab.test +++ test/altertab.test @@ -503,6 +503,5 @@ SELECT sql FROM sqlite_master WHERE name = 'y'; } {{CREATE VIEW y AS SELECT f2 AS f1 FROM x}} finish_test - Index: test/altertab2.test ================================================================== --- test/altertab2.test +++ test/altertab2.test @@ -85,6 +85,5 @@ {CREATE TABLE c3(x, FOREIGN KEY (x) REFERENCES "p3"(a))} } finish_test - Index: test/analyze.test ================================================================== --- test/analyze.test +++ test/analyze.test @@ -348,10 +348,11 @@ # This test corrupts the database file so it must be the last test # in the series. # do_test analyze-5.99 { + sqlite3_db_config db DEFENSIVE 0 execsql { PRAGMA writable_schema=on; UPDATE sqlite_master SET sql='nonsense' WHERE name='sqlite_stat1'; } db close Index: test/autoinc.test ================================================================== --- test/autoinc.test +++ test/autoinc.test @@ -695,10 +695,11 @@ # do_test autoinc-12.1 { db close forcedelete test.db sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 db eval { CREATE TABLE fake_sequence(name TEXT PRIMARY KEY,seq) WITHOUT ROWID; PRAGMA writable_schema=on; UPDATE sqlite_master SET sql=replace(sql,'fake_','sqlite_'), @@ -716,10 +717,11 @@ } {1 {database disk image is malformed}} do_test autoinc-12.2 { db close forcedelete test.db sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 db eval { CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT); INSERT INTO t1(b) VALUES('one'); PRAGMA writable_schema=on; UPDATE sqlite_master SET @@ -742,10 +744,11 @@ } do_test autoinc-12.3 { db close forcedelete test.db sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 db eval { CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT); INSERT INTO t1(b) VALUES('one'); PRAGMA writable_schema=on; UPDATE sqlite_master SET @@ -770,10 +773,11 @@ } set root1 [db one {SELECT rootpage FROM sqlite_master WHERE name='sqlite_sequence'}] set root2 [db one {SELECT rootpage FROM sqlite_master WHERE name='fake'}] + sqlite3_db_config db DEFENSIVE 0 db eval { PRAGMA writable_schema=on; UPDATE sqlite_master SET rootpage=$root2 WHERE name='sqlite_sequence'; UPDATE sqlite_master SET rootpage=$root1 @@ -789,10 +793,11 @@ breakpoint do_test autoinc-12.5 { db close forcedelete test.db sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 db eval { CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT); INSERT INTO t1(b) VALUES('one'); PRAGMA writable_schema=on; UPDATE sqlite_master SET @@ -808,10 +813,11 @@ } {1 {database disk image is malformed}} do_test autoinc-12.6 { db close forcedelete test.db sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 db eval { CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT); INSERT INTO t1(b) VALUES('one'); PRAGMA writable_schema=on; UPDATE sqlite_master SET @@ -829,10 +835,11 @@ } {0 ok} do_test autoinc-12.7 { db close forcedelete test.db sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 db eval { CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT); INSERT INTO t1(b) VALUES('one'); PRAGMA writable_schema=on; UPDATE sqlite_master SET Index: test/bestindex5.test ================================================================== --- test/bestindex5.test +++ test/bestindex5.test @@ -245,6 +245,5 @@ do_execsql_test 3.5 { SELECT rowid, * FROM t4 WHERE rowid!=1 OR x!='245'; } {} finish_test - Index: test/capi3.test ================================================================== --- test/capi3.test +++ test/capi3.test @@ -739,10 +739,11 @@ } db close } {} do_test capi3-8.2 { sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 execsql { PRAGMA writable_schema=ON; INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL); } db close @@ -757,10 +758,11 @@ # Build a 5-field row record. The first field is a string 'table', and # subsequent fields are all NULL. db close forcedelete test.db test.db-journal sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 execsql { CREATE TABLE t1(a); PRAGMA writable_schema=ON; INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL); } Index: test/capi3c.test ================================================================== --- test/capi3c.test +++ test/capi3c.test @@ -684,10 +684,11 @@ } db close } {} do_test capi3c-8.2 { sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 execsql { PRAGMA writable_schema=ON; INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL); } db close @@ -702,10 +703,11 @@ # Build a 5-field row record. The first field is a string 'table', and # subsequent fields are all NULL. db close forcedelete test.db test.db-journal sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 execsql { CREATE TABLE t1(a); PRAGMA writable_schema=ON; INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL); } Index: test/corrupt.test ================================================================== --- test/corrupt.test +++ test/corrupt.test @@ -130,10 +130,11 @@ } {} do_test corrupt-3.2 { set t1_r [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't1i1'}] set t1i1_r [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't1'}] set cookie [expr [execsql {PRAGMA schema_version}] + 1] + sqlite3_db_config db DEFENSIVE 0 execsql " PRAGMA writable_schema = 1; UPDATE sqlite_master SET rootpage = $t1_r WHERE name = 't1'; UPDATE sqlite_master SET rootpage = $t1i1_r WHERE name = 't1i1'; PRAGMA writable_schema = 0; Index: test/corrupt2.test ================================================================== --- test/corrupt2.test +++ test/corrupt2.test @@ -131,10 +131,11 @@ forcedelete corrupt.db forcedelete corrupt.db-journal forcecopy test.db corrupt.db sqlite3 db2 corrupt.db + sqlite3_db_config db2 DEFENSIVE 0 execsql " $::presql CREATE INDEX a1 ON abc(a); CREATE INDEX a2 ON abc(b); PRAGMA writable_schema = 1; @@ -263,10 +264,11 @@ catch {db close} forcedelete corrupt.db forcedelete corrupt.db-journal sqlite3 db corrupt.db + sqlite3_db_config db DEFENSIVE 0 db eval $::presql eval $A(-tclprep) db eval $A(-sqlprep) db close Index: test/corrupt5.test ================================================================== --- test/corrupt5.test +++ test/corrupt5.test @@ -31,10 +31,11 @@ } # Create a database with a freelist containing at least two pages. # do_test corrupt5-1.1 { + sqlite3_db_config db DEFENSIVE 0 execsql { CREATE TABLE t1(a,b,c); CREATE INDEX i1 ON t1(a,b); PRAGMA writable_schema=ON; UPDATE sqlite_master SET name=NULL, sql=NULL WHERE name='i1'; Index: test/corruptI.test ================================================================== --- test/corruptI.test +++ test/corruptI.test @@ -220,10 +220,11 @@ INSERT INTO t1 VALUES('a', 'A'); INSERT INTO t1 VALUES('b', 'A'); INSERT INTO t1 VALUES('c', 'A'); SELECT name FROM sqlite_master; } {t1 sqlite_autoindex_t1_1} +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 7.1 { PRAGMA writable_schema = 1; DELETE FROM sqlite_master WHERE name = 'sqlite_autoindex_t1_1'; } do_test 7.2 { Index: test/corruptK.test ================================================================== --- test/corruptK.test +++ test/corruptK.test @@ -141,11 +141,11 @@ CREATE TABLE t2(a, b, c); CREATE TABLE t3(a, b, c); CREATE TABLE t4(a, b, c); CREATE TABLE t5(a, b, c); } - + sqlite3_db_config db DEFENSIVE 0 do_execsql_test 3.2 { UPDATE sqlite_dbpage SET data = hex2blob(' 000: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. 010: 04 00 01 01 20 40 20 20 00 00 3e d9 00 00 00 06 .... @ ..>..... 020: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................ Index: test/countofview.test ================================================================== --- test/countofview.test +++ test/countofview.test @@ -39,6 +39,5 @@ select c from t2 union all select f from t3 ) } {3} finish_test - Index: test/dbpage.test ================================================================== --- test/dbpage.test +++ test/dbpage.test @@ -19,10 +19,11 @@ ifcapable !vtab||!compound { finish_test return } +sqlite3_db_config db DEFENSIVE 0 do_test 100 { execsql { PRAGMA auto_vacuum=0; PRAGMA page_size=4096; PRAGMA journal_mode=WAL; Index: test/default.test ================================================================== --- test/default.test +++ test/default.test @@ -104,10 +104,11 @@ # in the sqlite_master table, for backwards compatibility. # db close forcedelete test.db sqlite3 db test.db +sqlite3_db_config db DEFENSIVE 0 do_execsql_test default-4.0 { CREATE TABLE t1(a TEXT, b TEXT DEFAULT(99)); PRAGMA writable_schema=ON; UPDATE sqlite_master SET sql='CREATE TABLE t1(a TEXT, b TEXT DEFAULT(:xyz))'; } {} Index: test/e_fts3.test ================================================================== --- test/e_fts3.test +++ test/e_fts3.test @@ -675,10 +675,11 @@ ddl_test 10.1.1 { CREATE VIRTUAL TABLE ta USING fts3 } write_test 10.1.2 ta_content { INSERT INTO ta VALUES('During a summer vacation in 1790') } write_test 10.1.3 ta_content { INSERT INTO ta VALUES('Wordsworth went on a walking tour') } +sqlite3_db_config db DEFENSIVE 0 write_test 10.1.4 ta_content { DELETE FROM ta_content WHERE rowid = 2 } read_test 10.1.5 { SELECT * FROM ta WHERE ta MATCH 'summer' } {{During a summer vacation in 1790}} error_test 10.1.6 { Index: test/e_reindex.test ================================================================== --- test/e_reindex.test +++ test/e_reindex.test @@ -42,10 +42,11 @@ # recreate indices from scratch. # # Test this by corrupting some database indexes, running REINDEX, and # observing that the corruption is gone. # +sqlite3_db_config db DEFENSIVE 0 do_execsql_test e_reindex-1.1 { INSERT INTO t1 VALUES(1, 2); INSERT INTO t1 VALUES(3, 4); INSERT INTO t1 VALUES(5, 6); @@ -55,10 +56,11 @@ DELETE FROM sqlite_master WHERE type = 'index'; } {} db close sqlite3 db test.db +sqlite3_db_config db DEFENSIVE 0 do_execsql_test e_reindex-1.2 { DELETE FROM t1 WHERE a = 3; INSERT INTO t1 VALUES(7, 8); INSERT INTO t1 VALUES(9, 10); PRAGMA writable_schema = 1; Index: test/fts3auto.test ================================================================== --- test/fts3auto.test +++ test/fts3auto.test @@ -132,10 +132,11 @@ } # fts3_zero_long_segments TABLE ?LIMIT? # proc fts3_zero_long_segments {tbl limit} { + sqlite3_db_config db DEFENSIVE 0 execsql " UPDATE ${tbl}_segments SET block = zeroblob(length(block)) WHERE length(block)>$limit " Index: test/fts3corrupt.test ================================================================== --- test/fts3corrupt.test +++ test/fts3corrupt.test @@ -21,10 +21,11 @@ # Test that a doclist with a length field that indicates that the doclist # extends past the end of the node on which it resides is correctly identified # as database corruption. # +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts3; INSERT INTO t1 VALUES('hello'); } {} do_test fts3corrupt-1.1 { Index: test/fts3corrupt2.test ================================================================== --- test/fts3corrupt2.test +++ test/fts3corrupt2.test @@ -47,10 +47,11 @@ "ajfqz aethlgir aclcx aowlyvetby aproqm afjlqtkv anebfy akzrcpfrrvw" "aoledfotm aiwlfm aeejlaej anz abgbvk aktfn aayoh anpywgdvgz" "acvmldguld asdvz aqb aeomsyzyu aggylhprbdz asrfkwz auipybpsn agsnszzfb" } +sqlite3_db_config db DEFENSIVE 0 do_test fts3corrupt2-1.0 { execsql BEGIN execsql { CREATE VIRTUAL TABLE t2 USING FTS3(a, b); } execsql { INSERT INTO t2(t2) VALUES('nodesize=32') } foreach d $data { Index: test/fts3corrupt3.test ================================================================== --- test/fts3corrupt3.test +++ test/fts3corrupt3.test @@ -31,10 +31,11 @@ COMMIT; } do_execsql_test 1.1 { SELECT quote(root) from t1_segdir; } {X'00036F6E6509010200010200010200'} +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 1.2 { UPDATE t1_segdir SET root = X'00036F6E650EFFFFFFFFFFFFFFFFFFFFFFFF0200'; } do_catchsql_test 1.3 { SELECT rowid FROM t1 WHERE t1 MATCH 'one' Index: test/fts3corrupt4.test ================================================================== --- test/fts3corrupt4.test +++ test/fts3corrupt4.test @@ -38,10 +38,11 @@ do_execsql_test 1.1 { SELECT quote(root) FROM ft_segdir; } {X'0005616261636B03010200030266740302020003046E646F6E03030200'} +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 1.2 { UPDATE ft_segdir SET root = blob( '0005616261636B03010200 FFFFFFFF0702 66740302020003046E646F6E03030200' ); } @@ -81,10 +82,11 @@ do_execsql_test 2.2 { SELECT quote(block) FROM ft_segments WHERE blockid=2 } {X'00056162633130031F0200'} db func blob blob +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 2.3.1 { UPDATE ft_segments SET block = blob('00056162633130031F0200 FFFFFFFF07FF55 66740302020003046E646F6E03030200') WHERE blockid=2; } {} @@ -131,10 +133,11 @@ do_execsql_test 3.1 { SELECT quote(root) FROM ft_segdir } {X'0101056162633132040136030132030136'} db func blob blob +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 3.2 { UPDATE ft_segdir SET root = blob('0101056162633132FFFFFFFF070236030132030136'); } @@ -141,7 +144,5 @@ do_catchsql_test 3.1 { SELECT * FROM ft WHERE ft MATCH 'abc20' } {1 {database disk image is malformed}} finish_test - - Index: test/fts3cov.test ================================================================== --- test/fts3cov.test +++ test/fts3cov.test @@ -87,10 +87,11 @@ SELECT substr(hex(root), 1, 2) FROM t1_segdir; } } {03} # Test the "missing entry" case: +sqlite3_db_config db DEFENSIVE 0 do_test fts3cov-2.2 { set root [db one {SELECT root FROM t1_segdir}] read_fts3varint [string range $root 1 end] left_child execsql { DELETE FROM t1_segments WHERE blockid = $left_child } } {} @@ -403,10 +404,11 @@ SELECT rowid FROM t15 WHERE t15 MATCH '"abc* def2"' } {1 2} # Test a corruption case. # +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 16.1 { CREATE VIRTUAL TABLE t16 USING fts4; INSERT INTO t16 VALUES('theoretical work to examine the relationship'); INSERT INTO t16 VALUES('solution of our problems on the invisible'); DELETE FROM t16_content WHERE rowid = 2; Index: test/fts3d.test ================================================================== --- test/fts3d.test +++ test/fts3d.test @@ -294,10 +294,11 @@ SELECT level, idx FROM t1_segdir ORDER BY level, idx; } } {{Index already optimal} 1 0} # Even if we move things around, still does nothing. +sqlite3_db_config db DEFENSIVE 0 do_test fts3d-5.1 { execsql { UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0; SELECT OPTIMIZE(t1) FROM t1 LIMIT 1; SELECT level, idx FROM t1_segdir ORDER BY level, idx; Index: test/fts3defer.test ================================================================== --- test/fts3defer.test +++ test/fts3defer.test @@ -57,10 +57,11 @@ 5 {SELECT rowid FROM t1 WHERE t1 MATCH 'a dog'} {1} } do_select_tests 1.2 $tests +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 1.3 { SELECT count(*) FROM t1_segments WHERE length(block)>10000; UPDATE t1_segments SET block = zeroblob(length(block)) WHERE length(block)>10000; @@ -223,25 +224,28 @@ 3 { set dmt_modes {0 1 2} execsql { CREATE VIRTUAL TABLE t1 USING FTS4 } foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } } add_empty_records 1000 + sqlite3_db_config db DEFENSIVE 0 execsql $zero_long_doclists } 4 { set dmt_modes 0 execsql { CREATE VIRTUAL TABLE t1 USING FTS4 } foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } } add_empty_records 1000 execsql "INSERT INTO t1(t1) VALUES('optimize')" + sqlite3_db_config db DEFENSIVE 0 execsql $zero_long_doclists } 5 { set dmt_modes 0 execsql { CREATE VIRTUAL TABLE t1 USING FTS4(matchinfo=fts3) } foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } } add_empty_records 1000 + sqlite3_db_config db DEFENSIVE 0 execsql $zero_long_doclists } } { execsql { DROP TABLE IF EXISTS t1 } Index: test/fts3defer2.test ================================================================== --- test/fts3defer2.test +++ test/fts3defer2.test @@ -44,10 +44,11 @@ INSERT INTO t1 VALUES(''); INSERT INTO t1 VALUES(''); INSERT INTO t1 VALUES(''); INSERT INTO t1(t1) VALUES('optimize'); } +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 1.1.4 { SELECT count(*) FROM t1_segments WHERE length(block)>10000; UPDATE t1_segments SET block = zeroblob(length(block)) WHERE length(block)>10000; } {2} @@ -96,10 +97,11 @@ 2 { INSERT INTO t2(t2) VALUES('optimize') } 3 { UPDATE t2_segments SET block = zeroblob(length(block)) WHERE length(block)>10000; } } { + sqlite3_db_config db DEFENSIVE 0 execsql $sql do_execsql_test 2.2.$tn.1 { SELECT mit(matchinfo(t2, 'pcxnal')) FROM t2 WHERE t2 MATCH 'a b'; } [list \ @@ -150,13 +152,14 @@ 2 { INSERT INTO t3(t3) VALUES('optimize') } 3 { UPDATE t3_segments SET block = zeroblob(length(block)) WHERE length(block)>10000; } } { + sqlite3_db_config db DEFENSIVE 0 execsql $sql do_execsql_test 2.4.$tn { SELECT docid, mit(matchinfo(t3, 'pcxnal')) FROM t3 WHERE t3 MATCH '"a b c"'; } {1 {1 1 1 4 4 11 912 6} 3 {1 1 1 4 4 11 912 6}} } finish_test Index: test/fts3matchinfo.test ================================================================== --- test/fts3matchinfo.test +++ test/fts3matchinfo.test @@ -276,10 +276,11 @@ do_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1 1} } do_execsql_test 4.4.0.1 { INSERT INTO t5(t5) VALUES('optimize') } ifcapable fts4_deferred { + sqlite3_db_config db DEFENSIVE 0 do_execsql_test 4.4.0.2 { UPDATE t5_segments SET block = zeroblob(length(block)) WHERE length(block)>10000; } @@ -337,10 +338,11 @@ 'this record is used to try to dectect corruption' ); SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to'; } {{0 0 20 2 0 0 27 2}} +sqlite3_db_config db DEFENSIVE 0 do_catchsql_test 6.2 { UPDATE t9_content SET c0content = 'this record is used to'; SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to'; } {1 {database disk image is malformed}} @@ -390,10 +392,11 @@ do_execsql_test 8.3 { SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' } {{204 1 3 3 0} {204 1 3 3 0} {204 1 3 3 0}} # Corruption related tests. +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 8.4.1.1 { UPDATE t11_stat SET value = X'0000'; } do_catchsql_test 8.5.1.2 { SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' } {1 {database disk image is malformed}} Index: test/fts3misc.test ================================================================== --- test/fts3misc.test +++ test/fts3misc.test @@ -158,10 +158,11 @@ SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"' } {8000} do_execsql_test 4.2 { SELECT quote(value) from t4_stat where id=0 } {X'C03EC0B204C0A608'} + sqlite3_db_config db DEFENSIVE 0 do_execsql_test 4.3 { UPDATE t4_stat SET value = X'C03EC0B204C0A60800' WHERE id=0; } do_catchsql_test 4.4 { SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"' Index: test/fts3query.test ================================================================== --- test/fts3query.test +++ test/fts3query.test @@ -165,10 +165,11 @@ 1 "SELECT matchinfo(content) FROM t2 WHERE t2 MATCH 'history'" matchinfo 2 "SELECT offsets(content) FROM t2 WHERE t2 MATCH 'history'" offsets 3 "SELECT snippet(content) FROM t2 WHERE t2 MATCH 'history'" snippet 4 "SELECT optimize(content) FROM t2 WHERE t2 MATCH 'history'" optimize } +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 5.4.0 { UPDATE t2_content SET c0content = X'1234' } do_select_tests 5.4 -errorformat { illegal first argument to %s } { 1 "SELECT matchinfo(content) FROM t2 WHERE t2 MATCH 'history'" matchinfo Index: test/fts3snippet.test ================================================================== --- test/fts3snippet.test +++ test/fts3snippet.test @@ -182,10 +182,11 @@ set off [string first "onehundred " $numbers] do_offsets_test $T.2.2 {onehundred} \ [list 0 0 $off 10 1 0 $off 10] [list 0 0 $off 10] # Test a corruption case: + sqlite3_db_config db DEFENSIVE 0 execsql { UPDATE ft_content SET c1b = 'hello world' WHERE c1b = $numbers } do_error_test $T.2.3 { SELECT offsets(ft) FROM ft WHERE ft MATCH 'onehundred' } {database disk image is malformed} Index: test/fts4check.test ================================================================== --- test/fts4check.test +++ test/fts4check.test @@ -64,10 +64,11 @@ DELETE FROM t1_segdir WHERE level=0 AND idx=( SELECT max(idx) FROM t1_segdir WHERE level=0 ); } } { + sqlite3_db_config db DEFENSIVE 0 do_execsql_test 1.2.1.$tn "BEGIN; $disruption" do_catchsql_test 1.2.2.$tn { INSERT INTO t1 (t1) VALUES('integrity-check') } {1 {database disk image is malformed}} do_execsql_test 1.2.3.$tn "ROLLBACK" @@ -98,10 +99,11 @@ DELETE FROM t2_segdir WHERE level=0 AND idx=( SELECT max(idx) FROM t2_segdir WHERE level=1024 ); } } { + sqlite3_db_config db DEFENSIVE 0 do_execsql_test 2.2.1.$tn "BEGIN; $disruption" do_catchsql_test 2.2.2.$tn { INSERT INTO t2 (t2) VALUES('integrity-check') } {1 {database disk image is malformed}} do_execsql_test 2.2.3.$tn "ROLLBACK" @@ -143,10 +145,11 @@ UPDATE t3_content SET langid=langid+1 WHERE rowid = ( SELECT max(rowid) FROM t3_content ) } } { + sqlite3_db_config db DEFENSIVE 0 do_execsql_test 3.2.1.$tn "BEGIN; $disruption" do_catchsql_test 3.2.2.$tn { INSERT INTO t3 (t3) VALUES('integrity-check') } {1 {database disk image is malformed}} do_execsql_test 3.2.3.$tn "ROLLBACK" @@ -161,10 +164,11 @@ CREATE VIRTUAL TABLE t4 USING fts4(a, b, c, notindexed=b); INSERT INTO t4 VALUES('text one', 'text two', 'text three'); INSERT INTO t4(t4) VALUES('integrity-check'); } +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 4.1 { PRAGMA writable_schema = 1; UPDATE sqlite_master SET sql = 'CREATE VIRTUAL TABLE t4 USING fts4(a, b, c)' WHERE name = 't4'; @@ -195,10 +199,11 @@ do_execsql_test 5.1 { INSERT INTO t5(t5) VALUES('integrity-check'); } {} +sqlite3_db_config db DEFENSIVE 0 do_catchsql_test 5.2 { INSERT INTO t5_content VALUES(5, 'his hardy mountain pony'); INSERT INTO t5(t5) VALUES('integrity-check'); } {1 {database disk image is malformed}} Index: test/fts4growth.test ================================================================== --- test/fts4growth.test +++ test/fts4growth.test @@ -23,10 +23,11 @@ return } source $testdir/genesis.tcl +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 1.1 { CREATE VIRTUAL TABLE x1 USING fts3; } do_test 1.2 { foreach L { {"See here, young man," said Mulga Bill, "from Walgett to the sea,} Index: test/fts4merge.test ================================================================== --- test/fts4merge.test +++ test/fts4merge.test @@ -154,10 +154,11 @@ do_execsql_test 4.4.1 { SELECT quote(value) FROM t4_stat WHERE rowid=1 } {X'0006'} + sqlite3_db_config db DEFENSIVE 0 do_execsql_test 4.4.2 { DELETE FROM t4_stat WHERE rowid=1; INSERT INTO t4(t4) VALUES('merge=1,12'); SELECT level, group_concat(idx, ' ') FROM t4_segdir GROUP BY level; } "0 {0 1 2 3 4 5} 1 0" Index: test/fts4opt.test ================================================================== --- test/fts4opt.test +++ test/fts4opt.test @@ -35,10 +35,11 @@ # %_segdir table so that all segments within each index are on the same # level. This means that the 'merge' command can then be used for an # incremental optimize routine. # proc prepare_for_optimize {db tbl} { + sqlite3_db_config $db DEFENSIVE 0 $db eval [string map [list % $tbl] { BEGIN; CREATE TEMP TABLE tmp_segdir( level, idx, start_block, leaves_end_block, end_block, root ); Index: test/index.test ================================================================== --- test/index.test +++ test/index.test @@ -624,11 +624,10 @@ catchsql { CREATE TABLE sqlite_t1(a, b, c); } } {1 {object name reserved for internal use: sqlite_t1}} do_test index-18.1.2 { - sqlite3_db_config db DEFENSIVE 1 catchsql { CREATE TABLE sqlite_t1(a, b, c); } } {1 {object name reserved for internal use: sqlite_t1}} sqlite3_db_config db DEFENSIVE 0 Index: test/index3.test ================================================================== --- test/index3.test +++ test/index3.test @@ -81,10 +81,11 @@ # This test corrupts the database file so it must be the last test # in the series. # do_test index3-99.1 { + sqlite3_db_config db DEFENSIVE 0 execsql { PRAGMA writable_schema=on; UPDATE sqlite_master SET sql='nonsense' WHERE name='t1d' } db close Index: test/misc1.test ================================================================== --- test/misc1.test +++ test/misc1.test @@ -657,10 +657,11 @@ # 2015-04-19: NULL pointer dereference on a corrupt schema # db close sqlite3 db :memory: +sqlite3_db_config db DEFENSIVE 0 do_execsql_test misc1-23.1 { CREATE TABLE t1(x); PRAGMA writable_schema=ON; UPDATE sqlite_master SET sql='CREATE table t(d CHECK(T(#0)'; BEGIN; @@ -672,10 +673,11 @@ # 2015-04-19: Faulty assert() statement # db close database_may_be_corrupt sqlite3 db :memory: +sqlite3_db_config db DEFENSIVE 0 do_catchsql_test misc1-23.2 { CREATE TABLE t1(x UNIQUE); PRAGMA writable_schema=ON; UPDATE sqlite_master SET sql='CREATE TABLE IF not EXISTS t(c)'; BEGIN; @@ -683,10 +685,11 @@ ROLLBACK; DROP TABLE F; } {1 {no such table: F}} db close sqlite3 db :memory: +sqlite3_db_config db DEFENSIVE 0 do_catchsql_test misc1-23.3 { CREATE TABLE t1(x UNIQUE); PRAGMA writable_schema=ON; UPDATE sqlite_master SET sql='CREATE table y(a TEXT, a TEXT)'; BEGIN; Index: test/misc4.test ================================================================== --- test/misc4.test +++ test/misc4.test @@ -210,10 +210,11 @@ # 2015-05-15. Error message formatting problem. # db close sqlite3 db :memory: +sqlite3_db_config db DEFENSIVE 0 do_catchsql_test misc4-7.1 { CREATE TABLE t7(x); PRAGMA writable_schema=ON; UPDATE sqlite_master SET sql='CREATE TABLE [M%s%s%s%s%s%s%s%s%s%s%s%s%s'; VACUUM; Index: test/misc5.test ================================================================== --- test/misc5.test +++ test/misc5.test @@ -588,10 +588,11 @@ # Parser stack overflow is silently ignored when it occurs while parsing the # schema and PRAGMA writable_schema is turned on. # do_test misc5-7.2 { sqlite3 db2 :memory: + sqlite3_db_config db2 DEFENSIVE 0 catchsql { CREATE TABLE t1(x UNIQUE); PRAGMA writable_schema=ON; UPDATE sqlite_master SET sql='CREATE table t(o CHECK(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((;VALUES(o)'; BEGIN; Index: test/misc7.test ================================================================== --- test/misc7.test +++ test/misc7.test @@ -432,10 +432,11 @@ # sqlite3_test_control_pending_page [expr ($::sqlite_pending_byte / 1024) + 1] set ::pending_byte_page [expr ($::sqlite_pending_byte / 1024) + 1] sqlite3_test_control_pending_byte $::sqlite_pending_byte do_test misc7-17.3 { + sqlite3_db_config db DEFENSIVE 0 db eval { pragma writable_schema = true; UPDATE sqlite_master SET rootpage = $pending_byte_page WHERE type = 'table' AND name = 't3'; Index: test/mjournal.test ================================================================== --- test/mjournal.test +++ test/mjournal.test @@ -158,6 +158,5 @@ INSERT INTO t4 VALUES(1); COMMIT; } {0} finish_test - Index: test/notnull.test ================================================================== --- test/notnull.test +++ test/notnull.test @@ -604,6 +604,5 @@ do_uses_op_next_test notnull-6.9 "SELECT * FROM t8 WHERE a IS ?" 0 do_uses_op_next_test notnull-6.10 "SELECT * FROM t8 WHERE a IS ?" 0 finish_test - Index: test/pager1.test ================================================================== --- test/pager1.test +++ test/pager1.test @@ -1877,10 +1877,11 @@ } } {} do_test pager1-18.2 { set root [db one "SELECT rootpage FROM sqlite_master"] set lockingpage [expr (0x10000/1024) + 1] + sqlite3_db_config db DEFENSIVE 0 execsql { PRAGMA writable_schema = 1; UPDATE sqlite_master SET rootpage = $lockingpage; } sqlite3 db2 test.db @@ -1929,10 +1930,11 @@ catchsql { SELECT length(x||'') FROM t2 } db2 } {1 {database disk image is malformed}} db2 close do_test pager1-18.5 { sqlite3 db "" + sqlite3_db_config db DEFENSIVE 0 execsql { CREATE TABLE t1(a, b); CREATE TABLE t2(a, b); PRAGMA writable_schema = 1; UPDATE sqlite_master SET rootpage=5 WHERE tbl_name = 't1'; Index: test/parser1.test ================================================================== --- test/parser1.test +++ test/parser1.test @@ -26,10 +26,11 @@ # Verify that a legacy schema in the sqlite_master file is allowed to have # COLLATE, ASC, and DESC keywords on the id list of a FK constraint, and that # those keywords are silently ignored. # +sqlite3_db_config db DEFENSIVE 0 do_execsql_test parser1-1.2 { CREATE TABLE t1( a TEXT PRIMARY KEY, b TEXT, FOREIGN KEY(b) REFERENCES t1(a) Index: test/pragma.test ================================================================== --- test/pragma.test +++ test/pragma.test @@ -495,10 +495,11 @@ } # Verify that PRAGMA integrity_check catches UNIQUE and NOT NULL # constraint violations. # +sqlite3_db_config db DEFENSIVE 0 do_execsql_test pragma-3.20 { CREATE TABLE t1(a,b); CREATE INDEX t1a ON t1(a); INSERT INTO t1 VALUES(1,1),(2,2),(3,3),(2,4),(NULL,5),(NULL,6); PRAGMA writable_schema=ON; Index: test/resetdb.test ================================================================== --- test/resetdb.test +++ test/resetdb.test @@ -63,10 +63,11 @@ } {210 6000 ok delete 8} do_test 200 { # Thoroughly corrupt the database file by overwriting the first # page with randomness. + sqlite3_db_config db DEFENSIVE 0 catchsql { UPDATE sqlite_dbpage SET data=randomblob(4096) WHERE pgno=1; PRAGMA quick_check; } } {1 {unsupported file format}} @@ -123,10 +124,11 @@ PRAGMA page_count; } db2 } {210 26000 ok wal 8192 12} # Corrupt the database again +sqlite3_db_config db DEFENSIVE 0 do_catchsql_test 320 { UPDATE sqlite_dbpage SET data=randomblob(8192) WHERE pgno=1; PRAGMA quick_check } {1 {file is not a database}} @@ -226,10 +228,11 @@ if {[nonzero_reserved_bytes]} { finish_test return } +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 710 { UPDATE sqlite_dbpage SET data= X'53514C69746520666F726D61742033000200030100402020000000000000001300000000000000000000000300000004000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000D00000003017C0001D801AC017C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002E03061715110145696E6465787431626374310443524541544520494E4445582074316263204F4E20743128622C63292A0206171311013F696E64657874316174310343524541544520494E44455820743161204F4E20743128612926010617111101397461626C657431743102435245415445205441424C4520743128612C622C6329' WHERE pgno=1; } Index: test/shared8.test ================================================================== --- test/shared8.test +++ test/shared8.test @@ -60,10 +60,11 @@ SELECT * FROM v1; } db1 } {1 i 2 ii 3 iii 4 iv} do_test 1.1 { + sqlite3_db_config db1 DEFENSIVE 0 execsql { PRAGMA writable_schema = 1; DELETE FROM sqlite_master WHERE 1; PRAGMA writable_schema = 0; SELECT * FROM sqlite_master; Index: test/snapshot2.test ================================================================== --- test/snapshot2.test +++ test/snapshot2.test @@ -236,6 +236,5 @@ list [catch { sqlite3_snapshot_open_blob db2 main $snap } msg] $msg } {1 SQLITE_ERROR_SNAPSHOT} finish_test - Index: test/snapshot3.test ================================================================== --- test/snapshot3.test +++ test/snapshot3.test @@ -95,6 +95,5 @@ execsql BEGIN db3 list [catch { sqlite3_snapshot_open_blob db3 main $snap } msg] $msg } {1 SQLITE_ERROR_SNAPSHOT} finish_test - Index: test/snapshot4.test ================================================================== --- test/snapshot4.test +++ test/snapshot4.test @@ -70,6 +70,5 @@ } } {100} finish_test - Index: test/snapshot_up.test ================================================================== --- test/snapshot_up.test +++ test/snapshot_up.test @@ -179,6 +179,5 @@ sqlite3_snapshot_free $::snap1 sqlite3_snapshot_free $::snap2 finish_test - Index: test/swarmvtab3.test ================================================================== --- test/swarmvtab3.test +++ test/swarmvtab3.test @@ -229,6 +229,5 @@ db close forcedelete {*}[glob test.db*] forcedelete {*}[glob test_remote.db*] finish_test - Index: test/swarmvtabfault.test ================================================================== --- test/swarmvtabfault.test +++ test/swarmvtabfault.test @@ -61,6 +61,5 @@ } -test { faultsim_test_result {0 {1 2 9}} {1 {sql error: out of memory}} } finish_test - Index: test/table.test ================================================================== --- test/table.test +++ test/table.test @@ -274,10 +274,11 @@ do_test table-5.2.2 { db close forcedelete test.db sqlite3 db test.db + sqlite3_db_config db DEFENSIVE 0 db eval { CREATE TABLE t0(a,b); CREATE INDEX t ON t0(a); PRAGMA writable_schema=ON; UPDATE sqlite_master SET sql='CREATE TABLE a.b(a UNIQUE'; Index: test/trigger7.test ================================================================== --- test/trigger7.test +++ test/trigger7.test @@ -104,10 +104,11 @@ # This test corrupts the database file so it must be the last test # in the series. # do_test trigger7-99.1 { + sqlite3_db_config db DEFENSIVE 0 execsql { PRAGMA writable_schema=on; UPDATE sqlite_master SET sql='nonsense'; } db close Index: test/triggerE.test ================================================================== --- test/triggerE.test +++ test/triggerE.test @@ -66,10 +66,11 @@ #------------------------------------------------------------------------- # Test that variable references within trigger definitions loaded from # the sqlite_master table are automatically converted to NULL. # +sqlite3_db_config db DEFENSIVE 0 do_execsql_test 2.1 { PRAGMA writable_schema = 1; INSERT INTO sqlite_master VALUES('trigger', 'tr1', 't1', 0, 'CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN INSERT INTO t2 VALUES(?1, ?2); Index: test/unionvtab.test ================================================================== --- test/unionvtab.test +++ test/unionvtab.test @@ -453,6 +453,5 @@ do_execsql_test 5.4 { SELECT * FROM cc WHERE two LIKE '6' } {six 6} finish_test - Index: test/unionvtabfault.test ================================================================== --- test/unionvtabfault.test +++ test/unionvtabfault.test @@ -79,6 +79,5 @@ } finish_test - Index: test/vtab1.test ================================================================== --- test/vtab1.test +++ test/vtab1.test @@ -1251,10 +1251,11 @@ # an error message was set using a call similar to sqlite3_mprintf(zErr), # where zErr is an arbitrary string. This is no good if the string contains # characters that can be mistaken for printf() formatting directives. # do_test vtab1-17.1 { + sqlite3_db_config db DEFENSIVE 0 execsql { PRAGMA writable_schema = 1; INSERT INTO sqlite_master VALUES( 'table', 't3', 't3', 0, 'INSERT INTO "%s%s" VALUES(1)' ); Index: test/wherelimit2.test ================================================================== --- test/wherelimit2.test +++ test/wherelimit2.test @@ -295,6 +295,5 @@ set ::log } {ax a bx b cx c dx d ex a} finish_test - Index: test/window5.test ================================================================== --- test/window5.test +++ test/window5.test @@ -92,6 +92,5 @@ SELECT sum(a) FROM t1; } {21} finish_test - Index: test/windowfault.test ================================================================== --- test/windowfault.test +++ test/windowfault.test @@ -161,6 +161,5 @@ } -test { faultsim_test_result {0 {1 2 5 6 9 10}} } finish_test - Index: test/zipfile2.test ================================================================== --- test/zipfile2.test +++ test/zipfile2.test @@ -239,6 +239,5 @@ UPDATE OR REPLACE zip SET name='test2' WHERE name='test1'; SELECT name FROM zip; } {test2} finish_test - Index: tool/genfkey.test ================================================================== --- tool/genfkey.test +++ tool/genfkey.test @@ -349,6 +349,5 @@ execsql { SELECT * FROM parent; SELECT * FROM child; } } {1 1} -