From 798da52ce7becd856a33f87962202528242930c9 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 4 Nov 2004 04:42:28 +0000 Subject: [PATCH] All tests pass even if OMIT_TRIGGER is defined. (CVS 2053) FossilOrigin-Name: c33b3a613751057e8a46fdcd428b8448329d414d --- manifest | 46 ++++----- manifest.uuid | 2 +- src/delete.c | 12 ++- src/insert.c | 8 +- src/update.c | 6 +- test/attach.test | 28 ++++- test/attach3.test | 4 +- test/collate6.test | 13 ++- test/delete.test | 83 ++++++++------- test/index.test | 14 +-- test/interrupt.test | 6 +- test/lastinsert.test | 9 +- test/laststmtchanges.test | 10 +- test/main.test | 208 +++++++++++++++++++------------------- test/misc1.test | 4 +- test/misc2.test | 4 +- test/misc3.test | 105 ++++++++++--------- test/pagesize.test | 24 ++--- test/rowid.test | 14 ++- test/vacuum.test | 10 +- 20 files changed, 349 insertions(+), 261 deletions(-) diff --git a/manifest b/manifest index cb640f5ad3..d4f99325ab 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\s#ifdef\sin\sutil.c.\s\sTicket\s#984.\s(CVS\s2052) -D 2004-11-04T04:34:15 +C All\stests\spass\seven\sif\sOMIT_TRIGGER\sis\sdefined.\s(CVS\s2053) +D 2004-11-04T04:42:28 F Makefile.in c4d2416860f472a1e3393714d0372074197565df F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 @@ -33,12 +33,12 @@ F src/btree.c 93163198e6fb666b92c893fba5edb3ef6f335c0f F src/btree.h 94dfec0a1722d33359b23e7e310f2b64ffedf029 F src/build.c bb896c5f85ab749d17ae5d730235134c12c08033 F src/date.c 34bdb0082db7ec2a83ef00063f7b44e61ee19dad -F src/delete.c cf0efbef1f42d4eec385a3f59af2b37a5e232074 +F src/delete.c 52980e594e69e80374fb928fe611d5f75ca4e390 F src/expr.c 3a43e508a3dc213703808bbcbb17633b88b57d17 F src/func.c 600e506bccf7648df8ad03efb417560d0f7ad4c1 F src/hash.c a97721a55440b7bea31ffe471bb2f6b4123cddd5 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84 -F src/insert.c 64a3716522cbc81d91176eac0d944cc14be6236c +F src/insert.c 17f66e2c32e551122f45cea11db3e664471418d6 F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b F src/main.c ba1b26f03af4b7f8be3394748123dd671b9ea147 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 @@ -71,7 +71,7 @@ F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df F src/test5.c b001fa7f1b9e2dc5c2331de62fc641b5ab2bd7a1 F src/tokenize.c bf9de9689b3bb813d65784bf54472804bf9595e6 F src/trigger.c f9a0a8d3a87238de1a934eeb7d0b6b1f13e6a55b -F src/update.c ee15b7ba712c2292802eba2d465f039b5deada39 +F src/update.c 7b17b281d600bf3e220b3c5718e0883442dee722 F src/utf.c f4f83acd73389090e32d6589d307fc55d794c7ed F src/util.c 005fdf2d008f3429d081766ad6098fdd86d8d8e6 F src/vacuum.c ecb4a2c6f1ac5cc9b394dc64d3bb14ca650c4f60 @@ -83,9 +83,9 @@ F src/vdbeaux.c 544ff66308d3184b519decc731abb65c5233bc2d F src/vdbemem.c ef9ac7d32acfe4bce5c5b408b1294c8d9e0cdb56 F src/where.c 6e637a6b3e61fe3104adc4e5caa4738bf6570daa F test/all.test 929bfa932b55e75c96fe2203f7650ba451c1862c -F test/attach.test 6ad560eb3e77751a4faecd77da09deac9e38cc41 +F test/attach.test ff7fc16b4518a448fed47dfb3694bf57f522d552 F test/attach2.test f7795123d3051ace1672b6d23973da6435de3745 -F test/attach3.test 6d060986ff004ebb89e1876a331d96c6bb62269e +F test/attach3.test 742c932d7130e0e699a5d9f265cb831e0a824633 F test/auth.test 1cc252d9e7b3bdc1314199cbf3a0d3c5ed026c21 F test/autovacuum.test 9211914801ad35ad8f0fc15711b12461850ef2ac F test/bigfile.test d3744a8821ce9abb8697f2826a3e3d22b719e89f @@ -106,13 +106,13 @@ F test/collate2.test 12fd658d8f5106a8a5c8a77d66919d8c89394036 F test/collate3.test e60b428e07ec945492ba90ff1c895902ee3a8a50 F test/collate4.test c29c8d4b66cf45b36fa112c28493cdb451a8409b F test/collate5.test 1dd5f0f508c46667f9d4606c7950c414b0bdc0d5 -F test/collate6.test 2a45768914f04c1447a69d1358bbede376552675 +F test/collate6.test 6c9470d1606ee3e564675b229653e320c49ec638 F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87 F test/corrupt.test 0080ddcece23e8ba47c44608c4fb73fd4d1d8ce2 F test/crash.test a3f6d27f7cb7f7bd752461db1e14f7c781ecedc3 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/date.test dda578ec1857837156bd8b32f8e09d81d7d7881c -F test/delete.test ec0b455f2dcc0e189d96ee438438ba026c4e51d8 +F test/delete.test fc29491f6a7ac899ce29f4549a104809e245d9a6 F test/delete2.test 050a3a6e8ea0f83aed817d164b16af2a499fb452 F test/diskfull.test e2f6cfd868713ead06dc82b84a4938e868128fc0 F test/enc.test 2f5463af488d50aef60c6110bec6b21b5efba961 @@ -123,30 +123,30 @@ F test/fkey1.test 81bb13caaa78f58d7d191d7f535529f7c91d821a F test/func.test 830d352574c7f5cd15149a9be58a6dcc2b995c05 F test/hook.test f8605cde4c77b2c6a4a73723bf6c507796a64dda F test/in.test b92a2df9162e1cbd33c6449a29a05e6955b1741a -F test/index.test 83f5c232948801da2d9b7c603362d8e0313485bc +F test/index.test 4098cd020180bec286ef1a96bca256e76cc7b654 F test/insert.test c571223b499961d843ce0ab4709c87fa60ab2425 F test/insert2.test 614a29d3ed7dd0d8644a059c6d8ce742c63a734a -F test/interrupt.test 6b6b8b86cdeb66d5488bd1db74b4bb3c46e4f565 +F test/interrupt.test 5c336baaf810e5f7a91d2f01e2cafca480885dfe F test/intpkey.test b57cf5236fde1bd8cbc1388fa0c91908f6fd9194 F test/ioerr.test 3ce897ee998ee874073f3b23b0396d9ff804759c F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd F test/join2.test c97e4c5aa65dea462145529e58212a709b4722b8 F test/join3.test 67dc0d7c8dab3fff25796d0f3c3fd9c999aeded3 F test/join4.test 8dec387d06b3a4685e1104048065cf5236b99b93 -F test/lastinsert.test 31382f88b9b0270333ac9e4a17f2c2f4732da718 -F test/laststmtchanges.test 417aa27eb2b5cdfafb46e390e2c9ddd0a20eba43 +F test/lastinsert.test 09ac3a359ced3d4510feccc0dcbae3d80e449cf9 +F test/laststmtchanges.test 9cb56c5935103cacd0070d9d25d8dde322928db1 F test/limit.test f7c06fccd76755e8d083b61c06bc31cf461b9c35 F test/lock.test 7cb9395919a0986ee4dd08bd49d34df93c8fc4fe F test/lock2.test 2213590d442147d09fd2334c905a755586c1c398 F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9 -F test/main.test add6cd4fc1264becd3d195431073f202738af317 +F test/main.test 5f9deae11b93336da1ccc5f91cf8be075c91ddf1 F test/malloc.test 769b240d89a7ef3320d88919fdb6765f9395a51f F test/memdb.test b8a13fa79f006bd087bbcf135ce8eb62056a6027 F test/memleak.test f1fa233f8295dd1d955a00d5e5ee857850f27f29 F test/minmax.test c0f92d3f7b11656221735385f2c8b1878bbbdaf6 -F test/misc1.test 1a20ea722dff15155e93948dc4ac3e8d80fec386 -F test/misc2.test 703734f5817215ca54e364833b3bf5ff36fcc21e -F test/misc3.test db48619711950a1098b9547a8091cbb440b22e54 +F test/misc1.test 744f60d1025fa978708b96cb222a07a1feb1524a +F test/misc2.test 9d9403f7e6092699f3f92bb1e26ff55165528e7c +F test/misc3.test 8c83c3810d6254d9d63b4cbf3941c7b9523c236d F test/misc4.test d005a75f095bb04db09a5d096144405ae566b622 F test/misuse.test fcd9e7cec6ecccc34822584aec6b4e31f13629e1 F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0 @@ -154,14 +154,14 @@ F test/null.test 642428b6a5408cc5b954b49e1b6e5025e4458b2b F test/pager.test 394455707a079804e8a4e431d12edce831a065f0 F test/pager2.test c7e731ac56a2984a605b032ffd19b9deee820377 F test/pager3.test 16f546293bb751b8151dc17df613fca938bbec8b -F test/pagesize.test 86e14e54b608c00ecf86d14504ad8fed1e4e0064 +F test/pagesize.test 2050bb574c43f9143d283d6bcd37fa1eb73f0e49 F test/pragma.test ed8156b5ef3a82ff7be6bd814b3715079ea5a6b0 F test/printf.test 92ba4c510b4fc61120ffa4a01820446ed917ae57 F test/progress.test 5ddba78cb6011fba36093973cfb3ac473b8fb96a x F test/quick.test 2dca186ebd5c418a7699944ba3b5e437d765eddd F test/quote.test 6d75cf635d93ba2484dc9cb378d88cbae9dc2c62 F test/rollback.test 4097328d44510277244ef4fa51b22b2f11d7ef4c -F test/rowid.test b3d059f5c8d8874fa1c31030e0636f67405d20ea +F test/rowid.test 1ce3f1520d2082b0363e7d9bdef904cb72b9efe8 F test/select1.test 0e459a8066259445d707cc4f64ea00459441e29f F test/select2.test 91a2225926039b0d1687840735c284dbbf89f0bc F test/select3.test 9de435aa84fc406708cd8dc1b1d60e7f27cea685 @@ -191,7 +191,7 @@ F test/types2.test f23c147a2ab3e51d5dbcfa9987200db5acba7aa7 F test/unique.test 0e38d4cc7affeef2527720d1dafd1f6870f02f2b F test/update.test b29bd9061a1150426dab6959806fcc73a41b1217 F test/utf16.test 459c2f5ab80c60092c603630a348c32d6e59c558 -F test/vacuum.test 98831051cff8e6084f22785c79bdb10080c42dde +F test/vacuum.test fea17dd67231ced71ef71ac15f01760593af5ff6 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/view.test 2ec8fd4f3809243ad12667932071d536d1ba6850 F test/where.test 8a016d444252553a0c7c3a4c806d3f782f7337eb @@ -252,7 +252,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c -P 571de52376f52999268ba5e0cd05c6c6eff1ebbf -R 88bc900ed597200e93ade91a1a123d03 +P da045bd183335a112f9a6c805c12efe12d0a25ca +R 3020d6f48bce04fcef7f5133e21d3db2 U drh -Z 7327d11a71a1235a378656ac4c026c33 +Z 625b1d515abab0cebf7c5f6337f4ff8c diff --git a/manifest.uuid b/manifest.uuid index 47373639e2..bfcf2e9e7a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -da045bd183335a112f9a6c805c12efe12d0a25ca \ No newline at end of file +c33b3a613751057e8a46fdcd428b8448329d414d \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index e9b2bf7070..a476c4fded 100644 --- a/src/delete.c +++ b/src/delete.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle DELETE FROM statements. ** -** $Id: delete.c,v 1.84 2004/10/31 02:22:49 drh Exp $ +** $Id: delete.c,v 1.85 2004/11/04 04:42:28 drh Exp $ */ #include "sqliteInt.h" @@ -81,13 +81,15 @@ void sqlite3DeleteFrom( Index *pIdx; /* For looping over indices of the table */ int iCur; /* VDBE Cursor number for pTab */ sqlite3 *db; /* Main database structure */ - int isView; /* True if attempting to delete from a view */ AuthContext sContext; /* Authorization context */ + int oldIdx = -1; /* Cursor for the OLD table of AFTER triggers */ +#ifndef SQLITE_OMIT_TRIGGER + int isView; /* True if attempting to delete from a view */ int row_triggers_exist = 0; /* True if any triggers exist */ int before_triggers; /* True if there are BEFORE triggers */ int after_triggers; /* True if there are AFTER triggers */ - int oldIdx = -1; /* Cursor for the OLD table of AFTER triggers */ +#endif sContext.pParse = 0; if( pParse->nErr || sqlite3_malloc_failed ){ @@ -271,7 +273,7 @@ void sqlite3DeleteFrom( sqlite3VdbeAddOp(v, OP_Close, iCur, 0); } - sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1, + (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1, oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default, addr); } @@ -305,7 +307,7 @@ void sqlite3DeleteFrom( } sqlite3VdbeAddOp(v, OP_Close, iCur, 0); } - sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1, + (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1, oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default, addr); } diff --git a/src/insert.c b/src/insert.c index d7a202a5df..0112f8d524 100644 --- a/src/insert.c +++ b/src/insert.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** -** $Id: insert.c,v 1.120 2004/10/31 02:22:49 drh Exp $ +** $Id: insert.c,v 1.121 2004/11/04 04:42:28 drh Exp $ */ #include "sqliteInt.h" @@ -188,12 +188,14 @@ void sqlite3Insert( int iCleanup = 0; /* Address of the cleanup code */ int iInsertBlock = 0; /* Address of the subroutine used to insert data */ int iCntMem = 0; /* Memory cell used for the row counter */ - int isView; /* True if attempting to insert into a view */ + int newIdx = -1; /* Cursor for the NEW table */ +#ifndef SQLITE_OMIT_TRIGGER + int isView; /* True if attempting to insert into a view */ int row_triggers_exist = 0; /* True if there are FOR EACH ROW triggers */ int before_triggers; /* True if there are BEFORE triggers */ int after_triggers; /* True if there are AFTER triggers */ - int newIdx = -1; /* Cursor for the NEW table */ +#endif if( pParse->nErr || sqlite3_malloc_failed ) goto insert_cleanup; db = pParse->db; diff --git a/src/update.c b/src/update.c index 1905c3073b..b184c038cf 100644 --- a/src/update.c +++ b/src/update.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** -** $Id: update.c,v 1.91 2004/10/31 02:22:49 drh Exp $ +** $Id: update.c,v 1.92 2004/11/04 04:42:28 drh Exp $ */ #include "sqliteInt.h" @@ -48,12 +48,14 @@ void sqlite3Update( int chngRecno; /* True if the record number is being changed */ Expr *pRecnoExpr = 0; /* Expression defining the new record number */ int openAll = 0; /* True if all indices need to be opened */ - int isView; /* Trying to update a view */ AuthContext sContext; /* The authorization context */ +#ifndef SQLITE_OMIT_TRIGGER + int isView; /* Trying to update a view */ int before_triggers; /* True if there are any BEFORE triggers */ int after_triggers; /* True if there are any AFTER triggers */ int row_triggers_exist = 0; /* True if any row triggers exist */ +#endif int newIdx = -1; /* index of trigger "new" temp table */ int oldIdx = -1; /* index of trigger "old" temp table */ diff --git a/test/attach.test b/test/attach.test index 26376d7bb5..f18dd6eac6 100644 --- a/test/attach.test +++ b/test/attach.test @@ -12,7 +12,7 @@ # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # -# $Id: attach.test,v 1.27 2004/10/31 02:22:50 drh Exp $ +# $Id: attach.test,v 1.28 2004/11/04 04:42:28 drh Exp $ # set testdir [file dirname $argv0] @@ -454,11 +454,11 @@ do_test attach-4.5 { SELECT * FROM db2.t3; } } {1 2 9 10} +execsql { + DETACH db2; +} ifcapable {trigger} { do_test attach-4.6 { - execsql { - DETACH db2; - } execsql { CREATE TABLE t4(x); CREATE TRIGGER t3r3 AFTER INSERT ON t3 BEGIN @@ -479,6 +479,23 @@ ifcapable {trigger} { } } {main.11} } +ifcapable {!trigger} { + # When we do not have trigger support, set up the table like they + # would have been had triggers been there. The tests that follow need + # this setup. + execsql { + CREATE TABLE t4(x); + INSERT INTO t3 VALUES(6,7); + INSERT INTO t4 VALUES('db2.6'); + INSERT INTO t4 VALUES('db2.13'); + } db2 + execsql { + CREATE TABLE t4(y); + INSERT INTO main.t3 VALUES(11,12); + INSERT INTO t4 VALUES('main.11'); + } +} + # This one is tricky. On the UNION ALL select, we have to make sure # the schema for both main and db2 is valid before starting to execute @@ -496,6 +513,7 @@ do_test attach-4.8 { } {db2.6 db2.13 main.11} do_test attach-4.9 { + ifcapable {!trigger} {execsql {INSERT INTO main.t4 VALUES('main.15')}} execsql { INSERT INTO main.t3 VALUES(15,16); SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4; @@ -530,6 +548,7 @@ do_test attach-4.13 { # Tests for the sqliteFix...() routines in attach.c # +ifcapable {trigger} { do_test attach-5.1 { db close sqlite3 db test.db @@ -609,6 +628,7 @@ do_test attach-5.9 { END; } db2 } {1 {trigger r5 cannot reference objects in database temp}} +} ;# endif trigger # Check to make sure we get a sensible error if unable to open # the file that we are trying to attach. diff --git a/test/attach3.test b/test/attach3.test index 27b59c5ced..cc310164af 100644 --- a/test/attach3.test +++ b/test/attach3.test @@ -12,7 +12,7 @@ # focus of this script is testing the ATTACH and DETACH commands # and schema changes to attached databases. # -# $Id: attach3.test,v 1.9 2004/07/19 00:56:24 drh Exp $ +# $Id: attach3.test,v 1.10 2004/11/04 04:42:28 drh Exp $ # @@ -153,6 +153,7 @@ do_test attach3-6.2 { } } {} +ifcapable {trigger} { # Create a trigger in the auxilary database. do_test attach3-7.1 { execsql { @@ -211,6 +212,7 @@ do_test attach3-9.2 { SELECT count(*) FROM sqlite_temp_master; } } {0} +} ;# endif trigger # Make sure the aux.sqlite_master table is read-only do_test attach3-10.0 { diff --git a/test/collate6.test b/test/collate6.test index c371e088be..477ef4df48 100644 --- a/test/collate6.test +++ b/test/collate6.test @@ -12,11 +12,19 @@ # This file implements regression tests for SQLite library. The # focus of this script is collation sequences in concert with triggers. # -# $Id: collate6.test,v 1.1 2004/06/11 10:51:41 danielk1977 Exp $ +# $Id: collate6.test,v 1.2 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl +# There are no tests in this file that will work without +# trigger support. +# +ifcapable {!trigger} { + finish_test + return +} + # Create a case-insensitive collation type NOCASE for use in testing. # Normally, capital letters are less than their lower-case counterparts. db collate NOCASE nocase_collate @@ -101,6 +109,3 @@ do_test collate6-1.9 { finish_test - - - diff --git a/test/delete.test b/test/delete.test index 79ac457f58..d582bcf960 100644 --- a/test/delete.test +++ b/test/delete.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the DELETE FROM statement. # -# $Id: delete.test,v 1.17 2004/07/15 20:08:39 drh Exp $ +# $Id: delete.test,v 1.18 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -216,44 +216,49 @@ do_test delete-7.1 { SELECT * FROM t3; } } {1 2 3 4} -do_test delete-7.2 { - execsql { - CREATE TABLE cnt(del); - INSERT INTO cnt VALUES(0); - CREATE TRIGGER r1 AFTER DELETE ON t3 FOR EACH ROW BEGIN - UPDATE cnt SET del=del+1; - END; - DELETE FROM t3 WHERE a<2; - SELECT * FROM t3; - } -} {2 3 4} -do_test delete-7.3 { - execsql { - SELECT * FROM cnt; - } -} {1} -do_test delete-7.4 { - execsql { - DELETE FROM t3; - SELECT * FROM t3; - } -} {} -do_test delete-7.5 { - execsql { - SELECT * FROM cnt; - } -} {4} -do_test delete-7.6 { - execsql { - INSERT INTO t3 VALUES(1); - INSERT INTO t3 SELECT a+1 FROM t3; - INSERT INTO t3 SELECT a+2 FROM t3; - CREATE TABLE t4 AS SELECT * FROM t3; - PRAGMA count_changes=ON; - DELETE FROM t3; - DELETE FROM t4; - } -} {4 4} +ifcapable {trigger} { + do_test delete-7.2 { + execsql { + CREATE TABLE cnt(del); + INSERT INTO cnt VALUES(0); + CREATE TRIGGER r1 AFTER DELETE ON t3 FOR EACH ROW BEGIN + UPDATE cnt SET del=del+1; + END; + DELETE FROM t3 WHERE a<2; + SELECT * FROM t3; + } + } {2 3 4} + do_test delete-7.3 { + execsql { + SELECT * FROM cnt; + } + } {1} + do_test delete-7.4 { + execsql { + DELETE FROM t3; + SELECT * FROM t3; + } + } {} + do_test delete-7.5 { + execsql { + SELECT * FROM cnt; + } + } {4} + do_test delete-7.6 { + execsql { + INSERT INTO t3 VALUES(1); + INSERT INTO t3 SELECT a+1 FROM t3; + INSERT INTO t3 SELECT a+2 FROM t3; + CREATE TABLE t4 AS SELECT * FROM t3; + PRAGMA count_changes=ON; + DELETE FROM t3; + DELETE FROM t4; + } + } {4 4} +} ;# endif trigger +ifcapable {!trigger} { + execsql {DELETE FROM t3} +} integrity_check delete-7.7 # Make sure error messages are consistent when attempting to delete diff --git a/test/index.test b/test/index.test index 680affcbb0..067c4daef0 100644 --- a/test/index.test +++ b/test/index.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the CREATE INDEX statement. # -# $Id: index.test,v 1.33 2004/11/03 16:27:02 drh Exp $ +# $Id: index.test,v 1.34 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -598,11 +598,13 @@ do_test index-18.3 { CREATE VIEW sqlite_v1 AS SELECT * FROM t7; } } {1 {object name reserved for internal use: sqlite_v1}} -do_test index-18.4 { - catchsql { - CREATE TRIGGER sqlite_tr1 BEFORE INSERT ON t7 BEGIN SELECT 1; END; - } -} {1 {object name reserved for internal use: sqlite_tr1}} +ifcapable {trigger} { + do_test index-18.4 { + catchsql { + CREATE TRIGGER sqlite_tr1 BEFORE INSERT ON t7 BEGIN SELECT 1; END; + } + } {1 {object name reserved for internal use: sqlite_tr1}} +} do_test index-18.5 { execsql { DROP TABLE t7; diff --git a/test/interrupt.test b/test/interrupt.test index 3860ea897d..ed22d5ebbd 100644 --- a/test/interrupt.test +++ b/test/interrupt.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is the sqlite_interrupt() API. # -# $Id: interrupt.test,v 1.5 2004/10/30 20:23:10 drh Exp $ +# $Id: interrupt.test,v 1.6 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] @@ -94,7 +94,9 @@ do_test interrrupt-2.1 { } 64 set origsize [file size test.db] set cksum [db eval {SELECT md5sum(a || b) FROM t1}] -interrupt_test interrupt-2.2 {VACUUM} {} 100 +ifcapable {vacuum} { + interrupt_test interrupt-2.2 {VACUUM} {} 100 +} do_test interrupt-2.3 { execsql { SELECT md5sum(a || b) FROM t1; diff --git a/test/lastinsert.test b/test/lastinsert.test index 702b437e8a..9b317222d2 100644 --- a/test/lastinsert.test +++ b/test/lastinsert.test @@ -61,6 +61,14 @@ do_test lastinsert-1.4 { } } {0 3} +# All remaining tests involve triggers. Skip them if triggers are not +# supported in this build. +# +ifcapable {!trigger} { + finish_test + return +} + # ---------------------------------------------------------------------------- # 2.x - tests with after insert trigger @@ -316,4 +324,3 @@ do_test lastinsert-7.6 { } {0 1205} finish_test - diff --git a/test/laststmtchanges.test b/test/laststmtchanges.test index f7adcd2e79..c2b16ea2a8 100644 --- a/test/laststmtchanges.test +++ b/test/laststmtchanges.test @@ -74,6 +74,15 @@ do_test laststmtchanges-1.5 { } } {0 3} +# All remaining tests involve triggers. Skip them if triggers are not +# supported in this build. +# +ifcapable {!trigger} { + finish_test + return +} + + # ---------------------------------------------------------------------------- # 2.x - tests with after insert trigger @@ -254,4 +263,3 @@ do_test laststmtchanges-5.5 { } {0 {0 1 0 3}} finish_test - diff --git a/test/main.test b/test/main.test index eab2764fe6..10ef35b2f2 100644 --- a/test/main.test +++ b/test/main.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is exercising the code in main.c. # -# $Id: main.test,v 1.17 2004/11/03 16:27:02 drh Exp $ +# $Id: main.test,v 1.18 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -75,120 +75,122 @@ do_test main-1.16 { CREATE TABLE abc(x,y); } } {1} -do_test main-1.17 { - db complete { - CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr; - } -} {0} -do_test main-1.18 { - db complete { - CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr; END; - } -} {1} -do_test main-1.19 { - db complete { - CREATE TRIGGER xyz AFTER DELETE abc BEGIN - UPDATE pqr; - unknown command; - } -} {0} -do_test main-1.20 { - db complete { - CREATE TRIGGER xyz AFTER DELETE backend BEGIN - UPDATE pqr; - } -} {0} -do_test main-1.21 { - db complete { - CREATE TRIGGER xyz AFTER DELETE end BEGIN - SELECT a, b FROM end; - } -} {0} -do_test main-1.22 { - db complete { - CREATE TRIGGER xyz AFTER DELETE end BEGIN - SELECT a, b FROM end; - END; - } -} {1} -do_test main-1.23 { - db complete { - CREATE TRIGGER xyz AFTER DELETE end BEGIN - SELECT a, b FROM end; - END; - SELECT a, b FROM end; - } -} {1} -do_test main-1.24 { - db complete { - CREATE TRIGGER xyz AFTER DELETE [;end;] BEGIN - UPDATE pqr; - } -} {0} -do_test main-1.25 { - db complete { - CREATE TRIGGER xyz AFTER DELETE backend BEGIN - UPDATE pqr SET a=[;end;];;; - } -} {0} -do_test main-1.26 { - db complete { - CREATE -- a comment - TRIGGER xyz AFTER DELETE backend BEGIN - UPDATE pqr SET a=5; - } -} {0} -do_test main-1.27.1 { - db complete { - CREATE -- a comment - TRIGGERX xyz AFTER DELETE backend BEGIN - UPDATE pqr SET a=5; - } -} {1} -do_test main-1.27.2 { - db complete { - CREATE/**/TRIGGER xyz AFTER DELETE backend BEGIN - UPDATE pqr SET a=5; - } -} {0} -ifcapable {explain} { - do_test main-1.27.3 { +ifcapable {trigger} { + do_test main-1.17 { + db complete { + CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr; + } + } {0} + do_test main-1.18 { + db complete { + CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr; END; + } + } {1} + do_test main-1.19 { + db complete { + CREATE TRIGGER xyz AFTER DELETE abc BEGIN + UPDATE pqr; + unknown command; + } + } {0} + do_test main-1.20 { + db complete { + CREATE TRIGGER xyz AFTER DELETE backend BEGIN + UPDATE pqr; + } + } {0} + do_test main-1.21 { + db complete { + CREATE TRIGGER xyz AFTER DELETE end BEGIN + SELECT a, b FROM end; + } + } {0} + do_test main-1.22 { + db complete { + CREATE TRIGGER xyz AFTER DELETE end BEGIN + SELECT a, b FROM end; + END; + } + } {1} + do_test main-1.23 { + db complete { + CREATE TRIGGER xyz AFTER DELETE end BEGIN + SELECT a, b FROM end; + END; + SELECT a, b FROM end; + } + } {1} + do_test main-1.24 { + db complete { + CREATE TRIGGER xyz AFTER DELETE [;end;] BEGIN + UPDATE pqr; + } + } {0} + do_test main-1.25 { + db complete { + CREATE TRIGGER xyz AFTER DELETE backend BEGIN + UPDATE pqr SET a=[;end;];;; + } + } {0} + do_test main-1.26 { + db complete { + CREATE -- a comment + TRIGGER xyz AFTER DELETE backend BEGIN + UPDATE pqr SET a=5; + } + } {0} + do_test main-1.27.1 { + db complete { + CREATE -- a comment + TRIGGERX xyz AFTER DELETE backend BEGIN + UPDATE pqr SET a=5; + } + } {1} + do_test main-1.27.2 { db complete { - /* */ EXPLAIN -- A comment CREATE/**/TRIGGER xyz AFTER DELETE backend BEGIN UPDATE pqr SET a=5; } } {0} -} -do_test main-1.27.4 { - db complete { - BOGUS token - CREATE TRIGGER xyz AFTER DELETE backend BEGIN - UPDATE pqr SET a=5; + ifcapable {explain} { + do_test main-1.27.3 { + db complete { + /* */ EXPLAIN -- A comment + CREATE/**/TRIGGER xyz AFTER DELETE backend BEGIN + UPDATE pqr SET a=5; + } + } {0} } -} {1} -ifcapable {explain} { - do_test main-1.27.5 { + do_test main-1.27.4 { + db complete { + BOGUS token + CREATE TRIGGER xyz AFTER DELETE backend BEGIN + UPDATE pqr SET a=5; + } + } {1} + ifcapable {explain} { + do_test main-1.27.5 { + db complete { + EXPLAIN + CREATE TEMP TRIGGER xyz AFTER DELETE backend BEGIN + UPDATE pqr SET a=5; + } + } {0} + } + do_test main-1.28 { db complete { - EXPLAIN CREATE TEMP TRIGGER xyz AFTER DELETE backend BEGIN UPDATE pqr SET a=5; } } {0} + do_test main-1.29 { + db complete { + CREATE TRIGGER xyz AFTER DELETE backend BEGIN + UPDATE pqr SET a=5; + EXPLAIN select * from xyz; + } + } {0} } -do_test main-1.28 { - db complete { - CREATE TEMP TRIGGER xyz AFTER DELETE backend BEGIN - UPDATE pqr SET a=5; - } -} {0} -do_test main-1.29 { - db complete { - CREATE TRIGGER xyz AFTER DELETE backend BEGIN - UPDATE pqr SET a=5; - EXPLAIN select * from xyz; - } -} {0} do_test main-1.30 { db complete { CREATE TABLE /* In comment ; */ diff --git a/test/misc1.test b/test/misc1.test index 8a9137e297..a6f1bf44da 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -13,7 +13,7 @@ # This file implements tests for miscellanous features that were # left out of other test files. # -# $Id: misc1.test,v 1.30 2004/08/20 18:34:20 drh Exp $ +# $Id: misc1.test,v 1.31 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -538,6 +538,7 @@ do_test misc1-16.6 { } } {1 1 5 5 6 6} +ifcapable {trigger} { # Ticket #333: Temp triggers that modify persistent tables. # do_test misc1-17.1 { @@ -556,5 +557,6 @@ do_test misc1-17.1 { SELECT TestString FROM RealTable ORDER BY 1; } } {2 3} +} finish_test diff --git a/test/misc2.test b/test/misc2.test index 1eefe95f88..9a2c9dba51 100644 --- a/test/misc2.test +++ b/test/misc2.test @@ -13,11 +13,12 @@ # This file implements tests for miscellanous features that were # left out of other test files. # -# $Id: misc2.test,v 1.12 2004/06/19 00:16:31 drh Exp $ +# $Id: misc2.test,v 1.13 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl +ifcapable {trigger} { # Test for ticket #360 # do_test misc2-1.1 { @@ -35,6 +36,7 @@ do_test misc2-1.2 { INSERT INTO foo(bar) VALUES (111); } } {1 aiieee} +} ;# endif trigger # Make sure ROWID works on a view and a subquery. Ticket #364 # diff --git a/test/misc3.test b/test/misc3.test index a15f008fa7..77ad6f7796 100644 --- a/test/misc3.test +++ b/test/misc3.test @@ -13,60 +13,65 @@ # This file implements tests for miscellanous features that were # left out of other test files. # -# $Id: misc3.test,v 1.13 2004/11/03 16:27:02 drh Exp $ +# $Id: misc3.test,v 1.14 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl -# Ticket #529. Make sure an ABORT does not damage the in-memory cache -# that will be used by subsequent statements in the same transaction. -# -do_test misc3-1.1 { - execsql { - CREATE TABLE t1(a UNIQUE,b); - INSERT INTO t1 +ifcapable {integrityck} { + # Ticket #529. Make sure an ABORT does not damage the in-memory cache + # that will be used by subsequent statements in the same transaction. + # + do_test misc3-1.1 { + execsql { + CREATE TABLE t1(a UNIQUE,b); + INSERT INTO t1 + VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_'); + UPDATE t1 SET b=b||b; + UPDATE t1 SET b=b||b; + UPDATE t1 SET b=b||b; + UPDATE t1 SET b=b||b; + UPDATE t1 SET b=b||b; + INSERT INTO t1 VALUES(2,'x'); + UPDATE t1 SET b=substr(b,1,500); + BEGIN; + } + catchsql {UPDATE t1 SET a=CASE a WHEN 2 THEN 1 ELSE a END, b='y';} + execsql { + CREATE TABLE t2(x,y); + COMMIT; + PRAGMA integrity_check; + } + } ok +} +ifcapable {integrityck} { + do_test misc3-1.2 { + execsql { + DROP TABLE t1; + DROP TABLE t2; + } + ifcapable {vacuum} {execsql VACUUM} + execsql { + CREATE TABLE t1(a UNIQUE,b); + INSERT INTO t1 VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_'); - UPDATE t1 SET b=b||b; - UPDATE t1 SET b=b||b; - UPDATE t1 SET b=b||b; - UPDATE t1 SET b=b||b; - UPDATE t1 SET b=b||b; - INSERT INTO t1 VALUES(2,'x'); - UPDATE t1 SET b=substr(b,1,500); - BEGIN; - } - catchsql {UPDATE t1 SET a=CASE a WHEN 2 THEN 1 ELSE a END, b='y';} - execsql { - CREATE TABLE t2(x,y); - COMMIT; - PRAGMA integrity_check; - } -} ok -do_test misc3-1.2 { - execsql { - DROP TABLE t1; - DROP TABLE t2; - VACUUM; - CREATE TABLE t1(a UNIQUE,b); - INSERT INTO t1 - VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_'); - INSERT INTO t1 SELECT a+1, b||b FROM t1; - INSERT INTO t1 SELECT a+2, b||b FROM t1; - INSERT INTO t1 SELECT a+4, b FROM t1; - INSERT INTO t1 SELECT a+8, b FROM t1; - INSERT INTO t1 SELECT a+16, b FROM t1; - INSERT INTO t1 SELECT a+32, b FROM t1; - INSERT INTO t1 SELECT a+64, b FROM t1; - - BEGIN; - } - catchsql {UPDATE t1 SET a=CASE a WHEN 128 THEN 127 ELSE a END, b='';} - execsql { - INSERT INTO t1 VALUES(200,'hello out there'); - COMMIT; - PRAGMA integrity_check; - } -} ok + INSERT INTO t1 SELECT a+1, b||b FROM t1; + INSERT INTO t1 SELECT a+2, b||b FROM t1; + INSERT INTO t1 SELECT a+4, b FROM t1; + INSERT INTO t1 SELECT a+8, b FROM t1; + INSERT INTO t1 SELECT a+16, b FROM t1; + INSERT INTO t1 SELECT a+32, b FROM t1; + INSERT INTO t1 SELECT a+64, b FROM t1; + BEGIN; + } + catchsql {UPDATE t1 SET a=CASE a WHEN 128 THEN 127 ELSE a END, b='';} + execsql { + INSERT INTO t1 VALUES(200,'hello out there'); + COMMIT; + PRAGMA integrity_check; + } + } ok +} # Tests of the sqliteAtoF() function in util.c # @@ -253,6 +258,7 @@ ifcapable {explain} { } {0 {}} } +ifcapable {trigger} { # Ticket #640: vdbe stack overflow with a LIMIT clause on a SELECT inside # of a trigger. # @@ -287,6 +293,7 @@ do_test misc3-7.3 { SELECT count(*) FROM y3; } } 32 +} ;# endif trigger # Ticket #668: VDBE stack overflow occurs when the left-hand side # of an IN expression is NULL and the result is used as an integer, not diff --git a/test/pagesize.test b/test/pagesize.test index ea253531b9..bb984387c3 100644 --- a/test/pagesize.test +++ b/test/pagesize.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. # This file implements tests for the page_size PRAGMA. # -# $Id: pagesize.test,v 1.6 2004/11/03 16:27:02 drh Exp $ +# $Id: pagesize.test,v 1.7 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] @@ -88,9 +88,11 @@ foreach PGSZ {512 2048 4096 8192} { do_test pagesize-2.$PGSZ.3 { file size test.db } [expr {$PGSZ*2}] - do_test pagesize-2.$PGSZ.4 { - execsql {VACUUM} - } {} + ifcapable {vacuum} { + do_test pagesize-2.$PGSZ.4 { + execsql {VACUUM} + } {} + } integrity_check pagesize-2.$PGSZ.5 do_test pagesize-2.$PGSZ.6 { db close @@ -148,17 +150,13 @@ foreach PGSZ {512 2048 4096 8192} { } 192 integrity_check pagesize-2.$PGSZ.14 do_test pagesize-2.$PGSZ.15 { - execsql { - DELETE FROM t1 WHERE rowid%5!=0; - VACUUM; - SELECT count(*) FROM t1; - } + execsql {DELETE FROM t1 WHERE rowid%5!=0} + ifcapable {vacuum} {execsql VACUUM} + execsql {SELECT count(*) FROM t1} } 38 do_test pagesize-2.$PGSZ.16 { - execsql { - DROP TABLE t1; - VACUUM; - } + execsql {DROP TABLE t1} + ifcapable {vacuum} {execsql VACUUM} } {} integrity_check pagesize-2.$PGSZ.17 } diff --git a/test/rowid.test b/test/rowid.test index 64dac527b3..5a0b361387 100644 --- a/test/rowid.test +++ b/test/rowid.test @@ -12,7 +12,7 @@ # focus of this file is testing the magic ROWID column that is # found on all tables. # -# $Id: rowid.test,v 1.16 2004/06/27 21:31:40 drh Exp $ +# $Id: rowid.test,v 1.17 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -368,6 +368,7 @@ do_test rowid-7.8 { } } {2 66 3 111} +ifcapable {trigger} { # Make sure AFTER triggers that do INSERTs do not change the last_insert_rowid. # Ticket #290 # @@ -419,6 +420,17 @@ do_test rowid-8.8 { SELECT rowid, * FROM t4; } } {1 1 2 133 3 134} +} ;# endif trigger + +# If triggers are not enable, simulate their effect for the tests that +# follow. +ifcapable {!trigger} { + execsql { + CREATE TABLE t3(a integer primary key); + INSERT INTO t3 VALUES(123); + INSERT INTO t3 VALUES(124); + } +} # ticket #377: Comparison between integer primiary key and floating point # values. diff --git a/test/vacuum.test b/test/vacuum.test index 3894d17b7d..f8dd56086c 100644 --- a/test/vacuum.test +++ b/test/vacuum.test @@ -11,11 +11,19 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the VACUUM statement. # -# $Id: vacuum.test,v 1.27 2004/11/03 13:59:06 drh Exp $ +# $Id: vacuum.test,v 1.28 2004/11/04 04:42:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl +# If the VACUUM statement is disabled in the current build, skip all +# the tests in this file. +# +ifcapable {!vacuum} { + finish_test + return +} + set fcnt 1 proc cksum {{db db}} { set sql "SELECT name, type, sql FROM sqlite_master ORDER BY name, type"