From 27d258a3ec1cf88e2a9104650bb6221215ea4d76 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 30 Oct 2004 20:23:09 +0000 Subject: [PATCH] Begin adding the ability to remove unused features at compile-time and still have all the tests pass. (CVS 2033) FossilOrigin-Name: 2aa506ccb003a25555b414772002d0130db93052 --- Makefile.in | 2 +- main.mk | 2 +- manifest | 28 +++++++++---------- manifest.uuid | 2 +- src/test1.c | 67 +++++++++++++++++++++++++++++++++++++++++++-- src/vacuum.c | 6 ++-- test/bigfile.test | 3 +- test/date.test | 10 ++++++- test/interrupt.test | 10 ++++--- test/tester.tcl | 18 +++++++++--- test/vacuum.test | 37 ++++++++++++++----------- 11 files changed, 136 insertions(+), 49 deletions(-) diff --git a/Makefile.in b/Makefile.in index 3136476bcf..d1fc8c3d69 100644 --- a/Makefile.in +++ b/Makefile.in @@ -308,7 +308,7 @@ parse.h: parse.c parse.c: $(TOP)/src/parse.y lemon@BUILD_EXEEXT@ cp $(TOP)/src/parse.y . - ./lemon parse.y + ./lemon $(OPTS) parse.y pragma.lo: $(TOP)/src/pragma.c $(HDR) $(LTCOMPILE) $(TCL_FLAGS) -c $(TOP)/src/pragma.c diff --git a/main.mk b/main.mk index e79e0926ba..f2b81ebe0b 100644 --- a/main.mk +++ b/main.mk @@ -277,7 +277,7 @@ parse.h: parse.c parse.c: $(TOP)/src/parse.y lemon cp $(TOP)/src/parse.y . - ./lemon parse.y + ./lemon $(OPTS) parse.y pragma.o: $(TOP)/src/pragma.c $(HDR) $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/pragma.c diff --git a/manifest b/manifest index 8e48e9feba..899192c841 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ -C Move\saffinity.html\sinto\sthe\sattic.\s(CVS\s2032) -D 2004-10-26T16:34:38 -F Makefile.in 52c1cc106cad9148d4b7cb387b458e82dc86b339 +C Begin\sadding\sthe\sability\sto\sremove\sunused\sfeatures\sat\scompile-time\sand\sstill\nhave\sall\sthe\stests\spass.\s(CVS\s2033) +D 2004-10-30T20:23:09 +F Makefile.in 9e90c685d69f09039015a6b1f3b0a48e9738c9e5 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 F VERSION 342b6d5fde93b6d45023e2fee0163dda6464b9d6 @@ -16,7 +16,7 @@ F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826 -F main.mk bf65bb9f839aa8777796c9846816be590a7cd4b0 +F main.mk c7c97f809e5e7897bc843db64f692c7ef9013a92 F mkdll.sh 468d4f41d3ea98221371df4825cfbffbaac4d7e4 F mkopcodec.awk 80311cdeb16d78017cc62e4ad6c6d008e5fe0e17 F mkopcodeh.awk 4090944e4de0a2ccb99aa0083290f73bce4db406 @@ -64,7 +64,7 @@ F src/sqlite.h.in 4f97b5907acfd2a5068cb0cec9d5178816734db7 F src/sqliteInt.h 008c205896a1c531ec6249de20ecfe23c89ae243 F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9 F src/tclsqlite.c 0302e3f42f015d132d1291f3388c06e86c24a008 -F src/test1.c 3d78e5d827bf5d037f697c233c5934d45af46cb5 +F src/test1.c 23fd40832736c46b9c2d897fa13c7d913a3f1626 F src/test2.c b11fa244fff02190707dd0879987c37c75e61fc8 F src/test3.c 5b5b0f3d11b097399c1054fff73d8f3711092301 F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df @@ -74,7 +74,7 @@ F src/trigger.c b51a120d53e8b85359be11bf5e50854e5725fe3d F src/update.c 174c3b593b8f4928e510a51ec309e8ce69d2371c F src/utf.c f4f83acd73389090e32d6589d307fc55d794c7ed F src/util.c f4ab796b9def353feed2191d7ce8e39a0f5059cd -F src/vacuum.c 257de36230cb988842f66eb08dc6c0250b8e05f3 +F src/vacuum.c ecb4a2c6f1ac5cc9b394dc64d3bb14ca650c4f60 F src/vdbe.c adbcdbc817ae2f411904cd12582f06fc1ca8be1e F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181 F src/vdbeInt.h 6017100adff362b8dfa37a69e3f1431f084bfa5b @@ -87,7 +87,7 @@ F test/attach.test feb2ce54e78688df4c84553416d5aec3b2a0112e F test/attach2.test f7795123d3051ace1672b6d23973da6435de3745 F test/attach3.test 6d060986ff004ebb89e1876a331d96c6bb62269e F test/auth.test 1cc252d9e7b3bdc1314199cbf3a0d3c5ed026c21 -F test/bigfile.test 62722ac4b420dfbcdceb137b8634e2cf2865fe27 +F test/bigfile.test d3744a8821ce9abb8697f2826a3e3d22b719e89f F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747 F test/bind.test a8682ba41433b93bb36a4213a43f282ca9aec5a9 F test/blob.test 8727a7b46b2073a369cfc9bcb6f54dd366b9d884 @@ -110,7 +110,7 @@ F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87 F test/corrupt.test 0080ddcece23e8ba47c44608c4fb73fd4d1d8ce2 F test/crash.test a3f6d27f7cb7f7bd752461db1e14f7c781ecedc3 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 -F test/date.test fd3db29bba089578b1b008e3511ea9e74840377a +F test/date.test b4f8bb8e3e3ee6eb3efa1ccef47cfe206dafe4b8 F test/delete.test ec0b455f2dcc0e189d96ee438438ba026c4e51d8 F test/delete2.test 050a3a6e8ea0f83aed817d164b16af2a499fb452 F test/diskfull.test e2f6cfd868713ead06dc82b84a4938e868128fc0 @@ -125,7 +125,7 @@ F test/in.test b92a2df9162e1cbd33c6449a29a05e6955b1741a F test/index.test 31ed90af028d1ec9a3a8a4f0d7021717ba05dd16 F test/insert.test ebbab63db4ad69395a058514bccb3cdb0a029d48 F test/insert2.test 614a29d3ed7dd0d8644a059c6d8ce742c63a734a -F test/interrupt.test 9142ce4448605127640eda5e283952f75f67ed91 +F test/interrupt.test 6b6b8b86cdeb66d5488bd1db74b4bb3c46e4f565 F test/intpkey.test 3956a34cc82374821a017cf1646c9ff32f5e3c81 F test/ioerr.test 3ce897ee998ee874073f3b23b0396d9ff804759c F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd @@ -174,7 +174,7 @@ F test/table.test fd9a0f4992230e4ca89cd37ae3191a12750df1d0 F test/tableapi.test b21ab097e87a5484bb61029e69e1a4e5c5e65ede F test/tclsqlite.test 1288e6278e094c58ce650d7cbf3c4f39317d9a34 F test/temptable.test 63a16e3ad19adf073cfbcdf7624c92ac5236522c -F test/tester.tcl 1ff1170dd4203d87f572871080cdb64330dade99 +F test/tester.tcl 6dd72b79878a1b7076156cd1f0e674415dd91bc6 F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35 F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b F test/threadtest2.c 97a830d53c24c42290501fdfba4a6e5bdd34748b @@ -190,7 +190,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 6bce0f84fff255b943abed3b345c9e0ce287e2b6 +F test/vacuum.test 05959d8e6caf26d4d06cae19df49c41a4991676d F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/view.test ca5c296989d3045f121be9a67588ff88c64874a8 F test/where.test 40dcffcb77ad0a00960cef2b5b1212c77fd02199 @@ -251,7 +251,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c -P 09de96b6b2e877282be0815ba76c10f18839ff6b -R c872ef25d669a1ccc74408d414b2bed5 +P 87a3c668f0dcd43f5d9b38d92a75a4ac38d49057 +R 7ce19f5cec69820ac47d8f047cf87ee1 U drh -Z 3519d7ca392cdf8d6ad112e35ee57148 +Z 49adbf5abf742ee3280084694fca0270 diff --git a/manifest.uuid b/manifest.uuid index 0a2f092056..7f381d9122 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87a3c668f0dcd43f5d9b38d92a75a4ac38d49057 \ No newline at end of file +2aa506ccb003a25555b414772002d0130db93052 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index 77230b8c95..0c9d16d184 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.104 2004/09/30 13:43:13 drh Exp $ +** $Id: test1.c,v 1.105 2004/10/30 20:23:09 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -2467,6 +2467,69 @@ static int tcl_variable_type( return TCL_OK; } +/* +** This routine sets entries in the global ::sqlite_options() array variable +** according to the compile-time configuration of the database. Test +** procedures use this to determine when tests should be omitted. +*/ +static void set_options(Tcl_Interp *interp){ +#ifdef SQLITE_OMIT_AUTHORIZATION + Tcl_SetVar2(interp, "sqlite_options", "auth", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "auth", "1", TCL_GLOBAL_ONLY); +#endif +#ifdef SQLITE_OMIT_VACUUM + Tcl_SetVar2(interp, "sqlite_options", "vacuum", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "vacuum", "1", TCL_GLOBAL_ONLY); +#endif +#ifdef SQLITE_OMIT_PROGRESS_CALLBACK + Tcl_SetVar2(interp, "sqlite_options", "progress", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "progress", "1", TCL_GLOBAL_ONLY); +#endif +#ifdef SQLITE_OMIT_DATETIME_FUNCS + Tcl_SetVar2(interp, "sqlite_options", "datetime", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "datatime", "1", TCL_GLOBAL_ONLY); +#endif +#if defined(THREADSAFE) && THREADSAFE + Tcl_SetVar2(interp, "sqlite_options", "threadsafe", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "threadsafe", "0", TCL_GLOBAL_ONLY); +#endif +#ifdef SQLITE_OMIT_COMPOUND_SELECT + Tcl_SetVar2(interp, "sqlite_options", "compound", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "compound", "1", TCL_GLOBAL_ONLY); +#endif +#ifdef SQLITE_OMIT_TRIGGER + Tcl_SetVar2(interp, "sqlite_options", "trigger", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "trigger", "1", TCL_GLOBAL_ONLY); +#endif +#ifdef SQLITE_OMIT_VIEW + Tcl_SetVar2(interp, "sqlite_options", "view", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "view", "1", TCL_GLOBAL_ONLY); +#endif +#ifdef SQLITE_OMIT_INTEGRITY_CHECK + Tcl_SetVar2(interp, "sqlite_options", "integrityck", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "integrityck", "1", TCL_GLOBAL_ONLY); +#endif +#ifdef SQLITE_OMIT_FOREIGN_KEY + Tcl_SetVar2(interp, "sqlite_options", "foreignkey", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "foreignkey", "1", TCL_GLOBAL_ONLY); +#endif +#ifdef SQLITE_OMIT_CONFLICT_CLAUSE + Tcl_SetVar2(interp, "sqlite_options", "conflict", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "conflict", "1", TCL_GLOBAL_ONLY); +#endif +} + /* ** Register commands with the TCL interpreter. */ @@ -2563,7 +2626,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_crashparams", sqlite3_crashparams, 0 }, { "sqlite3_test_errstr", test_errstr, 0 }, { "tcl_variable_type", tcl_variable_type, 0 }, - }; int i; extern int sqlite3_os_trace; @@ -2589,5 +2651,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ (char*)&sqlite_static_bind_value, TCL_LINK_STRING); Tcl_LinkVar(interp, "sqlite_temp_directory", (char*)&sqlite3_temp_directory, TCL_LINK_STRING); + set_options(interp); return TCL_OK; } diff --git a/src/vacuum.c b/src/vacuum.c index 7bb8328bdb..99e30bd47a 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -14,12 +14,12 @@ ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** -** $Id: vacuum.c,v 1.32 2004/09/17 20:02:42 drh Exp $ +** $Id: vacuum.c,v 1.33 2004/10/30 20:23:09 drh Exp $ */ #include "sqliteInt.h" #include "os.h" -#if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM +#ifndef SQLITE_OMIT_VACUUM /* ** Generate a random name of 20 character in length. */ @@ -93,7 +93,7 @@ void sqlite3Vacuum(Parse *pParse, Token *pTableName){ */ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ int rc = SQLITE_OK; /* Return code from service routines */ -#if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM +#ifndef SQLITE_OMIT_VACUUM const char *zFilename; /* full pathname of the database file */ int nFilename; /* number of characters in zFilename[] */ char *zTemp = 0; /* a temporary file in same directory as zFilename */ diff --git a/test/bigfile.test b/test/bigfile.test index 0ff8b5df2c..ccaf6f4c52 100644 --- a/test/bigfile.test +++ b/test/bigfile.test @@ -12,7 +12,7 @@ # focus of this script testing the ability of SQLite to handle database # files larger than 4GB. # -# $Id: bigfile.test,v 1.6 2004/06/30 11:28:13 drh Exp $ +# $Id: bigfile.test,v 1.7 2004/10/30 20:23:09 drh Exp $ # set testdir [file dirname $argv0] @@ -71,7 +71,6 @@ do_test bigfile-1.2 { } } $::MAGIC_SUM - # The previous test may fail on some systems because they are unable # to handle large files. If that is so, then skip all of the following # tests. We will know the above test failed because the "db" command diff --git a/test/date.test b/test/date.test index 2e96b5ea58..a234e7a082 100644 --- a/test/date.test +++ b/test/date.test @@ -11,11 +11,19 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing date and time functions. # -# $Id: date.test,v 1.9 2004/08/20 18:34:20 drh Exp $ +# $Id: date.test,v 1.10 2004/10/30 20:23:10 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl +# Skip this whole file if date and time functions are omitted +# at compile-time +# +if {!$sqlite_options(datetime)} { + finish_test + return +} + proc datetest {tnum expr result} { do_test date-$tnum [subst { execsql "SELECT coalesce($expr,'NULL')" diff --git a/test/interrupt.test b/test/interrupt.test index 456cf48a17..3860ea897d 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.4 2004/02/18 16:57:23 drh Exp $ +# $Id: interrupt.test,v 1.5 2004/10/30 20:23:10 drh Exp $ set testdir [file dirname $argv0] @@ -100,9 +100,11 @@ do_test interrupt-2.3 { SELECT md5sum(a || b) FROM t1; } } $cksum -do_test interrupt-2.4 { - expr {$::origsize>[file size test.db]} -} 1 +ifcapable vacuum { + do_test interrupt-2.4 { + expr {$::origsize>[file size test.db]} + } 1 +} integrity_check interrupt-2.5 # Ticket #594. If an interrupt occurs in the middle of a transaction diff --git a/test/tester.tcl b/test/tester.tcl index 7c47e1771d..c919e21ce3 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -11,7 +11,7 @@ # This file implements some common TCL routines used for regression # testing the SQLite library # -# $Id: tester.tcl,v 1.38 2004/08/20 18:34:20 drh Exp $ +# $Id: tester.tcl,v 1.39 2004/10/30 20:23:10 drh Exp $ # Make sure tclsqlite3 was compiled correctly. Abort now with an # error message if not. @@ -230,7 +230,17 @@ proc forcedelete {filename} { # Do an integrity check of the entire database # proc integrity_check {name} { - do_test $name { - execsql {PRAGMA integrity_check} - } {ok} + ifcapable integrityck { + do_test $name { + execsql {PRAGMA integrity_check} + } {ok} + } +} + +# Evaluate a boolean expression of capabilities. If true, execute the +# code. Omit the code if false. +# +proc ifcapable {expr code} { + regsub -all {[a-z]+} $expr {$::sqlite_options(&)} e2 + if $e2 {uplevel 1 $code} } diff --git a/test/vacuum.test b/test/vacuum.test index 9fc538e181..54ce72487a 100644 --- a/test/vacuum.test +++ b/test/vacuum.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the VACUUM statement. # -# $Id: vacuum.test,v 1.25 2004/09/02 15:27:42 drh Exp $ +# $Id: vacuum.test,v 1.26 2004/10/30 20:23:10 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -67,9 +67,11 @@ do_test vacuum-1.2 { } cksum } $cksum -do_test vacuum-1.3 { - expr {[file size test.db]<$::size1} -} {1} +ifcapable vacuum { + do_test vacuum-1.3 { + expr {[file size test.db]<$::size1} + } {1} +} do_test vacuum-1.4 { execsql { BEGIN; @@ -92,18 +94,21 @@ do_test vacuum-1.5 { } cksum } $cksum -do_test vacuum-1.6 { - expr {[file size test.db]<$::size1} -} {1} - -do_test vacuum-2.1 { - catchsql { - BEGIN; - VACUUM; - COMMIT; - } -} {1 {cannot VACUUM from within a transaction}} -catch {db eval COMMIT} +ifcapable vacuum { + do_test vacuum-1.6 { + expr {[file size test.db]<$::size1} + } {1} +} +ifcapable vacuum { + do_test vacuum-2.1 { + catchsql { + BEGIN; + VACUUM; + COMMIT; + } + } {1 {cannot VACUUM from within a transaction}} + catch {db eval COMMIT} +} do_test vacuum-2.2 { sqlite3 db2 test.db execsql {