Index: src/build.c ================================================================== --- src/build.c +++ src/build.c @@ -21,11 +21,11 @@ ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.259 2004/11/04 14:30:05 danielk1977 Exp $ +** $Id: build.c,v 1.260 2004/11/04 14:47:12 drh Exp $ */ #include "sqliteInt.h" #include /* @@ -277,12 +277,11 @@ temp2 = pDb->trigHash; sqlite3HashInit(&pDb->trigHash, SQLITE_HASH_STRING, 0); sqlite3HashClear(&pDb->aFKey); sqlite3HashClear(&pDb->idxHash); for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ - Trigger *pTrigger = sqliteHashData(pElem); - sqlite3DeleteTrigger(pTrigger); + sqlite3DeleteTrigger((Trigger*)sqliteHashData(pElem)); } sqlite3HashClear(&temp2); sqlite3HashInit(&pDb->tblHash, SQLITE_HASH_STRING, 0); for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ Table *pTab = sqliteHashData(pElem); @@ -1589,13 +1588,10 @@ ** erasing iTable (this can happen with an auto-vacuum database). */ static void destroyRootPage(Vdbe *v, int iTable, int iDb){ #ifndef SQLITE_OMIT_AUTOVACUUM int base; -#endif - sqlite3VdbeAddOp(v, OP_Destroy, iTable, iDb); -#ifndef SQLITE_OMIT_AUTOVACUUM /* If SQLITE_OMIT_AUTOVACUUM is not defined, then OP_Destroy pushes ** an integer onto the stack. If this integer is non-zero, then it is ** the root page number of a table moved to location iTable. The ** following writes VDBE code to modify the sqlite_master table to ** reflect this. It is assumed that cursor number 0 is a write-cursor @@ -1628,11 +1624,14 @@ { OP_Integer, 4, 0, 0}, /* 13 */ { OP_Column, 0, 4, 0}, { OP_MakeRecord, 5, 0, 0}, { OP_PutIntKey, 0, 0, 0} /* 16 */ }; +#endif + sqlite3VdbeAddOp(v, OP_Destroy, iTable, iDb); +#ifndef SQLITE_OMIT_AUTOVACUUM base = sqlite3VdbeAddOpList(v, ArraySize(updateMaster), updateMaster); sqlite3VdbeChangeP1(v, base+13, iTable); #endif } @@ -1837,12 +1836,12 @@ ExprList *pFromCol, /* Columns in this table that point to other table */ Token *pTo, /* Name of the other table */ ExprList *pToCol, /* Columns in the other table */ int flags /* Conflict resolution algorithms. */ ){ - FKey *pFKey = 0; #ifndef SQLITE_OMIT_FOREIGN_KEY + FKey *pFKey = 0; Table *p = pParse->pNewTable; int nByte; int i; int nCol; char *z; Index: src/test3.c ================================================================== --- src/test3.c +++ src/test3.c @@ -11,11 +11,11 @@ ************************************************************************* ** Code for testing the btree.c module in SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test3.c,v 1.54 2004/11/04 14:30:06 danielk1977 Exp $ +** $Id: test3.c,v 1.55 2004/11/04 14:47:12 drh Exp $ */ #include "sqliteInt.h" #include "pager.h" #include "btree.h" #include "tcl.h" @@ -560,14 +560,14 @@ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ const char **argv /* Text of each argument */ ){ Btree *pBt; - char *zResult; int nRoot; int *aRoot; int i; + char *zResult; if( argc<3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ID ROOT ...\"", 0); return TCL_ERROR; @@ -579,11 +579,11 @@ if( Tcl_GetInt(interp, argv[i+2], &aRoot[i]) ) return TCL_ERROR; } #ifndef SQLITE_OMIT_INTEGRITY_CHECK zResult = sqlite3BtreeIntegrityCheck(pBt, aRoot, nRoot); #else - zResult = "ok"; + zResult = 0; #endif if( zResult ){ Tcl_AppendResult(interp, zResult, 0); sqliteFree(zResult); } Index: test/attach.test ================================================================== --- test/attach.test +++ test/attach.test @@ -10,11 +10,11 @@ #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # -# $Id: attach.test,v 1.28 2004/11/04 04:42:28 drh Exp $ +# $Id: attach.test,v 1.29 2004/11/04 14:47:13 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -151,10 +151,11 @@ DETACH db5; } db_list db } {0 main 2 db2 3 db3 4 db4 5 db6 6 db7 7 db8 8 db9 9 db10 10 db11} integrity_check attach-1.20.2 +execsql {select * from sqlite_temp_master} do_test attach-1.21 { catchsql { ATTACH 'test.db' as db12; } } {0 {}} Index: test/btree7.test ================================================================== --- test/btree7.test +++ test/btree7.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is btree database backend. # -# $Id: btree7.test,v 1.1 2004/06/05 00:01:46 drh Exp $ +# $Id: btree7.test,v 1.2 2004/11/04 14:47:13 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -37,22 +37,14 @@ INSERT INTO t1 VALUES(5, '$data450'); INSERT INTO t1 VALUES(8, '$bigdata'); INSERT INTO t1 VALUES(9, '$bigdata'); " } {} -#puts [execsql {select * from sqlite_master}] -#set bt [btree_open test.db 2000 0] -#btree_tree_dump $bt 2 -do_test btree7-1.2 { - execsql {PRAGMA integrity_check} -} {ok} +integrity_check btree7-1.2 do_test btree7-1.3 { execsql " INSERT INTO t1 VALUES(4, '$bigdata'); " } {} -#btree_tree_dump $bt 2 -do_test btree7-1.4 { - execsql {PRAGMA integrity_check} -} {ok} +integrity_check btree7-1.4 finish_test Index: test/collate3.test ================================================================== --- test/collate3.test +++ test/collate3.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is page cache subsystem. # -# $Id: collate3.test,v 1.3 2004/06/19 00:16:31 drh Exp $ +# $Id: collate3.test,v 1.4 2004/11/04 14:47:13 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # @@ -219,15 +219,17 @@ do_test collate3-3.6 { catchsql { DELETE FROM collate3t1; } } {0 {}} -do_test collate3-3.8 { - catchsql { - PRAGMA integrity_check - } -} {1 {no such collation sequence: string_compare}} +ifcapable {integrityck} { + do_test collate3-3.8 { + catchsql { + PRAGMA integrity_check + } + } {1 {no such collation sequence: string_compare}} +} do_test collate3-3.9 { catchsql { SELECT * FROM collate3t1; } } {0 {}} Index: test/delete2.test ================================================================== --- test/delete2.test +++ test/delete2.test @@ -27,11 +27,11 @@ # the table. # # The solution to the problem was to detect that the table is locked # before the index entry is deleted. # -# $Id: delete2.test,v 1.1 2004/08/08 19:43:30 drh Exp $ +# $Id: delete2.test,v 1.2 2004/11/04 14:47:13 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -53,37 +53,29 @@ do_test delete2-1.2 { execsql { SELECT * FROM q WHERE id='id.1'; } } {hello id.1} -do_test delete2-1.3 { - execsql { - PRAGMA integrity_check - } -} ok +integrity_check delete2-1.3 # Start a query on the table. The query should not use the index. # Do not complete the query, thus leaving the table locked. # do_test delete2-1.4 { set STMT [sqlite3_prepare $DB {SELECT * FROM q} -1 TAIL] sqlite3_step $STMT } SQLITE_ROW -do_test delete2-1.5 { - execsql {PRAGMA integrity_check} -} {ok} +integrity_check delete2-1.5 # Try to delete a row from the table. The delete should fail. # do_test delete2-1.6 { catchsql { DELETE FROM q WHERE rowid=1 } } {1 {database table is locked}} -do_test delete2-1.7 { - execsql {PRAGMA integrity_check} -} {ok} +integrity_check delete2-1.7 do_test delete2-1.8 { execsql { SELECT * FROM q; } } {hello id.1 goodbye id.2 again id.3} @@ -95,15 +87,13 @@ sqlite3_finalize $STMT catchsql { DELETE FROM q WHERE rowid=1 } } {0 {}} -do_test delete2-1.10 { - execsql {PRAGMA integrity_check} -} {ok} +integrity_check delete2-1.10 do_test delete2-1.11 { execsql { SELECT * FROM q; } } {goodbye id.2 again id.3} finish_test Index: test/memdb.test ================================================================== --- test/memdb.test +++ test/memdb.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is in-memory database backend. # -# $Id: memdb.test,v 1.9 2004/06/19 00:16:31 drh Exp $ +# $Id: memdb.test,v 1.10 2004/11/04 14:47:13 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -109,15 +109,11 @@ } {} } set ::pager_old_format 0 } -do_test memdb-2.1 { - execsql { - PRAGMA integrity_check - } -} {ok} +integrity_check memdb-2.1 do_test memdb-3.1 { execsql { CREATE TABLE t4(a,b,c,d); BEGIN; Index: test/misc3.test ================================================================== --- test/misc3.test +++ test/misc3.test @@ -11,11 +11,11 @@ # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # -# $Id: misc3.test,v 1.14 2004/11/04 04:42:28 drh Exp $ +# $Id: misc3.test,v 1.15 2004/11/04 14:47:13 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {integrityck} { @@ -104,37 +104,35 @@ } 1e+100 # Ticket #522. Make sure integer overflow is handled properly in # indices. # -do_test misc3-3.1 { - execsql {PRAGMA integrity_check} -} ok +integrity_check misc3-3.1 do_test misc3-3.2 { execsql { CREATE TABLE t2(a INT UNIQUE); - PRAGMA integrity_check; } -} ok +} {} +integrity_check misc3-3.2.1 do_test misc3-3.3 { execsql { INSERT INTO t2 VALUES(2147483648); - PRAGMA integrity_check; } -} ok +} {} +integrity_check misc3-3.3.1 do_test misc3-3.4 { execsql { INSERT INTO t2 VALUES(-2147483649); - PRAGMA integrity_check; } -} ok +} {} +integrity_check misc3-3.4.1 do_test misc3-3.5 { execsql { INSERT INTO t2 VALUES(+2147483649); - PRAGMA integrity_check; } -} ok +} {} +integrity_check misc3-3.5.1 do_test misc3-3.6 { execsql { INSERT INTO t2 VALUES(+2147483647); INSERT INTO t2 VALUES(-2147483648); INSERT INTO t2 VALUES(-2147483647); Index: test/pager3.test ================================================================== --- test/pager3.test +++ test/pager3.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is page cache subsystem. # -# $Id: pager3.test,v 1.1 2004/08/18 19:09:44 drh Exp $ +# $Id: pager3.test,v 1.2 2004/11/04 14:47:13 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -57,12 +57,15 @@ execsql { rollback; ------- NOTE (3) } db close sqlite3 db test.db - execsql { - pragma integrity_check; + set r ok + ifcapable {integrityck} { + set r [execsql { + pragma integrity_check; + }] } + set r } ok - finish_test Index: test/pragma.test ================================================================== --- test/pragma.test +++ test/pragma.test @@ -10,11 +10,11 @@ #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the PRAGMA command. # -# $Id: pragma.test,v 1.20 2004/11/03 16:27:02 drh Exp $ +# $Id: pragma.test,v 1.21 2004/11/04 14:47:13 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Test organization: @@ -218,11 +218,11 @@ INSERT INTO t2 VALUES(22,3,4); COMMIT; SELECT rowid, * from t2; } } {1 11 2 3 2 22 3 4} -if {![sqlite3 -has-codec]} { +if {![sqlite3 -has-codec] && $sqlite_options(integrityck)} { do_test pragma-3.2 { set rootpage [execsql {SELECT rootpage FROM sqlite_master WHERE name='i2'}] set db [btree_open test.db 100 0] btree_begin_transaction $db set c [btree_cursor $db $rootpage 1] @@ -305,10 +305,11 @@ # Test schema-query pragmas # do_test pragma-6.1 { set res {} + execsql {SELECT * FROM sqlite_temp_master} foreach {idx name file} [execsql {pragma database_list}] { lappend res $idx $name } set res } {0 main 1 temp 2 aux} Index: test/trigger2.test ================================================================== --- test/trigger2.test +++ test/trigger2.test @@ -191,15 +191,11 @@ SELECT * FROM rlog; } } [list 1 0 0 0.0 0.0 5 6 \ 2 0 0 5.0 6.0 5 6 ] - do_test trigger2-1.$ii.4 { - execsql { - PRAGMA integrity_check; - } - } {ok} + integrity_check trigger2-1.$ii.4 } catchsql { DROP TABLE rlog; DROP TABLE clog; DROP TABLE tbl; @@ -313,16 +309,11 @@ ON tbl BEGIN $tr_program_fixed END;" do_test trigger2-2.$ii-after "execsql {$statement $query}" $after_data execsql "DROP TRIGGER the_trigger;" - do_test trigger2-2.$ii-integrity { - execsql { - PRAGMA integrity_check; - } - } {ok} - + integrity_check trigger2-2.$ii-integrity } } catchsql { DROP TABLE tbl; DROP TABLE log; @@ -389,15 +380,11 @@ } {1 0 1} execsql { DROP TABLE tbl; DROP TABLE log; } -do_test trigger2-3.3 { - execsql { - PRAGMA integrity_check; - } -} {ok} +integrity_check trigger2-3.3 # Simple cascaded trigger execsql { CREATE TABLE tblA(a, b); CREATE TABLE tblB(a, b); @@ -721,10 +708,8 @@ UPDATE v1 SET x=x+100, y=y+200, z=z+300; SELECT * FROM v1log; } } {3 103 5 205 4 304 9 109 11 211 10 310} -do_test trigger2-9.9 { - execsql {PRAGMA integrity_check} -} {ok} +integrity_check trigger2-9.9 finish_test