Skip to content

Commit

Permalink
Add the SQLITE_DEFAULT_DEFENSIVE compile-time option. Fix up test cases
Browse files Browse the repository at this point in the history
so that they work with DEFENSIVE enabled.
  • Loading branch information
D. Richard Hipp committed Nov 7, 2018
1 parent a929f1f commit 84a7f10
Show file tree
Hide file tree
Showing 109 changed files with 42 additions and 102 deletions.
1 change: 0 additions & 1 deletion ext/fts5/test/fts5connect.test
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,3 @@ foreach {tn sql res} {
}

finish_test

1 change: 0 additions & 1 deletion ext/fts5/test/fts5first.test
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,3 @@ do_catchsql_test 3.3 {
SELECT * FROM x2('^a');
} {1 {fts5: phrase queries are not supported (detail!=full)}}
finish_test

1 change: 0 additions & 1 deletion ext/fts5/test/fts5rank.test
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,3 @@ do_execsql_test 5.1 {
} {30 31 32 33 34 35 36 37 38 39 40}

finish_test

1 change: 0 additions & 1 deletion ext/fts5/test/fts5rebuild.test
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ sqlite3_db_config db DEFENSIVE 0
do_execsql_test 1.5 {
DELETE FROM f1_data;
} {}
sqlite3_db_config db DEFENSIVE 1

do_catchsql_test 1.6 {
INSERT INTO f1(f1) VALUES('integrity-check');
Expand Down
1 change: 0 additions & 1 deletion ext/fts5/test/fts5rowid.test
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ do_execsql_test 2.4 {
UPDATE x1_data SET block = X'';
SELECT count(fts5_decode(rowid, block)) FROM x1_data;
} $res
sqlite3_db_config db DEFENSIVE 1

do_execsql_test 2.5 {
INSERT INTO x1(x1, rank) VALUES('pgsz', 1024);
Expand Down
1 change: 0 additions & 1 deletion ext/fts5/test/fts5vocab2.test
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,3 @@ do_execsql_test 3.5 {
}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbu1.test
Original file line number Diff line number Diff line change
Expand Up @@ -670,4 +670,3 @@ foreach {tn3 create_vfs destroy_vfs} {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbu10.test
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,3 @@ do_test 4.3 {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbu11.test
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,3 @@ do_test 4.7.2 {
} {1 {SQLITE_ERROR - rbu_state mismatch error}}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbu12.test
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,3 @@ do_multiclient_test tn {
}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbu13.test
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,3 @@ do_execsql_test 1.4 {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbu14.test
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,3 @@ foreach {tn schema} {


finish_test

2 changes: 0 additions & 2 deletions ext/rbu/rbu3.test
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,3 @@ do_test 5.3 {
do_test 6.1 { sqlite3rbu_internal_test } {}

finish_test


4 changes: 0 additions & 4 deletions ext/rbu/rbu5.test
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,3 @@ foreach {tn idx} {


finish_test




1 change: 0 additions & 1 deletion ext/rbu/rbu6.test
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,3 @@ for {set nStep 8} {$nStep < 20} {incr nStep} {


finish_test

2 changes: 0 additions & 2 deletions ext/rbu/rbu7.test
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,3 @@ foreach {tn tbl} {
}

finish_test


1 change: 0 additions & 1 deletion ext/rbu/rbu8.test
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,3 @@ integrity_check 1.3.3


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbu9.test
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,3 @@ foreach {tn idx} {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbuA.test
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ do_test 2.2 {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbuB.test
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ sqlite3_shutdown
test_sqlite3_log
sqlite3_initialize
finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbuC.test
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,3 @@ foreach {tn schema} {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbucollate.test
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ do_test 1.2 {

#forcedelete testrbu.db
finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbucrash.test
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,3 @@ for {set nPre 0} {$nPre < $rbu_num_steps} {incr nPre} {
}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbucrash2.test
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,3 @@ for {set x 1} {$x < 2} {incr x} {
}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbudiff.test
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,3 @@ tablE t1 USING FTs5(c);


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbudor.test
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,3 @@ do_execsql_test 1.4 {
} [list 1 $bigA 2 $bigB]

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbufault.test
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,3 @@ foreach {tn2 setup sql expect} {
}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbufault2.test
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ do_faultsim_test 1 -faults oom* -prep {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbufault3.test
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,3 @@ foreach {fault errlist} {
}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbufault4.test
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ for {set tn 1} {1} {incr tn} {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbufts.test
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,3 @@ do_test 3.3 {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbumulti.test
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,3 @@ for {set i 0} {$i<=3} {incr i} {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbuprogress.test
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,3 @@ foreach {bReopen} { 0 1 } {


finish_test

1 change: 0 additions & 1 deletion ext/rbu/rburesume.test
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,3 @@ for {set n 1} {$n < 5000} {incr n} {
}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbusave.test
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,3 @@ do_execsql_test 1.5 {
} {1 one 1 3 3 3 4 4 4 1 one 1 3 3 3 4 4 4}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbusplit.test
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,3 @@ foreach {tn cmd} {
}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbutemplimit.test
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,3 @@ do_test 1.6.1 {
do_test 1.6.2 { info commands rbu } {}

finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbuvacuum.test
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,3 @@ do_test 3.5 {

catch { db close }
finish_test

1 change: 0 additions & 1 deletion ext/rbu/rbuvacuum2.test
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,3 @@ do_test 6.3 {
} {ok}

finish_test

2 changes: 0 additions & 2 deletions ext/repair/test/checkindex01.test
Original file line number Diff line number Diff line change
Expand Up @@ -347,5 +347,3 @@ do_index_check_test 7.3 t7i3 {
do_index_check_test 7.4 t7i4 {
{} 1,1 {} 3,3
}


2 changes: 0 additions & 2 deletions ext/rtree/rtree8.test
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ populate_t1 50
do_execsql_test rtree8-2.1.1 { SELECT max(nodeno) FROM t1_node } {5}
sqlite3_db_config db DEFENSIVE 0
do_execsql_test rtree8-2.1.2 { DELETE FROM t1_node } {}
sqlite3_db_config db DEFENSIVE 1
for {set i 1} {$i <= 50} {incr i} {
do_catchsql_test rtree8-2.1.3.$i {
SELECT * FROM t1 WHERE id = $i
Expand All @@ -127,7 +126,6 @@ sqlite3_db_config db DEFENSIVE 0
do_execsql_test rtree8-2.2.1 {
DELETE FROM t1_parent
} {}
sqlite3_db_config db DEFENSIVE 1
do_catchsql_test rtree8-2.2.2 {
DELETE FROM t1 WHERE id=25
} {1 {database disk image is malformed}}
Expand Down
1 change: 0 additions & 1 deletion ext/session/sessionC.test
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,3 @@ do_test 3.3 {


finish_test

1 change: 0 additions & 1 deletion ext/session/sessionD.test
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,3 @@ do_catchsql_test 4.5.2 {
} {1 {no such table: ixua.i8}}

finish_test

2 changes: 0 additions & 2 deletions ext/session/sessionE.test
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,3 @@ do_changeset_test 3.4 S {
S delete

finish_test


1 change: 0 additions & 1 deletion ext/session/sessionF.test
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,3 @@ foreach {tn setup1 sql1 setup2 sql2 result} {


finish_test

1 change: 0 additions & 1 deletion ext/session/sessionG.test
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,3 @@ do_execsql_test 6.4 {


finish_test

1 change: 0 additions & 1 deletion ext/session/sessionH.test
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ do_test 1.0 {


finish_test

1 change: 0 additions & 1 deletion ext/session/sessionfault2.test
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,3 @@ do_faultsim_test 3.2 -faults oom* -prep {


finish_test

1 change: 0 additions & 1 deletion ext/session/sessionrebase.test
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,3 @@ foreach {tn cmd rebasable} {
catch { R delete }
}
finish_test

1 change: 0 additions & 1 deletion ext/session/sessionstat1.test
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,3 @@ do_test 4.2.3 {
} {t3 null 3}

finish_test

1 change: 0 additions & 1 deletion ext/session/sessionwor.test
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ do_iterator_test 1.3 t1 {
}

finish_test

3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,9 @@ static int openDatabase(
#endif
#if defined(SQLITE_ENABLE_QPSG)
| SQLITE_EnableQPSG
#endif
#if defined(SQLITE_DEFAULT_DEFENSIVE)
| SQLITE_Defensive
#endif
;
sqlite3HashInit(&db->aCollSeq);
Expand Down
2 changes: 2 additions & 0 deletions test/alter2.test
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ 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';
Expand Down Expand Up @@ -91,6 +92,7 @@ do_test alter2-1.0 {
#-----------------------------------------------------------------------
# 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);
Expand Down
1 change: 1 addition & 0 deletions test/altercol.test
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ do_execsql_test 13.1.3 {
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';
Expand Down
1 change: 0 additions & 1 deletion test/alterlegacy.test
Original file line number Diff line number Diff line change
Expand Up @@ -467,4 +467,3 @@ do_execsql_test 14.6 {


finish_test

1 change: 0 additions & 1 deletion test/altertab.test
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,3 @@ do_execsql_test 15.5 {


finish_test

1 change: 0 additions & 1 deletion test/altertab2.test
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ ifcapable fts5 {


finish_test

1 change: 1 addition & 0 deletions test/analyze.test
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ ifcapable stat4||stat3 {
# 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';
Expand Down
7 changes: 7 additions & 0 deletions test/autoinc.test
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ 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;
Expand All @@ -718,6 +719,7 @@ 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');
Expand All @@ -744,6 +746,7 @@ 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');
Expand Down Expand Up @@ -772,6 +775,7 @@ do_test autoinc-12.4 {
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
Expand All @@ -791,6 +795,7 @@ 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');
Expand All @@ -810,6 +815,7 @@ 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');
Expand All @@ -831,6 +837,7 @@ 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');
Expand Down
1 change: 0 additions & 1 deletion test/bestindex5.test
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,3 @@ do_execsql_test 3.5 { SELECT rowid, * FROM t4 WHERE rowid!=1 OR x!='245'; } {}


finish_test

Loading

0 comments on commit 84a7f10

Please sign in to comment.