From 097ce2caab3518e444949c6314ef162041e568d1 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 23 Jun 2011 17:29:33 +0000 Subject: [PATCH 1/9] Add a bit to the SQLITE_TESTCTRL_OPTIMIZATIONS setting that will disable affinity when writing to any index, regardless of whether or not the index is on a manifestation of a view. This allows better testing of the fix for ticket [91e2e8ba6ff2e2]. FossilOrigin-Name: b61a76a53af04f731fe7617f7b6b4fb2aef6587b --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/delete.c | 7 ++++++- src/sqliteInt.h | 1 + src/test1.c | 1 + 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 674d6dedb7..5971790c88 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\sfor\sticket\s[91e2e8ba6f].\sNo\schanges\sto\scode. -D 2011-06-23T16:40:26.224 +C Add\sa\sbit\sto\sthe\sSQLITE_TESTCTRL_OPTIMIZATIONS\ssetting\sthat\swill\sdisable\naffinity\swhen\swriting\sto\sany\sindex,\sregardless\sof\swhether\sor\snot\sthe\sindex\nis\son\sa\smanifestation\sof\sa\sview.\s\sThis\sallows\sbetter\stesting\sof\sthe\sfix\nfor\sticket\s[91e2e8ba6ff2e2]. +D 2011-06-23T17:29:33.244 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -132,7 +132,7 @@ F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 F src/date.c d3c11de76392ea62637bfac0f4655889fc2f5a85 -F src/delete.c de45b70c0225e5d55b6edee2cdd460da92d401ca +F src/delete.c 4925f9121525fc871f5d8d13c1f7dcc91abb38bb F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 9fabba17a4d4778dc660f0cb9d781fc86d7b9d41 @@ -183,12 +183,12 @@ F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 0e0173b3e79d956368013e759f084caa7995ecb1 F src/sqlite.h.in 4b7255c10d39c5faf089dbd29cde7c367ff39f1f F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h a9248d3b0d2b1cf428d8642320fb13044a8888e0 +F src/sqliteInt.h 7b72f7c6929757c0678d94524dbc7e7e3d6dc398 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 5db825be61708b1a2b3f8f6e185e9b753829acef -F src/test1.c 669b8fde7f3c72250d59fef1adda5e040f7baae0 +F src/test1.c 8eef932f1024f1076a8adb8a6f5d9c5267c9e969 F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 124ff9735fb6bb7d41de180d6bac90e7b1509432 F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 @@ -949,7 +949,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 0b3174e0b1364ccc31853dce02bce5f7d3d431db -R f6237300c8e94b60ef9cb6b4fc0d6ad4 -U dan -Z 66a01206844bd880ddebccebd0a5e317 +P c271f7e88fc081a460dd3f4afb24aa9fb7fa2917 +R 5805b6f3882ce897a61c4ce87076bc70 +U drh +Z 83d974f3e6b84b4810ac6511db96428d diff --git a/manifest.uuid b/manifest.uuid index bffb816668..b421fc183b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c271f7e88fc081a460dd3f4afb24aa9fb7fa2917 \ No newline at end of file +b61a76a53af04f731fe7617f7b6b4fb2aef6587b \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index de6ed69bc7..ec0ecec7e2 100644 --- a/src/delete.c +++ b/src/delete.c @@ -636,7 +636,12 @@ int sqlite3GenerateIndexKey( } } if( doMakeRec ){ - const char *zAff = pTab->pSelect ? 0 : sqlite3IndexAffinityStr(v, pIdx); + const char *zAff; + if( pTab->pSelect || (pParse->db->flags & SQLITE_IdxRealAsInt)!=0 ){ + zAff = 0; + }else{ + zAff = sqlite3IndexAffinityStr(v, pIdx); + } sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut); sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f8735ccfed..09f64b7939 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -955,6 +955,7 @@ struct sqlite3 { #define SQLITE_IndexCover 0x10 /* Disable index covering table */ #define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ #define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ +#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ #define SQLITE_OptMask 0xff /* Mask of all disablable opts */ /* diff --git a/src/test1.c b/src/test1.c index acb6d67d7a..7fdf54b128 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5605,6 +5605,7 @@ static int optimization_control( { "index-cover", SQLITE_IndexCover }, { "groupby-order", SQLITE_GroupByOrder }, { "factor-constants", SQLITE_FactorOutConst }, + { "real-as-int", SQLITE_IdxRealAsInt }, }; if( objc!=4 ){ From 15d31e1ee1e504e3a0a83ece6e27e6983c0da07f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 23 Jun 2011 19:49:22 +0000 Subject: [PATCH 2/9] Version 3.7.7 release candidate #1. FossilOrigin-Name: 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 --- manifest | 8 ++++---- manifest.uuid | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifest b/manifest index 5971790c88..6afb8c5324 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sbit\sto\sthe\sSQLITE_TESTCTRL_OPTIMIZATIONS\ssetting\sthat\swill\sdisable\naffinity\swhen\swriting\sto\sany\sindex,\sregardless\sof\swhether\sor\snot\sthe\sindex\nis\son\sa\smanifestation\sof\sa\sview.\s\sThis\sallows\sbetter\stesting\sof\sthe\sfix\nfor\sticket\s[91e2e8ba6ff2e2]. -D 2011-06-23T17:29:33.244 +C Version\s3.7.7\srelease\scandidate\s#1. +D 2011-06-23T19:49:22.376 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -949,7 +949,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P c271f7e88fc081a460dd3f4afb24aa9fb7fa2917 +P b61a76a53af04f731fe7617f7b6b4fb2aef6587b R 5805b6f3882ce897a61c4ce87076bc70 U drh -Z 83d974f3e6b84b4810ac6511db96428d +Z a111ec09c232c3c09811b275ae45bf17 diff --git a/manifest.uuid b/manifest.uuid index b421fc183b..1781623b8d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b61a76a53af04f731fe7617f7b6b4fb2aef6587b \ No newline at end of file +4374b7e83ea0a3fbc3691f9c0c936272862f32f2 \ No newline at end of file From df3aa16e2bd0543ec80be0703a429cbcf7923403 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 24 Jun 2011 11:29:51 +0000 Subject: [PATCH 3/9] Fix some harmless compiler warnings that were occurring with THREADSAFE=0. FossilOrigin-Name: 9b191bb4c7c1e1b12b188c0b3eee1f8f587887c8 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/date.c | 2 ++ src/os_unix.c | 2 +- tool/warnings.sh | 6 +++++- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 6afb8c5324..703d2960ab 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.7.7\srelease\scandidate\s#1. -D 2011-06-23T19:49:22.376 +C Fix\ssome\sharmless\scompiler\swarnings\sthat\swere\soccurring\swith\sTHREADSAFE=0. +D 2011-06-24T11:29:51.234 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c d3c11de76392ea62637bfac0f4655889fc2f5a85 +F src/date.c a3c6842bad7ae632281811de112a8ba63ff08ab3 F src/delete.c 4925f9121525fc871f5d8d13c1f7dcc91abb38bb F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -165,7 +165,7 @@ F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c 07acbb3e074e52b48a4248c06f66c9a91db1a0ce +F src/os_unix.c d3e7b17100704ee0fe2ef71a98c478b947480f4d F src/os_win.c eafcd6b91cf204a7ef29ac1ef2a1b7132e132e58 F src/pager.c 120550e7ef01dafaa2cbb4a0528c0d87c8f12b41 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 @@ -948,8 +948,8 @@ F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P b61a76a53af04f731fe7617f7b6b4fb2aef6587b -R 5805b6f3882ce897a61c4ce87076bc70 +F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262 +P 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 +R 1f317b87075f75e0f868cf711b7bb21e U drh -Z a111ec09c232c3c09811b275ae45bf17 +Z 5efaa6b46127bcc37e3b2f98e5f441cd diff --git a/manifest.uuid b/manifest.uuid index 1781623b8d..b9b8f7e7c3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4374b7e83ea0a3fbc3691f9c0c936272862f32f2 \ No newline at end of file +9b191bb4c7c1e1b12b188c0b3eee1f8f587887c8 \ No newline at end of file diff --git a/src/date.c b/src/date.c index c0744e8c72..f9411ea5b3 100644 --- a/src/date.c +++ b/src/date.c @@ -427,7 +427,9 @@ static int osLocaltime(time_t *t, struct tm *pTm){ #if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \ && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S) struct tm *pX; +#if SQLITE_THREADSAFE>0 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); +#endif sqlite3_mutex_enter(mutex); pX = localtime(t); #ifndef SQLITE_OMIT_BUILTIN_TEST diff --git a/src/os_unix.c b/src/os_unix.c index 682e74c958..f9a12a2fb9 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3672,7 +3672,7 @@ static void unixShmPurge(unixFile *pFd){ if( p && p->nRef==0 ){ int i; assert( p->pInode==pFd->pInode ); - if( p->mutex ) sqlite3_mutex_free(p->mutex); + sqlite3_mutex_free(p->mutex); for(i=0; inRegion; i++){ if( p->h>=0 ){ munmap(p->apRegion[i], p->szRegion); diff --git a/tool/warnings.sh b/tool/warnings.sh index e1fa2b2d91..2eb3992f09 100644 --- a/tool/warnings.sh +++ b/tool/warnings.sh @@ -8,7 +8,11 @@ echo '********** No optimizations. Includes FTS4 and RTREE *********' gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ sqlite3.c -echo '********** Optimized -O3. Includes FTS4 and RTREE *********' +echo '********** No optimizations. ENABLE_STAT2. THREADSAFE=0 *******' +gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ + -ansi -DSQLITE_ENABLE_STAT2 -DSQLITE_THREADSAFE=0 \ + sqlite3.c +echo '********** Optimized -O3. Includes FTS4 and RTREE ************' gcc -O3 -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ sqlite3.c From 600e62fdd5b8bb2de14b779ddca87671e36876db Mon Sep 17 00:00:00 2001 From: shaneh Date: Fri, 24 Jun 2011 13:50:13 +0000 Subject: [PATCH 4/9] Fix a Windows line ending issue in a test case that was causing an incrblob test to fail. FossilOrigin-Name: afbe9023a706375be53bce389ef4e806f17fc7ec --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/incrblob_err.test | 6 ++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 703d2960ab..8a766d0e4b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sharmless\scompiler\swarnings\sthat\swere\soccurring\swith\sTHREADSAFE=0. -D 2011-06-24T11:29:51.234 +C Fix\sa\sWindows\sline\sending\sissue\sin\sa\stest\scase\sthat\swas\scausing\san\sincrblob\stest\sto\sfail. +D 2011-06-24T13:50:13.840 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -501,7 +501,7 @@ F test/in4.test 64f3cc1acde1b9161ccdd8e5bde3daefdb5b2617 F test/incrblob.test 76e787ca3301d9bfa6906031c626d26f8dd707de F test/incrblob2.test edc3a96e557bd61fb39acc8d2edd43371fbbaa19 F test/incrblob3.test aedbb35ea1b6450c33b98f2b6ed98e5020be8dc7 -F test/incrblob_err.test c577c91d4ed9e8336cdb188b15d6ee2a6fe9604e +F test/incrblob_err.test d2562d2771ebffd4b3af89ef64c140dd44371597 F test/incrblobfault.test 917c0292224c64a56ef7215fd633a3a82f805be0 F test/incrvacuum.test 453d1e490d8f5ad2c9b3a54282a0690d6ae56462 F test/incrvacuum2.test ae04573b73ad52179f56e194fff0fbe43b509d23 @@ -949,7 +949,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262 -P 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 -R 1f317b87075f75e0f868cf711b7bb21e -U drh -Z 5efaa6b46127bcc37e3b2f98e5f441cd +P 9b191bb4c7c1e1b12b188c0b3eee1f8f587887c8 +R 32b8d769c1bc3fb3a1b9110c79256b1a +U shaneh +Z 84e18ea858841ffe13a9371ad8c31731 diff --git a/manifest.uuid b/manifest.uuid index b9b8f7e7c3..d375e114ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b191bb4c7c1e1b12b188c0b3eee1f8f587887c8 \ No newline at end of file +afbe9023a706375be53bce389ef4e806f17fc7ec \ No newline at end of file diff --git a/test/incrblob_err.test b/test/incrblob_err.test index b4c258772a..35d37fee92 100644 --- a/test/incrblob_err.test +++ b/test/incrblob_err.test @@ -35,6 +35,7 @@ do_malloc_test 1 -tclprep { } } -tclbody { set ::blob [db incrblob blobs v 1] + fconfigure $::blob -translation binary set rc [catch {puts -nonewline $::blob $::data}] if {$rc} { error "out of memory" } } @@ -71,8 +72,7 @@ do_malloc_test 3 -tclprep { if {$rc} { error "out of memory" } -} - +} do_ioerr_test incrblob_err-4 -cksum 1 -sqlprep { CREATE TABLE blobs(k, v BLOB); @@ -87,6 +87,7 @@ do_ioerr_test incrblob_err-5 -cksum 1 -sqlprep { INSERT INTO blobs VALUES(1, zeroblob(length(CAST($::data AS BLOB)))); } -tclbody { set ::blob [db incrblob blobs v 1] + fconfigure $::blob -translation binary puts -nonewline $::blob $::data close $::blob } @@ -96,6 +97,7 @@ do_ioerr_test incrblob_err-6 -cksum 1 -sqlprep { INSERT INTO blobs VALUES(1, $::data || $::data || $::data); } -tclbody { set ::blob [db incrblob blobs v 1] + fconfigure $::blob -translation binary seek $::blob -20 end puts -nonewline $::blob "12345678900987654321" close $::blob From 28e4e355861916ff548d5ca171a44325dec67296 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 24 Jun 2011 18:43:23 +0000 Subject: [PATCH 5/9] Explicitly cast an argument to printf() to (int), in case the result of the pointer arithmetic expression is a 64-bit integer on some platforms. FossilOrigin-Name: 90cfeaf7b68eebc2cd75bc60b1bb86823646fe30 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8a766d0e4b..369f2971cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sWindows\sline\sending\sissue\sin\sa\stest\scase\sthat\swas\scausing\san\sincrblob\stest\sto\sfail. -D 2011-06-24T13:50:13.840 +C Explicitly\scast\san\sargument\sto\sprintf()\sto\s(int),\sin\scase\sthe\sresult\sof\sthe\spointer\sarithmetic\sexpression\sis\sa\s64-bit\sinteger\son\ssome\splatforms. +D 2011-06-24T18:43:23.777 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -127,7 +127,7 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c 8c46f0ab69ad9549c75a3a91fed87abdaa743e2f F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 -F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a +F src/build.c 5e614e586d9f8a81c16c80b545b9e1747f96c1bb F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 @@ -949,7 +949,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262 -P 9b191bb4c7c1e1b12b188c0b3eee1f8f587887c8 -R 32b8d769c1bc3fb3a1b9110c79256b1a -U shaneh -Z 84e18ea858841ffe13a9371ad8c31731 +P afbe9023a706375be53bce389ef4e806f17fc7ec +R 39e40cd4e043bc5ee4d5e0c0bd1144c1 +U dan +Z 0fb26f42eab966013b31af43c43a2eeb diff --git a/manifest.uuid b/manifest.uuid index d375e114ae..150eec39e9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -afbe9023a706375be53bce389ef4e806f17fc7ec \ No newline at end of file +90cfeaf7b68eebc2cd75bc60b1bb86823646fe30 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 97758cbcbd..455b35b56e 100644 --- a/src/build.c +++ b/src/build.c @@ -2791,7 +2791,7 @@ Index *sqlite3CreateIndex( /* A named index with an explicit CREATE INDEX statement */ zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s", onError==OE_None ? "" : " UNIQUE", - pEnd->z - pName->z + 1, + (int)(pEnd->z - pName->z) + 1, pName->z); }else{ /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ From 5b0b6fded766b43dad5df8c12bb2423b85a8e467 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 25 Jun 2011 01:14:36 +0000 Subject: [PATCH 6/9] Support using nmake via cmd.exe, allow Tcl related variables to be overridden via the environment, and add 'dll' to the 'all' target. FossilOrigin-Name: 0cb0f30603b1658ae24d1b74d6ab59d05ef4e448 --- Makefile.msc | 44 ++++++++++++++++++++++++++++++-------------- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index a6d1bf4c2f..718464d6ec 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -43,16 +43,32 @@ TCC = $(TCC) -I$(TOP)\ext\rtree # TCC = $(TCC) -DNDEBUG -# The library that programs using TCL must link against. +# The locations of the Tcl header and library files. Also, the library that +# non-stubs enabled programs using Tcl must link against. These variables +# (TCLINCDIR, TCLLIBDIR, and LIBTCL) may be overridden via the environment +# prior to running nmake in order to match the actual installed location and +# version on this machine. # -LIBTCL = tcl85.lib +!if "$(TCLINCDIR)" == "" TCLINCDIR = c:\tcl\include +!endif + +!if "$(TCLLIBDIR)" == "" TCLLIBDIR = c:\tcl\lib +!endif + +!if "$(LIBTCL)" == "" +LIBTCL = tcl85.lib +!endif # This is the command to use for tclsh - normally just "tclsh", but we may -# know the specific version we want to use +# know the specific version we want to use. This variable (TCLSH_CMD) may be +# overridden via the environment prior to running nmake in order to select a +# specific Tcl shell to use. # +!if "$(TCLSH_CMD)" == "" TCLSH_CMD = tclsh85 +!endif # Compiler options needed for programs that use the readline() library. # @@ -118,7 +134,7 @@ LTLIBOPTS = /MACHINE:$(PLATFORM) !ENDIF # nawk compatible awk. -NAWK = .\gawk.exe +NAWK = gawk.exe # You should not have to change anything below this line ############################################################################### @@ -439,7 +455,7 @@ EXTHDR = $(EXTHDR) \ # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # -all: libsqlite3.lib sqlite3.exe libtclsqlite3.lib +all: dll libsqlite3.lib sqlite3.exe libtclsqlite3.lib libsqlite3.lib: $(LIBOBJ) $(LTLIB) $(LTLIBOPTS) /OUT:$@ $(LIBOBJ) $(TLIBS) @@ -463,7 +479,7 @@ sqlite3.exe: $(TOP)\src\shell.c libsqlite3.lib sqlite3.h -mkdir tsrc for %i in ($(SRC)) do copy /Y %i tsrc del /Q tsrc\sqlite.h.in tsrc\parse.y - $(TCLSH_CMD) $(TOP)\tool\vdbe-compress.tcl vdbe.new + $(TCLSH_CMD) $(TOP)\tool\vdbe-compress.tcl < tsrc\vdbe.c > vdbe.new move vdbe.new tsrc\vdbe.c echo > .target_source @@ -720,10 +736,10 @@ tclsqlite3.exe: tclsqlite-shell.lo libsqlite3.lib # Rules to build opcodes.c and opcodes.h # opcodes.c: opcodes.h $(TOP)\mkopcodec.awk - $(NAWK) "/#define OP_/ { print }" opcodes.h | sort /+45 | $(NAWK) -f $(TOP)\mkopcodec.awk >opcodes.c + $(NAWK) "/#define OP_/ { print }" opcodes.h | sort /+45 | $(NAWK) -f $(TOP)\mkopcodec.awk > opcodes.c opcodes.h: parse.h $(TOP)\src\vdbe.c $(TOP)\mkopcodeh.awk - type parse.h $(TOP)\src\vdbe.c | $(NAWK) -f $(TOP)\mkopcodeh.awk >opcodes.h + type parse.h $(TOP)\src\vdbe.c | $(NAWK) -f $(TOP)\mkopcodeh.awk > opcodes.h # Rules to build parse.c and parse.h - the outputs of lemon. # @@ -734,16 +750,16 @@ parse.c: $(TOP)\src\parse.y lemon.exe $(TOP)\addopcodes.awk copy $(TOP)\src\parse.y . .\lemon.exe $(OPT_FEATURE_FLAGS) $(OPTS) parse.y move parse.h parse.h.temp - $(NAWK) -f $(TOP)\addopcodes.awk parse.h.temp >parse.h + $(NAWK) -f $(TOP)\addopcodes.awk parse.h.temp > parse.h sqlite3.h: $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION - $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP) >sqlite3.h + $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP) > sqlite3.h mkkeywordhash.exe: $(TOP)\tool\mkkeywordhash.c $(BCC) -Femkkeywordhash.exe $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)\tool\mkkeywordhash.c keywordhash.h: $(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe - .\mkkeywordhash.exe >keywordhash.h + .\mkkeywordhash.exe > keywordhash.h @@ -839,7 +855,7 @@ test: testfixture.exe sqlite3.exe spaceanal_tcl.h: $(TOP)\tool\spaceanal.tcl $(NAWK) -f $(TOP)/tool/tostr.awk \ - $(TOP)\tool\spaceanal.tcl >spaceanal_tcl.h + $(TOP)\tool\spaceanal.tcl > spaceanal_tcl.h sqlite3_analyzer.exe: $(TESTFIXTURE_SRC) spaceanal_tcl.h $(LTLINK) -DTCLSH=2 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 \ @@ -866,10 +882,10 @@ clean: dll: sqlite3.dll sqlite3.def: libsqlite3.lib - echo EXPORTS >sqlite3.def + echo EXPORTS > sqlite3.def dumpbin /all libsqlite3.lib \ | $(NAWK) "/ 1 _sqlite3_/ { sub(/^.* _/,\"\");print }" \ - | sort >>sqlite3.def + | sort >> sqlite3.def sqlite3.dll: $(LIBOBJ) sqlite3.def link $(LTLINKOPTS) /DLL /DEF:sqlite3.def /OUT:$@ $(LIBOBJ) diff --git a/manifest b/manifest index 369f2971cc..495f9da122 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Explicitly\scast\san\sargument\sto\sprintf()\sto\s(int),\sin\scase\sthe\sresult\sof\sthe\spointer\sarithmetic\sexpression\sis\sa\s64-bit\sinteger\son\ssome\splatforms. -D 2011-06-24T18:43:23.777 +C Support\susing\snmake\svia\scmd.exe,\sallow\sTcl\srelated\svariables\sto\sbe\soverridden\svia\sthe\senvironment,\sand\sadd\s'dll'\sto\sthe\s'all'\starget. +D 2011-06-25T01:14:36.767 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 11082f65b452b908d93013292c17850378c39284 +F Makefile.msc 9c76731c20561a33ce1257c70be3f029cedb62a6 F Makefile.vxworks c85ec1d8597fe2f7bc225af12ac1666e21379151 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION 3fcdd7fbe3eb282df3978fe77288544543767961 @@ -949,7 +949,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262 -P afbe9023a706375be53bce389ef4e806f17fc7ec -R 39e40cd4e043bc5ee4d5e0c0bd1144c1 -U dan -Z 0fb26f42eab966013b31af43c43a2eeb +P 90cfeaf7b68eebc2cd75bc60b1bb86823646fe30 +R 9d6679872042f0704eb46a854652b6b2 +U mistachkin +Z 10a97d70fb2ecf74c56670a3fe99eddd diff --git a/manifest.uuid b/manifest.uuid index 150eec39e9..1bf5d940d2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -90cfeaf7b68eebc2cd75bc60b1bb86823646fe30 \ No newline at end of file +0cb0f30603b1658ae24d1b74d6ab59d05ef4e448 \ No newline at end of file From c7060c4dc5cf0c9bae1202513ae7a181c7646a60 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 26 Jun 2011 23:44:35 +0000 Subject: [PATCH 7/9] Modifications to the "like.test" script in order to expose the problem reported by ticket [25ee81271091ec27a8c5]. FossilOrigin-Name: c4db5b640638a211b096454ba90b58faf595392b --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/like.test | 7 +++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 495f9da122..552a042538 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Support\susing\snmake\svia\scmd.exe,\sallow\sTcl\srelated\svariables\sto\sbe\soverridden\svia\sthe\senvironment,\sand\sadd\s'dll'\sto\sthe\s'all'\starget. -D 2011-06-25T01:14:36.767 +C Modifications\sto\sthe\s"like.test"\sscript\sin\sorder\sto\sexpose\sthe\sproblem\nreported\sby\sticket\s[25ee81271091ec27a8c5]. +D 2011-06-26T23:44:35.143 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -540,7 +540,7 @@ F test/jrnlmode3.test c6522b276ba315fd1416198de6fc1da9e72409fb F test/keyword1.test a2400977a2e4fde43bf33754c2929fda34dbca05 F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 -F test/like.test a47f52692aac96ba82508efba74819214cdebc17 +F test/like.test 9cc5261d22f2108a27cedff8a972aa3284a4ba52 F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e F test/loadext.test 0393ce12d9616aa87597dd0ec88181de181f6db0 @@ -949,7 +949,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262 -P 90cfeaf7b68eebc2cd75bc60b1bb86823646fe30 -R 9d6679872042f0704eb46a854652b6b2 -U mistachkin -Z 10a97d70fb2ecf74c56670a3fe99eddd +P 0cb0f30603b1658ae24d1b74d6ab59d05ef4e448 +R b4c0c5b0c346256e14626d78568a95ff +U drh +Z 547c3ad3eebb979ac90e817759786a1e diff --git a/manifest.uuid b/manifest.uuid index 1bf5d940d2..76ea188c40 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0cb0f30603b1658ae24d1b74d6ab59d05ef4e448 \ No newline at end of file +c4db5b640638a211b096454ba90b58faf595392b \ No newline at end of file diff --git a/test/like.test b/test/like.test index bd9a6c39c1..45d5a97c5b 100644 --- a/test/like.test +++ b/test/like.test @@ -70,12 +70,15 @@ do_test like-1.4 { } } {ABC abc} do_test like-1.5.1 { + # Use sqlite3_exec() to verify fix for ticket [25ee81271091] 2011-06-26 + sqlite3_exec db {PRAGMA case_sensitive_like=on} +} {0 {}} +do_test like-1.5.2 { execsql { - PRAGMA case_sensitive_like=on; SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1; } } {abc} -do_test like-1.5.2 { +do_test like-1.5.3 { execsql { PRAGMA case_sensitive_like; -- no argument; does not change setting SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1; From aab910c459eafdc68606ff916f4ecbc60ee06a38 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 27 Jun 2011 00:01:22 +0000 Subject: [PATCH 8/9] Make sure all new statements begin life unexpired, even if they registered functions or did other actions during preparation that would have expired all statements. Fix for ticket [25ee81271091] FossilOrigin-Name: faa38c8724d3eebad97197bfa44d11e75cfe6c69 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 552a042538..1a8f207d3b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modifications\sto\sthe\s"like.test"\sscript\sin\sorder\sto\sexpose\sthe\sproblem\nreported\sby\sticket\s[25ee81271091ec27a8c5]. -D 2011-06-26T23:44:35.143 +C Make\ssure\sall\snew\sstatements\sbegin\slife\sunexpired,\seven\sif\sthey\sregistered\nfunctions\sor\sdid\sother\sactions\sduring\spreparation\sthat\swould\shave\sexpired\nall\sstatements.\s\sFix\sfor\sticket\s[25ee81271091] +D 2011-06-27T00:01:22.248 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -242,7 +242,7 @@ F src/vdbe.c 50b5b4ef29d928a4f60905f820ee1ab2f8ced29f F src/vdbe.h 5cf09e7ee8a3f7d93bc51f196a96550786afe7a1 F src/vdbeInt.h ad84226cc0adcb1185c22b70696b235a1678bb45 F src/vdbeapi.c 2f908c65337b16c6249ab378d477e74492cf759b -F src/vdbeaux.c 0b2e2880f13af400a27c92a7673287c3eaec8b21 +F src/vdbeaux.c 4d100407e3c72e163854aff8903d19d5ecdf46c0 F src/vdbeblob.c f024f0bf420f36b070143c32b15cc7287341ffd3 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 @@ -949,7 +949,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262 -P 0cb0f30603b1658ae24d1b74d6ab59d05ef4e448 -R b4c0c5b0c346256e14626d78568a95ff +P c4db5b640638a211b096454ba90b58faf595392b +R 1d2c6c9972e41fe17af0cc7482f056ad U drh -Z 547c3ad3eebb979ac90e817759786a1e +Z 50eb339a1b9fd382164ccbf3dfada87e diff --git a/manifest.uuid b/manifest.uuid index 76ea188c40..6f48ead043 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c4db5b640638a211b096454ba90b58faf595392b \ No newline at end of file +faa38c8724d3eebad97197bfa44d11e75cfe6c69 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 447ba57a1e..989a8003d3 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1505,6 +1505,7 @@ void sqlite3VdbeMakeReady( memset(zCsr, 0, zEnd-zCsr); zCsr += (zCsr - (u8*)0)&7; assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); + p->expired = 0; /* Memory for registers, parameters, cursor, etc, is allocated in two ** passes. On the first pass, we try to reuse unused space at the From c431fd558068005380f8acace49b48895305e779 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 27 Jun 2011 16:55:50 +0000 Subject: [PATCH 9/9] Add a case to permutations.test to run the veryquick test suite using sqlite3_prepare() instead of sqlite3_prepare_v2(). This helps to test the fix for bug [25ee812710]. FossilOrigin-Name: d9f7993bfa2ecb30c44455de538eb6f8a4a59087 --- manifest | 24 ++++---- manifest.uuid | 2 +- src/tclsqlite.c | 137 ++++++++++++++++++++++++++++++++++++----- test/all.test | 1 + test/alter2.test | 1 + test/exists.test | 2 +- test/permutations.test | 9 +++ test/temptable.test | 1 + 8 files changed, 147 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index 1a8f207d3b..c734903830 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sall\snew\sstatements\sbegin\slife\sunexpired,\seven\sif\sthey\sregistered\nfunctions\sor\sdid\sother\sactions\sduring\spreparation\sthat\swould\shave\sexpired\nall\sstatements.\s\sFix\sfor\sticket\s[25ee81271091] -D 2011-06-27T00:01:22.248 +C Add\sa\scase\sto\spermutations.test\sto\srun\sthe\sveryquick\stest\ssuite\susing\ssqlite3_prepare()\sinstead\sof\ssqlite3_prepare_v2().\sThis\shelps\sto\stest\sthe\sfix\sfor\sbug\s[25ee812710]. +D 2011-06-27T16:55:50.495 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -187,7 +187,7 @@ F src/sqliteInt.h 7b72f7c6929757c0678d94524dbc7e7e3d6dc398 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e -F src/tclsqlite.c 5db825be61708b1a2b3f8f6e185e9b753829acef +F src/tclsqlite.c c355b33803fb756dc09297ec84d19604301fa622 F src/test1.c 8eef932f1024f1076a8adb8a6f5d9c5267c9e969 F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 124ff9735fb6bb7d41de180d6bac90e7b1509432 @@ -254,9 +254,9 @@ F src/where.c 55403ce19c506be6a321c7f129aff693d6103db5 F test/8_3_names.test b93687beebd17f6ebf812405a6833bae5d1f4199 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 -F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 +F test/all.test 52fc8dee494092031a556911d404ca30a749a30b F test/alter.test a3f570072b53d7c0fe463bab3f5affa8e113c487 -F test/alter2.test 75f731508f1bf27ba09a6075c66cd02216ba464b +F test/alter2.test e0c09d630d650ea32333781a4ed3c45eb02c4289 F test/alter3.test 8677e48d95536f7a6ed86a1a774744dadcc22b07 F test/alter4.test 1e5dd6b951e9f65ca66422edff02e56df82dd403 F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc @@ -393,7 +393,7 @@ F test/eval.test bc269c365ba877554948441e91ad5373f9f91be3 F test/exclusive.test 53e1841b422e554cecf0160f937c473d6d0e3062 F test/exclusive2.test 343d55130c12c67b8bf10407acec043a6c26c86b F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 -F test/exists.test 5e2d64b4eb5a9d08876599bdae2e1213d2d12e2a +F test/exists.test 8f7b27b61c2fbe5822f0a1f899c715d14e416e30 F test/expr.test 67c9fd6f8f829e239dc8b0f4a08a73c08b09196d F test/fallocate.test 43dc34b8c24be6baffadc3b4401ee15710ce83c6 F test/filectrl.test 97003734290887566e01dded09dc9e99cb937e9e @@ -615,7 +615,7 @@ F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806 F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test 0d85f2ab6963aee28c671d4c71bec038c00a1d16 -F test/permutations.test 1e8892ebf1bd6e9e8036f4841c72a91bf72da74a +F test/permutations.test aae89941ca0968b53633c97b5dd0d6f9f9899d27 F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea @@ -693,7 +693,7 @@ F test/table.test 04ba066432430657712d167ebf28080fe878d305 F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tclsqlite.test 8c154101e704170c2be10f137a5499ac2c6da8d3 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c -F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a +F test/temptable.test 1a21a597055dcf6002b6f1ee867632dccd6e925c F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05 F test/tester.tcl 7d3d17914ca5397a82f801db733b81d4a82f50c3 F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f @@ -949,7 +949,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262 -P c4db5b640638a211b096454ba90b58faf595392b -R 1d2c6c9972e41fe17af0cc7482f056ad -U drh -Z 50eb339a1b9fd382164ccbf3dfada87e +P faa38c8724d3eebad97197bfa44d11e75cfe6c69 +R ea65f158609dffa4f41c8ce1eb564414 +U dan +Z 2df66e3ffb41532c6826925a7e3446a4 diff --git a/manifest.uuid b/manifest.uuid index 6f48ead043..4cd588aa86 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -faa38c8724d3eebad97197bfa44d11e75cfe6c69 \ No newline at end of file +d9f7993bfa2ecb30c44455de538eb6f8a4a59087 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index ad4d27a126..339b8967df 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -107,6 +107,11 @@ typedef struct IncrblobChannel IncrblobChannel; /* ** There is one instance of this structure for each SQLite database ** that has been opened by the SQLite TCL interface. +** +** If this module is built with SQLITE_TEST defined (to create the SQLite +** testfixture executable), then it may be configured to use either +** sqlite3_prepare_v2() or sqlite3_prepare() to prepare SQL statements. +** If SqliteDb.bLegacyPrepare is true, sqlite3_prepare() is used. */ typedef struct SqliteDb SqliteDb; struct SqliteDb { @@ -135,6 +140,9 @@ struct SqliteDb { IncrblobChannel *pIncrblob;/* Linked list of open incrblob channels */ int nStep, nSort, nIndex; /* Statistics for most recent operation */ int nTransaction; /* Number of nested [transaction] methods */ +#ifdef SQLITE_TEST + int bLegacyPrepare; /* True to use sqlite3_prepare() */ +#endif }; struct IncrblobChannel { @@ -429,20 +437,33 @@ static SqlFunc *findSqlFunc(SqliteDb *pDb, const char *zName){ return pNew; } +/* +** Free a single SqlPreparedStmt object. +*/ +static void dbFreeStmt(SqlPreparedStmt *pStmt){ +#ifdef SQLITE_TEST + if( sqlite3_sql(pStmt->pStmt)==0 ){ + Tcl_Free((char *)pStmt->zSql); + } +#endif + sqlite3_finalize(pStmt->pStmt); + Tcl_Free((char *)pStmt); +} + /* ** Finalize and free a list of prepared statements */ -static void flushStmtCache( SqliteDb *pDb ){ +static void flushStmtCache(SqliteDb *pDb){ SqlPreparedStmt *pPreStmt; + SqlPreparedStmt *pNext; - while( pDb->stmtList ){ - sqlite3_finalize( pDb->stmtList->pStmt ); - pPreStmt = pDb->stmtList; - pDb->stmtList = pDb->stmtList->pNext; - Tcl_Free( (char*)pPreStmt ); + for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pNext){ + pNext = pPreStmt->pNext; + dbFreeStmt(pPreStmt); } pDb->nStmt = 0; pDb->stmtLast = 0; + pDb->stmtList = 0; } /* @@ -1030,6 +1051,27 @@ static int DbTransPostCmd( return rc; } +/* +** Unless SQLITE_TEST is defined, this function is a simple wrapper around +** sqlite3_prepare_v2(). If SQLITE_TEST is defined, then it uses either +** sqlite3_prepare_v2() or legacy interface sqlite3_prepare(), depending +** on whether or not the [db_use_legacy_prepare] command has been used to +** configure the connection. +*/ +static int dbPrepare( + SqliteDb *pDb, /* Database object */ + const char *zSql, /* SQL to compile */ + sqlite3_stmt **ppStmt, /* OUT: Prepared statement */ + const char **pzOut /* OUT: Pointer to next SQL statement */ +){ +#ifdef SQLITE_TEST + if( pDb->bLegacyPrepare ){ + return sqlite3_prepare(pDb->db, zSql, -1, ppStmt, pzOut); + } +#endif + return sqlite3_prepare_v2(pDb->db, zSql, -1, ppStmt, pzOut); +} + /* ** Search the cache for a prepared-statement object that implements the ** first SQL statement in the buffer pointed to by parameter zIn. If @@ -1100,7 +1142,7 @@ static int dbPrepareAndBind( if( pPreStmt==0 ){ int nByte; - if( SQLITE_OK!=sqlite3_prepare_v2(pDb->db, zSql, -1, &pStmt, pzOut) ){ + if( SQLITE_OK!=dbPrepare(pDb, zSql, &pStmt, pzOut) ){ Tcl_SetObjResult(interp, dbTextToObj(sqlite3_errmsg(pDb->db))); return TCL_ERROR; } @@ -1127,6 +1169,14 @@ static int dbPrepareAndBind( pPreStmt->nSql = (*pzOut - zSql); pPreStmt->zSql = sqlite3_sql(pStmt); pPreStmt->apParm = (Tcl_Obj **)&pPreStmt[1]; +#ifdef SQLITE_TEST + if( pPreStmt->zSql==0 ){ + char *zCopy = Tcl_Alloc(pPreStmt->nSql + 1); + memcpy(zCopy, zSql, pPreStmt->nSql); + zCopy[pPreStmt->nSql] = '\0'; + pPreStmt->zSql = zCopy; + } +#endif } assert( pPreStmt ); assert( strlen30(pPreStmt->zSql)==pPreStmt->nSql ); @@ -1180,7 +1230,6 @@ static int dbPrepareAndBind( return TCL_OK; } - /* ** Release a statement reference obtained by calling dbPrepareAndBind(). ** There should be exactly one call to this function for each call to @@ -1205,8 +1254,7 @@ static void dbReleaseStmt( if( pDb->maxStmt<=0 || discard ){ /* If the cache is turned off, deallocated the statement */ - sqlite3_finalize(pPreStmt->pStmt); - Tcl_Free((char *)pPreStmt); + dbFreeStmt(pPreStmt); }else{ /* Add the prepared statement to the beginning of the cache list. */ pPreStmt->pNext = pDb->stmtList; @@ -1226,11 +1274,11 @@ static void dbReleaseStmt( /* If we have too many statement in cache, remove the surplus from ** the end of the cache list. */ while( pDb->nStmt>pDb->maxStmt ){ - sqlite3_finalize(pDb->stmtLast->pStmt); - pDb->stmtLast = pDb->stmtLast->pPrev; - Tcl_Free((char*)pDb->stmtLast->pNext); + SqlPreparedStmt *pLast = pDb->stmtLast; + pDb->stmtLast = pLast->pPrev; pDb->stmtLast->pNext = 0; pDb->nStmt--; + dbFreeStmt(pLast); } } } @@ -1363,9 +1411,12 @@ static void dbEvalRowInfo( ** no further rows available. This is similar to SQLITE_DONE. */ static int dbEvalStep(DbEvalContext *p){ + const char *zPrevSql = 0; /* Previous value of p->zSql */ + while( p->zSql[0] || p->pPreStmt ){ int rc; if( p->pPreStmt==0 ){ + zPrevSql = (p->zSql==zPrevSql ? 0 : p->zSql); rc = dbPrepareAndBind(p->pDb, p->zSql, &p->zSql, &p->pPreStmt); if( rc!=TCL_OK ) return rc; }else{ @@ -1392,8 +1443,19 @@ static int dbEvalStep(DbEvalContext *p){ if( rcs!=SQLITE_OK ){ /* If a run-time error occurs, report the error and stop reading ** the SQL. */ - Tcl_SetObjResult(pDb->interp, dbTextToObj(sqlite3_errmsg(pDb->db))); dbReleaseStmt(pDb, pPreStmt, 1); +#if SQLITE_TEST + if( p->pDb->bLegacyPrepare && rcs==SQLITE_SCHEMA && zPrevSql ){ + /* If the runtime error was an SQLITE_SCHEMA, and the database + ** handle is configured to use the legacy sqlite3_prepare() + ** interface, retry prepare()/step() on the same SQL statement. + ** This only happens once. If there is a second SQLITE_SCHEMA + ** error, the error will be returned to the caller. */ + p->zSql = zPrevSql; + continue; + } +#endif + Tcl_SetObjResult(pDb->interp, dbTextToObj(sqlite3_errmsg(pDb->db))); return TCL_ERROR; }else{ dbReleaseStmt(pDb, pPreStmt, 0); @@ -2926,7 +2988,7 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ }else{ flags &= ~SQLITE_OPEN_NOMUTEX; } - }else if( strcmp(zArg, "-fullmutex")==0 ){ + }else if( strcmp(zArg, "-fullmutex")==0 ){ int b; if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR; if( b ){ @@ -3527,6 +3589,44 @@ static int init_all_cmd( init_all(slave); return TCL_OK; } + +/* +** Tclcmd: db_use_legacy_prepare DB BOOLEAN +** +** The first argument to this command must be a database command created by +** [sqlite3]. If the second argument is true, then the handle is configured +** to use the sqlite3_prepare_v2() function to prepare statements. If it +** is false, sqlite3_prepare(). +*/ +static int db_use_legacy_prepare_cmd( + ClientData cd, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + Tcl_CmdInfo cmdInfo; + SqliteDb *pDb; + int bPrepare; + + if( objc!=3 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB BOOLEAN"); + return TCL_ERROR; + } + + if( !Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &cmdInfo) ){ + Tcl_AppendResult(interp, "no such db: ", Tcl_GetString(objv[1]), (char*)0); + return TCL_ERROR; + } + pDb = (SqliteDb*)cmdInfo.objClientData; + if( Tcl_GetBooleanFromObj(interp, objv[2], &bPrepare) ){ + return TCL_ERROR; + } + + pDb->bLegacyPrepare = bPrepare; + + Tcl_ResetResult(interp); + return TCL_OK; +} #endif /* @@ -3633,7 +3733,12 @@ static void init_all(Tcl_Interp *interp){ Sqlitetestfts3_Init(interp); #endif - Tcl_CreateObjCommand(interp,"load_testfixture_extensions",init_all_cmd,0,0); + Tcl_CreateObjCommand( + interp, "load_testfixture_extensions", init_all_cmd, 0, 0 + ); + Tcl_CreateObjCommand( + interp, "db_use_legacy_prepare", db_use_legacy_prepare_cmd, 0, 0 + ); #ifdef SQLITE_SSE Sqlitetestsse_Init(interp); diff --git a/test/all.test b/test/all.test index 9671246681..54302d02e9 100644 --- a/test/all.test +++ b/test/all.test @@ -38,6 +38,7 @@ run_test_suite pcache10 run_test_suite pcache50 run_test_suite pcache90 run_test_suite pcache100 +run_test_suite prepare if {$::tcl_platform(platform)=="unix"} { ifcapable !default_autovacuum { diff --git a/test/alter2.test b/test/alter2.test index 712960c0ea..66b1950945 100644 --- a/test/alter2.test +++ b/test/alter2.test @@ -137,6 +137,7 @@ do_test alter2-1.8 { do_test alter2-1.9 { # ALTER TABLE abc ADD COLUMN d; alter_table abc {CREATE TABLE abc(a, b, c, d);} + if {[permutation] == "prepare"} { db cache flush } execsql { SELECT * FROM abc; } execsql { UPDATE abc SET d = 11 WHERE c IS NULL AND a<4; diff --git a/test/exists.test b/test/exists.test index c7c14a2402..fb73797d29 100644 --- a/test/exists.test +++ b/test/exists.test @@ -159,7 +159,7 @@ foreach jm {rollback wal} { sql1 { DROP INDEX IF EXISTS i2 } sql2 { CREATE INDEX aux.i2 ON t2(x) } sql1 { DROP INDEX IF EXISTS i2 } - sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' } + sql2 { SELECT * FROM aux.sqlite_master WHERE type = 'index' } } {} # VIEW objects. diff --git a/test/permutations.test b/test/permutations.test index 22e2189d98..57f69462a5 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -776,6 +776,15 @@ test_suite "no_optimization" -description { optimization_control $::dbhandle all 0 } +test_suite "prepare" -description { + Run tests with the db connection using sqlite3_prepare() instead of _v2(). +} -dbconfig { + db_use_legacy_prepare $::dbhandle 1 + #$::dbhandle cache size 0 +} -files [ + test_set $allquicktests -exclude *malloc* *ioerr* *fault* +] + # End of tests ############################################################################# diff --git a/test/temptable.test b/test/temptable.test index ad85f7e9f6..d82ea36444 100644 --- a/test/temptable.test +++ b/test/temptable.test @@ -292,6 +292,7 @@ do_test temptable-5.1 { execsql { CREATE TEMP TABLE mask(a,b,c) } db2 + if {[permutation]=="prepare"} { db2 cache flush } execsql { CREATE INDEX mask ON t2(x); SELECT * FROM t2;