diff --git a/main.mk b/main.mk index e8fe510535..a194c48af8 100644 --- a/main.mk +++ b/main.mk @@ -54,7 +54,7 @@ TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src # Object files for the SQLite library. # -LIBOBJ = attach.o auth.o btree.o build.o date.o delete.o \ +LIBOBJ+= attach.o auth.o btree.o build.o date.o delete.o \ expr.o func.o hash.o insert.o \ main.o opcodes.o os_mac.o os_unix.o os_win.o \ pager.o parse.o pragma.o printf.o random.o \ diff --git a/manifest b/manifest index eee4fd8ec8..f7198895fe 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sin\ssupport\sof\susing\sa\scodec.\s(CVS\s1845) -D 2004-07-22T02:40:39 +C Fix\sbugs\sassociated\swith\sthe\scodec.\s(CVS\s1846) +D 2004-07-22T15:02:25 F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -17,7 +17,7 @@ F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826 -F main.mk 1fabb57eba6c25d98ec8a2127850673f2425c458 +F main.mk 1957885390af52f5a69679bb43ec4cd8904c7a9f F mkdll.sh 68d34a961a1fdfa15ef27fc4f4740be583112124 F publish.sh 73703b55b590a7b7ee305b05445a424ec47be29e F spec.template b2f6c4e488cbc3b993a57deba22cbc36203c4da3 @@ -25,7 +25,7 @@ F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2 F sqlite3.def 7610bb4092dcfa7db8fe6d9a92d3e51adce23566 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a -F src/attach.c 2e5d8eae9c08d15ee92ec0d831faeeda996d1a95 +F src/attach.c 784456629b3d7e50e4691f496700658fd1f16441 F src/auth.c 60db23b98bb94c8b0178180faaf49dc116674217 F src/btree.c 9f1727185200c5b9488f3e99a1bdb250f841c876 F src/btree.h fab5e800b5d91a5700c0b344d711b98de6f7ad0e @@ -51,19 +51,19 @@ F src/os_unix.c 02a08065f90ca2737514cdc19d60eb3c4b98fa6b F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13 F src/os_win.c 54181eb73cb4783c4241feca9eaa490768b39008 F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44 -F src/pager.c 1354e8f80889a8c967f4bc4ee2723485624eb6e7 +F src/pager.c e0865a9afa64f59c6dc1cc1ab50bc700f67ee28b F src/pager.h 67739fe649f33be55dba522ca8a9cc4e42d14f71 -F src/parse.y 1c22ccb2b60237a7263873892a4d580ea5e53536 +F src/parse.y 0bcc53bba498081a544e50c8845bf4857ebfccb9 F src/pragma.c c8be18093f0492f9983406647808781ca0073d8b F src/printf.c 36090f6d7b4946539de97c1850675ce55ef66c16 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/select.c aefda626660086addca4ce85c34aeef5d0f44c25 F src/shell.c 93c96c847228c02fb84bb381875d87ee71fbbeb4 F src/sqlite.h.in 80de11cde2c9f78eff4dab0aad1eb5196d6e2a3f -F src/sqliteInt.h 17ed61c040c1e47e1dd660daef3adda9ea9cb4fb +F src/sqliteInt.h 049cb4f716f7b7ea3657f26c7e26a4f821aca53c F src/table.c 4521c278892f60e4d630788c0ea5cf4db1e75c49 F src/tclsqlite.c 8652b55cac11dc1025cd4a336180330ebade3cd7 -F src/test1.c 004885b49a7b5a594192f137c671135920f64c94 +F src/test1.c ef00096c283ccfec1b2ae5fdaccb85fb06e24281 F src/test2.c f4c2f3928f1998fd8cb75a81e33a60e025ea85d4 F src/test3.c 8576bb977937265e2c1a4d3fab3793e1974153e8 F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2 @@ -97,7 +97,7 @@ F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2 F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027 F test/btree7.test 429b96cfef5b51a7d512cfb4b5b3e453384af293 F test/capi2.test 78f2c486689fcc80394a24c2cc32725330ab6299 -F test/capi3.test 85c4445cd9bd1fa0cd9d8af56a4fae361b57c553 +F test/capi3.test e2d47b59c1ca5be2e5986fb77f716a7fdd228e25 F test/collate1.test 2ee4fa3a47a652ccf56c5ddf65dcc44d9bad82ef F test/collate2.test c1a3b41f761b28853c5696037f92de928f93233b F test/collate3.test e60b428e07ec945492ba90ff1c895902ee3a8a50 @@ -131,7 +131,7 @@ F test/lastinsert.test 31382f88b9b0270333ac9e4a17f2c2f4732da718 F test/laststmtchanges.test 417aa27eb2b5cdfafb46e390e2c9ddd0a20eba43 F test/limit.test e4ee72ab4869992950f8cfce256e04a0a2a98b23 F test/lock.test 1dbf1d06b0a7eb36237b4f107cfb3da9726b449e -F test/lock2.test 4108cabaa108a142e5eed83de3b13b6e579c12cf +F test/lock2.test 2213590d442147d09fd2334c905a755586c1c398 F test/main.test e8c4d9ca6d1e5f5e55e6550d31aec488883b2ed9 F test/malloc.test 769b240d89a7ef3320d88919fdb6765f9395a51f F test/memdb.test b8a13fa79f006bd087bbcf135ce8eb62056a6027 @@ -146,10 +146,10 @@ F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0 F test/null.test c14d0f4739f21e929b8115b72bf0c765b6bb1721 F test/pager.test 059cc5c58d3b5a851343dff8c56cf7286425d03a F test/pager2.test 55469c7c1c1a54d6b32d7b3cc99001e90101a1ce -F test/pragma.test 212d810e02a51c0ff9784a19d55e35d23382005d +F test/pragma.test f7414c1d902688825ca11f7f5e03628704d903b5 F test/printf.test 428ad9be92963b68ba222dac4c19724cc4e304ea F test/progress.test 76c722f090b1ccb575e7e4e203a71608c5763beb x -F test/quick.test 62cd0e248b3128c3e900d11d99c550aaec41db5f +F test/quick.test 5bb4afdb204c57329c86fa11f3f0a5296675fd7f F test/quote.test 08f23385c685d3dc7914ec760d492cacea7f6e3d F test/rollback.test 4097328d44510277244ef4fa51b22b2f11d7ef4c F test/rowid.test b3d059f5c8d8874fa1c31030e0636f67405d20ea @@ -175,7 +175,7 @@ F test/trigger1.test dc015c410161f1a6109fd52638dfac852e2a34de F test/trigger2.test 0767ab30cb5a2c8402c8524f3d566b410b6f5263 F test/trigger3.test 70931be83fa3f563f7a5ca9e88b86f476af73948 F test/trigger4.test 97c11d3cf43d752b172809bb82536372ee5e399c -F test/types.test fdf7920c9d3aabbba25c11daa48c872d1870bce9 +F test/types.test db5483a8dc5c8fadc737c3ab36d9cbd96ba25e14 F test/types2.test f23c147a2ab3e51d5dbcfa9987200db5acba7aa7 F test/unique.test 0e38d4cc7affeef2527720d1dafd1f6870f02f2b F test/update.test b29bd9061a1150426dab6959806fcc73a41b1217 @@ -237,7 +237,7 @@ F www/tclsqlite.tcl 06a86cba4d7fc88e2bcd633b57702d3d16abebb5 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P b77bec35742f07d79da3e85baee09a90c1494415 -R 3e3f31107533fb8a64f00d1c99d78fca +P 58505bf9be8e7f9d33a7a52f0d2ac167448f7b3a +R f3db447534ed74e51b726af7a9dab6bc U drh -Z 0ca92d2eb65daa15aadbbce8e6c55b3b +Z b2bfc42df168bf93298aa49508a9d11e diff --git a/manifest.uuid b/manifest.uuid index 8263fe8859..ba95a9d5f8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58505bf9be8e7f9d33a7a52f0d2ac167448f7b3a \ No newline at end of file +b0a3becd82b9a4203c23f35dc5a5fd725e046f21 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index cd36936daf..4fa844776d 100644 --- a/src/attach.c +++ b/src/attach.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the ATTACH and DETACH commands. ** -** $Id: attach.c,v 1.24 2004/07/22 02:40:38 drh Exp $ +** $Id: attach.c,v 1.25 2004/07/22 15:02:25 drh Exp $ */ #include "sqliteInt.h" @@ -23,7 +23,13 @@ ** The pFilename and pDbname arguments are the tokens that define the ** filename and dbname in the ATTACH statement. */ -void sqlite3Attach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey){ +void sqlite3Attach( + Parse *pParse, /* The parser context */ + Token *pFilename, /* Name of database file */ + Token *pDbname, /* Name of the database to use internally */ + int keyType, /* 0: no key. 1: TEXT, 2: BLOB */ + Token *pKey /* Text of the key for keytype 2 and 3 */ +){ Db *aNew; int rc, i; char *zFile, *zName; @@ -91,14 +97,32 @@ void sqlite3Attach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey) sqlite3ErrorMsg(pParse, "unable to open database: %s", zFile); } #if SQLITE_HAS_CODEC - assert( pKey!=0 ); - if( pKey->n>0 ){ - extern int sqlite3CodecAttach(sqlite*, int, void*, int); - char *zKey = 0; + { + extern int sqlite3CodecAttach(sqlite3*, int, void*, int); + char *zKey; int nKey; + if( keyType==0 ){ + /* No key specified. Use the key from the main database */ + extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*); + sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey); + }else if( keyType==1 ){ + /* Key specified as text */ + zKey = sqlite3NameFromToken(pKey); + nKey = strlen(zKey); + }else{ + /* Key specified as a BLOB */ + char *zTemp; + assert( keyType==2 ); + pKey->z++; + pKey->n--; + zTemp = sqlite3NameFromToken(pKey); + zKey = sqlite3HexToBlob(zTemp); + sqliteFree(zTemp); + } sqlite3CodecAttach(db, db->nDb-1, zKey, nKey); - zKey = sqlite3NameFromToken(pKey); - nKey = strlen(zKey); + if( keyType ){ + sqliteFree(zKey); + } } #endif sqliteFree(zFile); diff --git a/src/pager.c b/src/pager.c index fc7bce9ede..36445b4265 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.152 2004/07/22 01:19:35 drh Exp $ +** @(#) $Id: pager.c,v 1.153 2004/07/22 15:02:25 drh Exp $ */ #include "os.h" /* Must be first to enable large file support */ #include "sqliteInt.h" @@ -1001,8 +1001,8 @@ static int pager_reload_cache(Pager *pPager){ sqlite3OsSeek(&pPager->fd, pPager->pageSize*(off_t)(pPg->pgno-1)); rc = sqlite3OsRead(&pPager->fd, zBuf, pPager->pageSize); TRACE2("REFETCH page %d\n", pPg->pgno); - CODEC(pPager, zBuf, pPg->pgno, 2); if( rc ) break; + CODEC(pPager, zBuf, pPg->pgno, 2); }else{ memset(zBuf, 0, pPager->pageSize); } @@ -2516,12 +2516,13 @@ int sqlite3pager_write(void *pData){ } pPg->inJournal = 1; }else{ - u32 cksum = pager_cksum(pPager, pPg->pgno, pData); + u32 cksum; + CODEC(pPager, pData, pPg->pgno, 7); + cksum = pager_cksum(pPager, pPg->pgno, pData); saved = *(u32*)PGHDR_TO_EXTRA(pPg, pPager); store32bits(cksum, pPg, pPager->pageSize); szPg = pPager->pageSize+8; store32bits(pPg->pgno, pPg, -4); - CODEC(pPager, pData, pPg->pgno, 7); rc = sqlite3OsWrite(&pPager->jfd, &((char*)pData)[-4], szPg); pPager->journalOff += szPg; TRACE3("JOURNAL page %d needSync=%d\n", pPg->pgno, pPg->needSync); diff --git a/src/parse.y b/src/parse.y index 260e0f2073..efb242045d 100644 --- a/src/parse.y +++ b/src/parse.y @@ -14,7 +14,7 @@ ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** -** @(#) $Id: parse.y,v 1.130 2004/07/20 14:06:52 drh Exp $ +** @(#) $Id: parse.y,v 1.131 2004/07/22 15:02:25 drh Exp $ */ %token_prefix TK_ %token_type {Token} @@ -54,6 +54,11 @@ struct LimitVal { */ struct TrigEvent { int a; IdList * b; }; +/* +** An instance of this structure holds the ATTACH key and the key type. +*/ +struct AttachKey { int type; Token key; }; + } // end %include // These are extra tokens used by the lexer but never seen by the @@ -893,11 +898,14 @@ cmd ::= DROP TRIGGER nm(X) dbnm(D). { //////////////////////// ATTACH DATABASE file AS name ///////////////////////// cmd ::= ATTACH database_kw_opt ids(F) AS nm(D) key_opt(K). { - sqlite3Attach(pParse, &F, &D, &K); + sqlite3Attach(pParse, &F, &D, K.type, &K.key); } -%type key_opt {Token} -key_opt(A) ::= USING ids(X). { A = X; } -key_opt(A) ::= . { A.z = 0; A.n = 0; } +%type key_opt {struct AttachKey} +key_opt(A) ::= . { A.type = 0; } +%ifdef SQLITE_HAS_CODEC +key_opt(A) ::= KEY ids(X). { A.type=1; A.key = X; } +key_opt(A) ::= KEY BLOB(X). { A.type=2; A.Key = X; } +%endif database_kw_opt ::= DATABASE. database_kw_opt ::= . diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 1db96f2b78..d6cde4e5e5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.307 2004/07/22 01:19:35 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.308 2004/07/22 15:02:25 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -1330,7 +1330,7 @@ void sqlite3DeferForeignKey(Parse*, int); # define sqlite3AuthContextPush(a,b,c) # define sqlite3AuthContextPop(a) ((void)(a)) #endif -void sqlite3Attach(Parse*, Token*, Token*, Token*); +void sqlite3Attach(Parse*, Token*, Token*, int, Token*); void sqlite3Detach(Parse*, Token*); int sqlite3BtreeFactory(const sqlite *db, const char *zFilename, int omitJournal, int nCache, Btree **ppBtree); diff --git a/src/test1.c b/src/test1.c index 852a1649f0..61758fcd11 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.94 2004/07/17 21:56:10 drh Exp $ +** $Id: test1.c,v 1.95 2004/07/22 15:02:26 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -304,6 +304,62 @@ static int test_last_rowid( return SQLITE_OK; } +/* +** Usage: sqlite3_key DB KEY +** +** Set the codec key. +*/ +static int test_key( + void *NotUsed, + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int argc, /* Number of arguments */ + char **argv /* Text of each argument */ +){ + sqlite *db; + const char *zKey; + int nKey; + if( argc!=3 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], + " FILENAME\"", 0); + return TCL_ERROR; + } + if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; + zKey = argv[2]; + nKey = strlen(zKey); +#ifdef SQLITE_HAS_CODEC + sqlite3_key(db, zKey, nKey); +#endif + return TCL_OK; +} + +/* +** Usage: sqlite3_rekey DB KEY +** +** Change the codec key. +*/ +static int test_rekey( + void *NotUsed, + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int argc, /* Number of arguments */ + char **argv /* Text of each argument */ +){ + sqlite *db; + const char *zKey; + int nKey; + if( argc!=3 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], + " FILENAME\"", 0); + return TCL_ERROR; + } + if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; + zKey = argv[2]; + nKey = strlen(zKey); +#ifdef SQLITE_HAS_CODEC + sqlite3_rekey(db, zKey, nKey); +#endif + return TCL_OK; +} + /* ** Usage: sqlite3_close DB ** @@ -2328,8 +2384,10 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite_malloc_fail", (Tcl_CmdProc*)sqlite_malloc_fail }, { "sqlite_malloc_stat", (Tcl_CmdProc*)sqlite_malloc_stat }, #endif - { "sqlite_bind", (Tcl_CmdProc*)test_bind }, - { "breakpoint", (Tcl_CmdProc*)test_breakpoint }, + { "sqlite_bind", (Tcl_CmdProc*)test_bind }, + { "breakpoint", (Tcl_CmdProc*)test_breakpoint }, + { "sqlite3_key", (Tcl_CmdProc*)test_key }, + { "sqlite3_rekey", (Tcl_CmdProc*)test_rekey }, }; static struct { char *zName; diff --git a/test/capi3.test b/test/capi3.test index a595bff52a..1d8f5d550f 100644 --- a/test/capi3.test +++ b/test/capi3.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # -# $Id: capi3.test,v 1.19 2004/06/30 06:30:26 danielk1977 Exp $ +# $Id: capi3.test,v 1.20 2004/07/22 15:02:26 drh Exp $ # set testdir [file dirname $argv0] @@ -443,6 +443,7 @@ db close do_test capi3-6.0 { set DB [sqlite3_open test.db] + sqlite3_key $DB xyzzy set sql {SELECT a FROM t1 order by rowid} set STMT [sqlite3_prepare $DB $sql -1 TAIL] expr 0 @@ -461,87 +462,93 @@ do_test capi3-6.4 { sqlite3_close $DB } {SQLITE_OK} -# Test what happens when the library encounters a newer file format. -# Do this by updating the file format via the btree layer. -do_test capi3-7.1 { - set ::bt [btree_open test.db 10 0] - btree_begin_transaction $::bt - set meta [btree_get_meta $::bt] - lset meta 2 2 - eval [concat btree_update_meta $::bt [lrange $meta 0 end]] - btree_commit $::bt - btree_close $::bt -} {} -do_test capi3-7.2 { - sqlite3 db test.db -breakpoint - catchsql { - SELECT * FROM sqlite_master; - } -} {1 {unsupported file format}} - -# Now test that the library correctly handles bogus entries in the -# sqlite_master table (schema corruption). -do_test capi3-8.1 { +if {![sqlite3 -has-codec]} { + # Test what happens when the library encounters a newer file format. + # Do this by updating the file format via the btree layer. + do_test capi3-7.1 { + set ::bt [btree_open test.db 10 0] + btree_begin_transaction $::bt + set meta [btree_get_meta $::bt] + lset meta 2 2 + eval [concat btree_update_meta $::bt [lrange $meta 0 end]] + btree_commit $::bt + btree_close $::bt + } {} + do_test capi3-7.2 { + sqlite3 db test.db + catchsql { + SELECT * FROM sqlite_master; + } + } {1 {unsupported file format}} db close - file delete -force test.db - sqlite3 db test.db - execsql { - CREATE TABLE t1(a); - } +} + +if {![sqlite3 -has-codec]} { + # Now test that the library correctly handles bogus entries in the + # sqlite_master table (schema corruption). + do_test capi3-8.1 { + file delete -force test.db + file delete -force test.db-journal + sqlite3 db test.db + execsql { + CREATE TABLE t1(a); + } + db close + } {} + do_test capi3-8.2 { + set ::bt [btree_open test.db 10 0] + btree_begin_transaction $::bt + set ::bc [btree_cursor $::bt 1 1] + + # Build a 5-field row record consisting of 5 null records. This is + # officially black magic. + catch {unset data} + set data [binary format c6 {6 0 0 0 0 0}] + btree_insert $::bc 5 $data + + btree_close_cursor $::bc + btree_commit $::bt + btree_close $::bt + } {} + do_test capi3-8.3 { + sqlite3 db test.db + catchsql { + SELECT * FROM sqlite_master; + } + } {1 {malformed database schema}} + do_test capi3-8.4 { + set ::bt [btree_open test.db 10 0] + btree_begin_transaction $::bt + set ::bc [btree_cursor $::bt 1 1] + + # Build a 5-field row record. The first field is a string 'table', and + # subsequent fields are all NULL. Replace the other broken record with + # this one and try to read the schema again. The broken record uses + # either UTF-8 or native UTF-16 (if this file is being run by + # utf16.test). + if { [string match UTF-16* $::ENC] } { + set data [binary format c6a10 {6 33 0 0 0 0} [utf16 table]] + } else { + set data [binary format c6a5 {6 23 0 0 0 0} table] + } + btree_insert $::bc 5 $data + + btree_close_cursor $::bc + btree_commit $::bt + btree_close $::bt + } {} + do_test capi3-8.5 { + db close + sqlite3 db test.db + catchsql { + SELECT * FROM sqlite_master; + } + } {1 {malformed database schema}} db close -} {} -do_test capi3-8.2 { - set ::bt [btree_open test.db 10 0] - btree_begin_transaction $::bt - set ::bc [btree_cursor $::bt 1 1] - - # Build a 5-field row record consisting of 5 null records. This is - # officially black magic. - catch {unset data} - set data [binary format c6 {6 0 0 0 0 0}] - btree_insert $::bc 5 $data - - btree_close_cursor $::bc - btree_commit $::bt - btree_close $::bt -} {} -do_test capi3-8.3 { - sqlite3 db test.db - catchsql { - SELECT * FROM sqlite_master; - } -} {1 {malformed database schema}} -do_test capi3-8.4 { - set ::bt [btree_open test.db 10 0] - btree_begin_transaction $::bt - set ::bc [btree_cursor $::bt 1 1] - - # Build a 5-field row record. The first field is a string 'table', and - # subsequent fields are all NULL. Replace the other broken record with - # this one and try to read the schema again. The broken record uses - # either UTF-8 or native UTF-16 (if this file is being run by - # utf16.test). - if { [string match UTF-16* $::ENC] } { - set data [binary format c6a10 {6 33 0 0 0 0} [utf16 table]] - } else { - set data [binary format c6a5 {6 23 0 0 0 0} table] - } - btree_insert $::bc 5 $data - - btree_close_cursor $::bc - btree_commit $::bt - btree_close $::bt -} {} -do_test capi3-8.5 { - db close - sqlite3 db test.db - catchsql { - SELECT * FROM sqlite_master; - } -} {1 {malformed database schema}} -db close +} file delete -force test.db +file delete -force test.db-journal + # Test the english language string equivalents for sqlite error codes set code2english [list \ @@ -761,4 +768,3 @@ do_test capi3-12.8 { finish_test - diff --git a/test/lock2.test b/test/lock2.test index 317f5f4d4c..ea5923a182 100644 --- a/test/lock2.test +++ b/test/lock2.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is database locks between competing processes. # -# $Id: lock2.test,v 1.2 2004/06/28 11:52:46 drh Exp $ +# $Id: lock2.test,v 1.3 2004/07/22 15:02:26 drh Exp $ set testdir [file dirname $argv0] @@ -89,7 +89,7 @@ close $f do_test lock2-1.1 { set ::tf1 [launch_testfixture] testfixture $::tf1 { - sqlite3 db test.db + sqlite3 db test.db -key xyzzy db eval {select * from sqlite_master} } } {} diff --git a/test/pragma.test b/test/pragma.test index 04704f016a..9cea4c0c5c 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -12,7 +12,7 @@ # # This file implements tests for the PRAGMA command. # -# $Id: pragma.test,v 1.15 2004/06/26 19:35:30 drh Exp $ +# $Id: pragma.test,v 1.16 2004/07/22 15:02:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -207,7 +207,8 @@ do_test pragma-2.4 { # Construct a corrupted index and make sure the integrity_check # pragma finds it. # -if {![sqlite3 -has-codec]} { +# These tests won't work if the database is encrypted +# do_test pragma-3.1 { execsql { BEGIN; @@ -219,19 +220,19 @@ do_test pragma-3.1 { SELECT rowid, * from t2; } } {1 11 2 3 2 22 3 4} -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] - btree_first $c - btree_delete $c - btree_commit $db - btree_close $db - execsql {PRAGMA integrity_check} -} {{rowid 1 missing from index i2} {wrong # of entries in index i2}} -}; # endif has-codec - +if {![sqlite3 -has-codec]} { + 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] + btree_first $c + btree_delete $c + btree_commit $db + btree_close $db + execsql {PRAGMA integrity_check} + } {{rowid 1 missing from index i2} {wrong # of entries in index i2}} +} do_test pragma-3.3 { execsql { DROP INDEX i2; diff --git a/test/quick.test b/test/quick.test index c9757e1038..4857daf3bf 100644 --- a/test/quick.test +++ b/test/quick.test @@ -10,7 +10,7 @@ #*********************************************************************** # This file runs all tests. # -# $Id: quick.test,v 1.27 2004/07/19 00:39:46 drh Exp $ +# $Id: quick.test,v 1.28 2004/07/22 15:02:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -25,18 +25,13 @@ set EXCLUDE { malloc.test memleak.test misuse.test - format3.test crash.test utf16.test } if {[sqlite3 -has-codec]} { - lappend EXCLUDE \ - attach.test \ - attach2.test \ - auth.test \ - format3.test \ - version.test + # lappend EXCLUDE \ + # conflict.test } foreach testfile [lsort -dictionary [glob $testdir/*.test]] { diff --git a/test/types.test b/test/types.test index 1233e90dec..2402de86a2 100644 --- a/test/types.test +++ b/test/types.test @@ -12,7 +12,7 @@ # it tests that the different storage classes (integer, real, text etc.) # all work correctly. # -# $Id: types.test,v 1.9 2004/06/30 03:08:25 drh Exp $ +# $Id: types.test,v 1.10 2004/07/22 15:02:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -37,6 +37,10 @@ source $testdir/tester.tcl # types-3.*: Test that the '=' operator respects manifest types. # +# Disable encryption on the database for this test. +db close +set DB [sqlite3 db test.db] +sqlite3_rekey $DB {} # Create a table with one column for each type of affinity do_test types-1.1.0 {