From d6ee353c84e50a855a330c91447052a67b1db0a6 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 29 Mar 2011 15:00:17 +0000 Subject: [PATCH 01/19] If the keyword "unordered" appears at the end of the SQLITE_STAT1.STAT column for an index, then use that index for equality lookups only, never for range queries or sorting. FossilOrigin-Name: 3b964155f611c437d53d44feafa22f531942b1b4 --- install-sh | 0 manifest | 28 ++++++++++++++++------------ manifest.uuid | 2 +- src/analyze.c | 4 ++++ src/sqliteInt.h | 1 + src/where.c | 3 ++- test/progress.test | 0 tool/mkopts.tcl | 0 8 files changed, 24 insertions(+), 14 deletions(-) mode change 100644 => 100755 install-sh mode change 100755 => 100644 test/progress.test mode change 100755 => 100644 tool/mkopts.tcl diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index 5041a0d7f0..e5474f9e2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\sunix\sVFS\simplementation\sof\sxNextSystemCall().\sAlso\ssome\stypos\sthat\sprevent\scompilation\swhen\sHAVE_POSIX_FALLOCATE\sis\sdefined. -D 2011-03-29T10:04:23 +C If\sthe\skeyword\s"unordered"\sappears\sat\sthe\send\sof\sthe\sSQLITE_STAT1.STAT\ncolumn\sfor\san\sindex,\sthen\suse\sthat\sindex\sfor\sequality\slookups\sonly,\snever\nfor\srange\squeries\sor\ssorting. +D 2011-03-29T15:00:17.756 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -99,7 +99,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 7e4d4d0433c9cbfd906c6451a7cc50310a8f4555 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -115,7 +115,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3 -F src/analyze.c a038162344265ac21dfb24b3fcc06c666ebb9c07 +F src/analyze.c 0a58e3d8228617e619c48a3aa8991a1ff5ad7768 F src/attach.c 438ea6f6b5d5961c1f49b737f2ce0f14ce7c6877 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 6728d6d48d55b449af76a3e51c0808849cb32a2e @@ -180,7 +180,7 @@ F src/select.c d24406c45dd2442eb2eeaac413439066b149c944 F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a F src/sqlite.h.in e047f69a61d604d4f8be6cf1d1bdfc68be9ba7e5 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h f8f1d00a22c98fd3f2fbc94da74eeb880879f89f +F src/sqliteInt.h da41a2f4aa71d8490c55d2eaec423839300226f6 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -244,7 +244,7 @@ F src/vtab.c e1edca38c4c4310710635bb91bb3c87fdf60f21d F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c a6e89fe7e56ab7e633be6fdebdddd857e9e5bc99 +F src/where.c 8614b235f8c944e9210fd50c4619fc899bfa196e F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 @@ -604,7 +604,7 @@ F test/permutations.test 5b2a4cb756ffb2407cb4743163668d1d769febb6 F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -894,7 +894,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl cf44512a48112b1ba09590548660a5a6877afdb3 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -919,7 +919,11 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7270f80ac5dd17b979f1f790b2dfcf811866c1dc -R 667989871349daf241bf6e2f9ef88c3d -U dan -Z e094d9a9a392624fe79d654e33f9ed32 +P bc6cce81565b17f886478bd51500bba2ed11ec1d +R 28f7b55473c6274def40f06b898262fe +T *bgcolor * #c0c0c0 +T *branch * unordered-index-hack +T *sym-unordered-index-hack * +T -sym-trunk * +U drh +Z 6d40d1dbb9e51f61cda2be9cc9ee0b6e diff --git a/manifest.uuid b/manifest.uuid index 96763a4275..f0761ed34e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc6cce81565b17f886478bd51500bba2ed11ec1d \ No newline at end of file +3b964155f611c437d53d44feafa22f531942b1b4 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 0a8339bafb..8aef9d7731 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -535,6 +535,10 @@ static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){ if( pIndex==0 ) break; pIndex->aiRowEst[i] = v; if( *z==' ' ) z++; + if( memcmp(z, "unordered", 10)==0 ){ + pIndex->bUnordered = 1; + break; + } } return 0; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0825af4cdf..8d3e2b1144 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1462,6 +1462,7 @@ struct Index { int tnum; /* Page containing root of this index in database file */ u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ + u8 bUnordered; /* Use this index for == or IN queries only */ char *zColAff; /* String defining the affinity of each column */ Index *pNext; /* The next index associated with the same table */ Schema *pSchema; /* Schema containing this index */ diff --git a/src/where.c b/src/where.c index cdcaa98c01..00975e5fdc 100644 --- a/src/where.c +++ b/src/where.c @@ -2860,7 +2860,7 @@ static void bestBtreeIndex( } /* Determine the value of estBound. */ - if( nEqnColumn ){ + if( nEqnColumn && pProbe->bUnordered==0 ){ int j = pProbe->aiColumn[nEq]; if( findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE|WO_GT|WO_GE, pIdx) ){ WhereTerm *pTop = findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE, pIdx); @@ -2892,6 +2892,7 @@ static void bestBtreeIndex( ** will scan rows in a different order, set the bSort variable. */ if( pOrderBy ){ if( (wsFlags & WHERE_COLUMN_IN)==0 + && pProbe->bUnordered==0 && isSortingIndex(pParse, pWC->pMaskSet, pProbe, iCur, pOrderBy, nEq, wsFlags, &rev) ){ diff --git a/test/progress.test b/test/progress.test old mode 100755 new mode 100644 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 From 8b2b2e67fedc7ad8f5b64e9c02152dd473074901 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Apr 2011 01:14:12 +0000 Subject: [PATCH 02/19] Fix typos in documentation comments. No changes to code. FossilOrigin-Name: 9c64b5a99c5251818000e7d655f3a870589b631e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/main.c | 2 +- src/sqlite.h.in | 26 +++++++++++++------------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index a043600f2a..7f0072fc34 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sperformance\sregression:\s\sKeep\stwo\sbtree\smasks\sin\seach\sprepared\nstatement;\sone\sfor\sbtrees\sused\sand\sanother\sfor\sbtrees\sthat\srequire\slocks.\nOnly\stry\sto\slock\sthe\sbtrees\sidentified\sby\sthe\ssecond\smask. -D 2011-04-06T22:05:53.025 +C Fix\stypos\sin\sdocumentation\scomments.\s\sNo\schanges\sto\scode. +D 2011-04-07T01:14:12.525 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 5dad851457fdd249a4d4f41e94fe9cb11aedf1f2 +F src/main.c a8571665d43ff18f89a49d47a281605ce5ea825e F src/malloc.c 788f2ed928786dfe305b6783d551d6b1a9080976 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -178,7 +178,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 649a6f10f7eb7b52a5a28847773cb9968a828ae8 F src/shell.c a73b30067ec15f116d5d0c28880179898fbe3d0b -F src/sqlite.h.in 923630d8249b66cf8a266dd53d4d094cace80164 +F src/sqlite.h.in 4d28db70c37a1b17942820308eb59f211140da43 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 7b0150bfdab049b11bb2d055d065051ff734d113 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 61a6ccbe3c9c3ad5f35fb325e3c327cb19409925 -R 5fa436b215ae7db10b0b34b9477bdc0a +P 614de91a504d2231009a9de1305e31fce1b1c5a6 +R e68cf91f31b8f54b3f58e7c0f4d97cbb U drh -Z e891e0a53128468187772ad760452d05 +Z 8376cd3928f598b2a6d539c81827da5e diff --git a/manifest.uuid b/manifest.uuid index 507019b439..cfb71ef981 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -614de91a504d2231009a9de1305e31fce1b1c5a6 \ No newline at end of file +9c64b5a99c5251818000e7d655f3a870589b631e \ No newline at end of file diff --git a/src/main.c b/src/main.c index 1f923f57c3..4aaa61899c 100644 --- a/src/main.c +++ b/src/main.c @@ -515,7 +515,7 @@ int sqlite3_db_config(sqlite3 *db, int op, ...){ va_start(ap, op); switch( op ){ case SQLITE_DBCONFIG_LOOKASIDE: { - void *pBuf = va_arg(ap, void*); /* IMP: R-21112-12275 */ + void *pBuf = va_arg(ap, void*); /* IMP: R-26835-10964 */ int sz = va_arg(ap, int); /* IMP: R-47871-25994 */ int cnt = va_arg(ap, int); /* IMP: R-04460-53386 */ rc = setupLookaside(db, pBuf, sz, cnt); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 2604f67c07..ec7e502d4a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -727,7 +727,7 @@ struct sqlite3_io_methods { ** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most ** VFSes do not need this signal and should silently ignore this opcode. ** Applications should not call [sqlite3_file_control()] with this -** opcode as doing so may disrupt the operation of the specilized VFSes +** opcode as doing so may disrupt the operation of the specialized VFSes ** that do require it. */ #define SQLITE_FCNTL_LOCKSTATE 1 @@ -1309,7 +1309,7 @@ struct sqlite3_mem_methods { **
SQLITE_CONFIG_SCRATCH
**
^This option specifies a static memory buffer that SQLite can use for ** scratch memory. There are three arguments: A pointer an 8-byte -** aligned memory buffer from which the scrach allocations will be +** aligned memory buffer from which the scratch allocations will be ** drawn, the size of each scratch allocation (sz), ** and the maximum number of scratch allocations (N). The sz ** argument must be a multiple of 16. @@ -1461,7 +1461,7 @@ struct sqlite3_mem_methods { **
^This option takes three additional arguments that determine the ** [lookaside memory allocator] configuration for the [database connection]. ** ^The first argument (the third parameter to [sqlite3_db_config()] is a -** pointer to an memory buffer to use for lookaside memory. +** pointer to a memory buffer to use for lookaside memory. ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb ** may be NULL in which case SQLite will allocate the ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the @@ -1493,7 +1493,7 @@ struct sqlite3_mem_methods { **
^This option is used to enable or disable [CREATE TRIGGER | triggers]. ** There should be two additional arguments. ** The first argument is an integer which is 0 to disable triggers, -** positive to enable trigers or negative to leave the setting unchanged. +** positive to enable triggers or negative to leave the setting unchanged. ** The second parameter is a pointer to an integer into which ** is written 0 or 1 to indicate whether triggers are disabled or enabled ** following this call. The second parameter may be a NULL pointer, in @@ -2105,7 +2105,7 @@ void sqlite3_randomness(int N, void *P); /* ** CAPI3REF: Compile-Time Authorization Callbacks ** -** ^This routine registers a authorizer callback with a particular +** ^This routine registers an authorizer callback with a particular ** [database connection], supplied in the first argument. ** ^The authorizer callback is invoked as SQL statements are being compiled ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], @@ -2751,7 +2751,7 @@ int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); ** whether or not it requires a protected sqlite3_value. ** ** The terms "protected" and "unprotected" refer to whether or not -** a mutex is held. A internal mutex is held for a protected +** a mutex is held. An internal mutex is held for a protected ** sqlite3_value object but no mutex is held for an unprotected ** sqlite3_value object. If SQLite is compiled to be single-threaded ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) @@ -3437,7 +3437,7 @@ int sqlite3_reset(sqlite3_stmt *pStmt); ** are used to add SQL functions or aggregates or to redefine the behavior ** of existing SQL functions or aggregates. The only differences between ** these routines are the text encoding expected for -** the the second parameter (the name of the function being created) +** the second parameter (the name of the function being created) ** and the presence or absence of a destructor callback for ** the application data pointer. ** @@ -3482,7 +3482,7 @@ int sqlite3_reset(sqlite3_stmt *pStmt); ** callback only; NULL pointers must be passed as the xStep and xFinal ** parameters. ^An aggregate SQL function requires an implementation of xStep ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing -** SQL function or aggregate, pass NULL poiners for all three function +** SQL function or aggregate, pass NULL pointers for all three function ** callbacks. ** ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL, @@ -3916,7 +3916,7 @@ void sqlite3_result_zeroblob(sqlite3_context*, int n); ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin ** on an even byte address. ** -** ^The fourth argument, pArg, is a application data pointer that is passed +** ^The fourth argument, pArg, is an application data pointer that is passed ** through as the first argument to the collating function callback. ** ** ^The fifth argument, xCallback, is a pointer to the collating function. @@ -3932,7 +3932,7 @@ void sqlite3_result_zeroblob(sqlite3_context*, int n); ** by the eTextRep argument. The collating function must return an ** integer that is negative, zero, or positive ** if the first string is less than, equal to, or greater than the second, -** respectively. A collating function must alway return the same answer +** respectively. A collating function must always return the same answer ** given the same inputs. If two or more collating functions are registered ** to the same collation name (using different eTextRep values) then all ** must give an equivalent answer when invoked with equivalent strings. @@ -4344,7 +4344,7 @@ int sqlite3_release_memory(int); **
  • Memory accounting is disabled using a combination of the ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. -**
  • An alternative page cache implementation is specifed using +**
  • An alternative page cache implementation is specified using ** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...). **
  • The page cache allocates from its own memory pool supplied ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than @@ -4565,7 +4565,7 @@ typedef struct sqlite3_module sqlite3_module; ** CAPI3REF: Virtual Table Object ** KEYWORDS: sqlite3_module {virtual table module} ** -** This structure, sometimes called a a "virtual table module", +** This structure, sometimes called a "virtual table module", ** defines the implementation of a [virtual tables]. ** This structure consists mostly of methods for the module. ** @@ -4877,7 +4877,7 @@ typedef struct sqlite3_blob sqlite3_blob; ** This is true if any column of the row is changed, even a column ** other than the one the BLOB handle is open on.)^ ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for -** a expired BLOB handle fail with an return code of [SQLITE_ABORT]. +** an expired BLOB handle fail with a return code of [SQLITE_ABORT]. ** ^(Changes written into a BLOB prior to the BLOB expiring are not ** rolled back by the expiration of the BLOB. Such changes will eventually ** commit if the transaction continues to completion.)^ From 18e2d06b5cbe4546b0ebaba485916f37f8849e4d Mon Sep 17 00:00:00 2001 From: shaneh Date: Thu, 7 Apr 2011 01:54:14 +0000 Subject: [PATCH 03/19] Fix an issue with an analyze test. No code changes. FossilOrigin-Name: cddf79db83e5f121cc4ce8ab7ad3993fc96f5bc0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/analyze7.test | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 7f0072fc34..5bcc8e164c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos\sin\sdocumentation\scomments.\s\sNo\schanges\sto\scode. -D 2011-04-07T01:14:12.525 +C Fix\san\sissue\swith\san\sanalyze\stest.\s\sNo\scode\schanges. +D 2011-04-07T01:54:14.841 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -262,7 +262,7 @@ F test/analyze3.test d61f55d8b472fc6e713160b1e577f7a68e63f38b F test/analyze4.test 757b37875cf9bb528d46f74497bc789c88365045 F test/analyze5.test adc89b92fc9fee5ca1cb0bc8512f3206ad0fe5aa F test/analyze6.test c125622a813325bba1b4999040ddc213773c2290 -F test/analyze7.test 9cbca440bebc5142a875ad23947797ff52f7b37c +F test/analyze7.test 5508e7828164ea0b518ed219bed7320a481863d4 F test/async.test ad4ba51b77cd118911a3fe1356b0809da9c108c3 F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6 F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 614de91a504d2231009a9de1305e31fce1b1c5a6 -R e68cf91f31b8f54b3f58e7c0f4d97cbb -U drh -Z 8376cd3928f598b2a6d539c81827da5e +P 9c64b5a99c5251818000e7d655f3a870589b631e +R 500179b50473c33d369ec227056639d8 +U shaneh +Z 968ffb3f0f21b278cdb420506c09a125 diff --git a/manifest.uuid b/manifest.uuid index cfb71ef981..8aa7d0c31c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c64b5a99c5251818000e7d655f3a870589b631e \ No newline at end of file +cddf79db83e5f121cc4ce8ab7ad3993fc96f5bc0 \ No newline at end of file diff --git a/test/analyze7.test b/test/analyze7.test index a796ab78af..4892a2233a 100644 --- a/test/analyze7.test +++ b/test/analyze7.test @@ -87,7 +87,7 @@ ifcapable stat2 { # row count for (c=2) than it does for (c=?). do_test analyze7-3.2.2 { execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;} - } {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~102 rows)}} + } {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~51 rows)}} } else { # If ENABLE_STAT2 is not defined, the expected row count for (c=2) is the # same as that for (c=?). From cef8368093cda99984054703a8e6665509186d4c Mon Sep 17 00:00:00 2001 From: shaneh Date: Thu, 7 Apr 2011 03:41:01 +0000 Subject: [PATCH 04/19] Fix a couple of MSVC compiler warnings; FossilOrigin-Name: 748c9109c973e1d3e914adbe533f12af7783bfe4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c | 2 +- src/vdbetrace.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 5bcc8e164c..695550c2eb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sissue\swith\san\sanalyze\stest.\s\sNo\scode\schanges. -D 2011-04-07T01:54:14.841 +C Fix\sa\scouple\sof\sMSVC\scompiler\swarnings; +D 2011-04-07T03:41:01.582 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -177,7 +177,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 649a6f10f7eb7b52a5a28847773cb9968a828ae8 -F src/shell.c a73b30067ec15f116d5d0c28880179898fbe3d0b +F src/shell.c 9c8389796764f65d4506bcd614ac8061f4160d5c F src/sqlite.h.in 4d28db70c37a1b17942820308eb59f211140da43 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 7b0150bfdab049b11bb2d055d065051ff734d113 @@ -242,7 +242,7 @@ F src/vdbeapi.c e0e2672e0a96ae3f8575c8ecd02912a3e8a554a1 F src/vdbeaux.c 9ae5074b19bdff2d8806a278533956fb281510d5 F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b -F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5 +F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 F src/vtab.c b0abc931f95af94c9ffdf9f747eb191cda953123 F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9c64b5a99c5251818000e7d655f3a870589b631e -R 500179b50473c33d369ec227056639d8 +P cddf79db83e5f121cc4ce8ab7ad3993fc96f5bc0 +R f5987fe82b62f3ebf8c67ca2278e4153 U shaneh -Z 968ffb3f0f21b278cdb420506c09a125 +Z 3f3df3b5de717a7fadca60aa07e16ae2 diff --git a/manifest.uuid b/manifest.uuid index 8aa7d0c31c..6193c7c6f5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cddf79db83e5f121cc4ce8ab7ad3993fc96f5bc0 \ No newline at end of file +748c9109c973e1d3e914adbe533f12af7783bfe4 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 78788a5bb9..4f34ccceb6 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2199,7 +2199,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ /* convert testctrl text option to value. allow any unique prefix ** of the option name, or a numerical value. */ - n = strlen(azArg[1]); + n = strlen30(azArg[1]); for(i=0; i<(int)(sizeof(aCtrl)/sizeof(aCtrl[0])); i++){ if( strncmp(azArg[1], aCtrl[i].zCtrlName, n)==0 ){ if( testctrl<0 ){ diff --git a/src/vdbetrace.c b/src/vdbetrace.c index b422fa9eb1..de123b550f 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -85,7 +85,7 @@ char *sqlite3VdbeExpandSql( const char *zStart = zRawSql; while( *(zRawSql++)!='\n' && *zRawSql ); sqlite3StrAccumAppend(&out, "-- ", 3); - sqlite3StrAccumAppend(&out, zStart, zRawSql-zStart); + sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart)); } }else{ while( zRawSql[0] ){ From b73da5bd1c0512b7218a9ca84d2cdba59bc13f6f Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Apr 2011 05:17:32 +0000 Subject: [PATCH 05/19] Fix test script attach4.test so that it works with type 1 VFS implementations (no wal). And wal.test so that it work with a small default pager cache size. FossilOrigin-Name: 29c7b42587000704d61f49badd584ac7040c3d7d --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/attach4.test | 6 +++++- test/wal.test | 1 + 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 695550c2eb..aad936a7c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\sof\sMSVC\scompiler\swarnings; -D 2011-04-07T03:41:01.582 +C Fix\stest\sscript\sattach4.test\sso\sthat\sit\sworks\swith\stype\s1\sVFS\simplementations\s(no\swal).\sAnd\swal.test\sso\sthat\sit\swork\swith\sa\ssmall\sdefault\spager\scache\ssize. +D 2011-04-07T05:17:32.622 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -271,7 +271,7 @@ F test/async5.test f3592d79c84d6e83a5f50d3fd500445f7d97dfdf F test/attach.test 2bb09073d7d5499127db00f50780766dcea913e1 F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437 F test/attach3.test bd9830bc3a0d22ed1310c9bff6896927937017dc -F test/attach4.test d58859e62e0a70f17481eed01bf94995f72fea7f +F test/attach4.test 31f9eb0ca7bdbc393cc4657b877903a226a83d4b F test/attachmalloc.test 1d5b821a676f7bf0b00d87cc106b78966789ba57 F test/auth.test b047105c32da7db70b842fd24056723125ecc2ff F test/auth2.test 270baddc8b9c273682760cffba6739d907bd2882 @@ -861,7 +861,7 @@ F test/vtabE.test 7c4693638d7797ce2eda17af74292b97e705cc61 F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d -F test/wal.test bac92a13276ce9b65d3d5c9ff3411d24c795826c +F test/wal.test 5617ad308bfdb8a8885220d8a261a6096a8d7e57 F test/wal2.test e561a8c6fdd1c2cd1876f3e39757934e7b7361f8 F test/wal3.test 5c396cc22497244d627306f4c1d360167353f8dd F test/wal4.test 3404b048fa5e10605facaf70384e6d2943412e30 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P cddf79db83e5f121cc4ce8ab7ad3993fc96f5bc0 -R f5987fe82b62f3ebf8c67ca2278e4153 -U shaneh -Z 3f3df3b5de717a7fadca60aa07e16ae2 +P 748c9109c973e1d3e914adbe533f12af7783bfe4 +R 99d9581e40f5efb3517a0b9208c237e8 +U dan +Z e2fa6b1af58e1ead18709b6bc0b2be67 diff --git a/manifest.uuid b/manifest.uuid index 6193c7c6f5..a0c325fcd1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -748c9109c973e1d3e914adbe533f12af7783bfe4 \ No newline at end of file +29c7b42587000704d61f49badd584ac7040c3d7d \ No newline at end of file diff --git a/test/attach4.test b/test/attach4.test index fe7392610f..f597f5d035 100644 --- a/test/attach4.test +++ b/test/attach4.test @@ -74,7 +74,11 @@ do_test 1.4 { set L [list] set S "" foreach {name f} $files { - lappend L wal + if {[permutation] == "journaltest"} { + lappend L delete + } else { + lappend L wal + } append S " PRAGMA $name.journal_mode = WAL; UPDATE $name.tbl SET x = '$name'; diff --git a/test/wal.test b/test/wal.test index bc5df883ee..1aa70e0525 100644 --- a/test/wal.test +++ b/test/wal.test @@ -1544,6 +1544,7 @@ ifcapable autovacuum { } [expr 84 * 1024] do_test 24.4 { execsql { + PRAGMA cache_size = 200; PRAGMA incremental_vacuum; PRAGMA wal_checkpoint; } From 7329ed9b3821c0c847af29362375794a8da79437 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Apr 2011 10:09:00 +0000 Subject: [PATCH 06/19] Do not run multi-threaded Tcl tests if the library was built with SQLITE_MUTEX_NOOP defined. FossilOrigin-Name: e4e99606fdf1f1cecf914dc865b066bf07793d1f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test_config.c | 6 ++++++ test/thread_common.tcl | 3 +++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index aad936a7c2..70509467f7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stest\sscript\sattach4.test\sso\sthat\sit\sworks\swith\stype\s1\sVFS\simplementations\s(no\swal).\sAnd\swal.test\sso\sthat\sit\swork\swith\sa\ssmall\sdefault\spager\scache\ssize. -D 2011-04-07T05:17:32.622 +C Do\snot\srun\smulti-threaded\sTcl\stests\sif\sthe\slibrary\swas\sbuilt\swith\sSQLITE_MUTEX_NOOP\sdefined. +D 2011-04-07T10:09:00.583 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -198,7 +198,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2 -F src/test_config.c 62f0f8f934b1d5c7e4cd4f506ae453a1117b47d7 +F src/test_config.c 8f9599650fcd896f62a17be226ae3e439debb5e4 F src/test_demovfs.c 31050680fa6925b4f677cfd4fa965b5f19195e50 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_func.c cbdec5cededa0761daedde5baf06004a9bf416b5 @@ -694,7 +694,7 @@ F test/thread004.test f51dfc3936184aaf73ee85f315224baad272a87f F test/thread005.test bf5c374ca65dd89fd56c8fe511ccfb46875bda5e F test/thread1.test 862dd006d189e8b0946935db17399dcac2f8ef91 F test/thread2.test e08034b83fe9693ade77049732518e5b3d2d700d -F test/thread_common.tcl 2aa6f2fdcd4d6e461169c3e5ca098eebf643b863 +F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9 F test/threadtest3.c 0ed13e09690f6204d7455fac3b0e8ece490f6eef @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 748c9109c973e1d3e914adbe533f12af7783bfe4 -R 99d9581e40f5efb3517a0b9208c237e8 +P 29c7b42587000704d61f49badd584ac7040c3d7d +R d74328ff56374f7a92f06da23007061f U dan -Z e2fa6b1af58e1ead18709b6bc0b2be67 +Z bfc44684e4ef88e4862d7f932c4ec0cd diff --git a/manifest.uuid b/manifest.uuid index a0c325fcd1..a26ee76d9d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -29c7b42587000704d61f49badd584ac7040c3d7d \ No newline at end of file +e4e99606fdf1f1cecf914dc865b066bf07793d1f \ No newline at end of file diff --git a/src/test_config.c b/src/test_config.c index 6eee524c09..4dc6441f51 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -91,6 +91,12 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "mutex", "1", TCL_GLOBAL_ONLY); #endif +#ifdef SQLITE_MUTEX_NOOP + Tcl_SetVar2(interp, "sqlite_options", "mutex_noop", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "mutex_noop", "0", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_OMIT_ALTERTABLE Tcl_SetVar2(interp, "sqlite_options", "altertable", "0", TCL_GLOBAL_ONLY); #else diff --git a/test/thread_common.tcl b/test/thread_common.tcl index 9b7a95dd9a..6b17082ad4 100644 --- a/test/thread_common.tcl +++ b/test/thread_common.tcl @@ -89,6 +89,9 @@ proc run_thread_tests {{print_warning 0}} { ifcapable !mutex { set zProblem "SQLite build is not threadsafe" } + ifcapable mutex_noop { + set zProblem "SQLite build uses SQLITE_MUTEX_NOOP" + } if {[info commands sqlthread] eq ""} { set zProblem "SQLite build is not threadsafe" } From fe98f9b21694cb10ab213e0f90d548765270d95f Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Apr 2011 14:05:47 +0000 Subject: [PATCH 07/19] Avoid running thread1.test or thread2.test if SQLITE_MUTEX_NOOP is defined. FossilOrigin-Name: 532ae32ea0f5e821dac643cbc4b041c103cadfdc --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/thread1.test | 5 +---- test/thread2.test | 6 +----- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 70509467f7..518827889c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\srun\smulti-threaded\sTcl\stests\sif\sthe\slibrary\swas\sbuilt\swith\sSQLITE_MUTEX_NOOP\sdefined. -D 2011-04-07T10:09:00.583 +C Avoid\srunning\sthread1.test\sor\sthread2.test\sif\sSQLITE_MUTEX_NOOP\sis\sdefined. +D 2011-04-07T14:05:47.844 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -692,8 +692,8 @@ F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca F test/thread004.test f51dfc3936184aaf73ee85f315224baad272a87f F test/thread005.test bf5c374ca65dd89fd56c8fe511ccfb46875bda5e -F test/thread1.test 862dd006d189e8b0946935db17399dcac2f8ef91 -F test/thread2.test e08034b83fe9693ade77049732518e5b3d2d700d +F test/thread1.test df115faa10a4ba1d456e9d4d9ec165016903eae4 +F test/thread2.test f35d2106452b77523b3a2b7d1dcde2e5ee8f9e46 F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 29c7b42587000704d61f49badd584ac7040c3d7d -R d74328ff56374f7a92f06da23007061f +P e4e99606fdf1f1cecf914dc865b066bf07793d1f +R 42c41e910cfc7e1c1b9040c4c34f5e86 U dan -Z bfc44684e4ef88e4862d7f932c4ec0cd +Z e11fdaaab64fe55fe7338be760f5f876 diff --git a/manifest.uuid b/manifest.uuid index a26ee76d9d..4b9265b79f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e4e99606fdf1f1cecf914dc865b066bf07793d1f \ No newline at end of file +532ae32ea0f5e821dac643cbc4b041c103cadfdc \ No newline at end of file diff --git a/test/thread1.test b/test/thread1.test index 70bcc22c22..0618f2c66f 100644 --- a/test/thread1.test +++ b/test/thread1.test @@ -19,10 +19,7 @@ source $testdir/tester.tcl # Skip this whole file if the thread testing code is not enabled # -ifcapable !mutex { - finish_test - return -} +if {[run_thread_tests]==0} { finish_test ; return } if {[llength [info command thread_step]]==0 || [sqlite3 -has-codec]} { finish_test return diff --git a/test/thread2.test b/test/thread2.test index 253b3d61ca..dad2bf2c5f 100644 --- a/test/thread2.test +++ b/test/thread2.test @@ -17,11 +17,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl -ifcapable !mutex { - finish_test - return -} - +if {[run_thread_tests]==0} { finish_test ; return } # Skip this whole file if the thread testing code is not enabled # From 93b4fc78cf8a32f0b9c4563a77706034e56c6093 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Apr 2011 14:47:01 +0000 Subject: [PATCH 08/19] When searching a list of freelist trunk pages looking for a specific page to allocate, avoid unnecessary journalling of the unchanged trunk pages towards the start of the list. FossilOrigin-Name: d03d63d77ed144ac2c02a0245c4b4b070b79c88e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 10 ++++------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 518827889c..097db8a15d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\srunning\sthread1.test\sor\sthread2.test\sif\sSQLITE_MUTEX_NOOP\sis\sdefined. -D 2011-04-07T14:05:47.844 +C When\ssearching\sa\slist\sof\sfreelist\strunk\spages\slooking\sfor\sa\sspecific\spage\nto\sallocate,\savoid\sunnecessary\sjournalling\sof\sthe\sunchanged\strunk\spages\stowards\nthe\sstart\sof\sthe\slist. +D 2011-04-07T14:47:01.943 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b7529a6691f0fd534ae8ff622203c46a7f1b626b F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 4fcad108b612a4d33dac568b11d26e4d38ccbe35 +F src/btree.c 6a9164af8a2ef4612ee30b253635a9bd8e5e1b1b F src/btree.h 11753dd46597a20702bca8746cb4caa4486a82b5 F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 F src/build.c b7c993274ee2a029937b0bc4815bdef80b330017 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e4e99606fdf1f1cecf914dc865b066bf07793d1f -R 42c41e910cfc7e1c1b9040c4c34f5e86 -U dan -Z e11fdaaab64fe55fe7338be760f5f876 +P 532ae32ea0f5e821dac643cbc4b041c103cadfdc +R ada284aaaa309102c01ae8aa530bb601 +U drh +Z 52b476a7ff4c3a8d80844592d209d819 diff --git a/manifest.uuid b/manifest.uuid index 4b9265b79f..ada919f6d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -532ae32ea0f5e821dac643cbc4b041c103cadfdc \ No newline at end of file +d03d63d77ed144ac2c02a0245c4b4b070b79c88e \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index bfdc3d98a8..103a1f3230 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4819,7 +4819,7 @@ static int allocateBtreePage( goto end_allocate_page; } - k = get4byte(&pTrunk->aData[4]); + k = get4byte(&pTrunk->aData[4]); /* # of leaves on this trunk page */ if( k==0 && !searchList ){ /* The trunk has no leaves and the list is not being searched. ** So extract the trunk page itself and use it as the newly @@ -4904,10 +4904,6 @@ static int allocateBtreePage( u32 closest; Pgno iPage; unsigned char *aData = pTrunk->aData; - rc = sqlite3PagerWrite(pTrunk->pDbPage); - if( rc ){ - goto end_allocate_page; - } if( nearby>0 ){ u32 i; int dist; @@ -4937,11 +4933,12 @@ static int allocateBtreePage( TRACE(("ALLOCATE: %d was leaf %d of %d on trunk %d" ": %d more free pages\n", *pPgno, closest+1, k, pTrunk->pgno, n-1)); + rc = sqlite3PagerWrite(pTrunk->pDbPage); + if( rc ) goto end_allocate_page; if( closestpDbPage) ); noContent = !btreeGetHasContent(pBt, *pPgno); rc = btreeGetPage(pBt, *pPgno, ppPage, noContent); if( rc==SQLITE_OK ){ @@ -5010,6 +5007,7 @@ end_allocate_page: }else{ *ppPage = 0; } + assert( rc!=SQLITE_OK || sqlite3PagerIswriteable((*ppPage)->pDbPage) ); return rc; } From 1b855bbd57fec13036a3e3a2cf244e69a759e564 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Apr 2011 15:24:08 +0000 Subject: [PATCH 09/19] Add test case to verify [d03d63d77e] works. FossilOrigin-Name: bf78acb9dfacde0f08a5b3ceac13480f12a06168 --- manifest | 14 ++++---- manifest.uuid | 2 +- test/incrvacuum2.test | 76 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 097db8a15d..f1d58d0456 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\ssearching\sa\slist\sof\sfreelist\strunk\spages\slooking\sfor\sa\sspecific\spage\nto\sallocate,\savoid\sunnecessary\sjournalling\sof\sthe\sunchanged\strunk\spages\stowards\nthe\sstart\sof\sthe\slist. -D 2011-04-07T14:47:01.943 +C Add\stest\scase\sto\sverify\s[d03d63d77e]\sworks. +D 2011-04-07T15:24:08.318 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -494,7 +494,7 @@ F test/incrblob3.test aedbb35ea1b6450c33b98f2b6ed98e5020be8dc7 F test/incrblob_err.test c577c91d4ed9e8336cdb188b15d6ee2a6fe9604e F test/incrblobfault.test 917c0292224c64a56ef7215fd633a3a82f805be0 F test/incrvacuum.test 453d1e490d8f5ad2c9b3a54282a0690d6ae56462 -F test/incrvacuum2.test 9e22a794899c91b7d8c8e12eaacac8df249faafe +F test/incrvacuum2.test 33f8f47edf361e6f31f67c46c4963d3f6841bc07 F test/incrvacuum_ioerr.test 57d2f5777ab13fa03b87b262a4ea1bad5cfc0291 F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 532ae32ea0f5e821dac643cbc4b041c103cadfdc -R ada284aaaa309102c01ae8aa530bb601 -U drh -Z 52b476a7ff4c3a8d80844592d209d819 +P d03d63d77ed144ac2c02a0245c4b4b070b79c88e +R f5495057ba04c126989ad94dcb1c1777 +U dan +Z 4011134d338b456807276b30795357fc diff --git a/manifest.uuid b/manifest.uuid index ada919f6d9..f48873c287 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d03d63d77ed144ac2c02a0245c4b4b070b79c88e \ No newline at end of file +bf78acb9dfacde0f08a5b3ceac13480f12a06168 \ No newline at end of file diff --git a/test/incrvacuum2.test b/test/incrvacuum2.test index d8a391b713..2ecee12ab3 100644 --- a/test/incrvacuum2.test +++ b/test/incrvacuum2.test @@ -23,6 +23,7 @@ ifcapable {!autovacuum || !pragma} { return } +set testprefix incrvacuum2 # Create a database in incremental vacuum mode that has many # pages on the freelist. @@ -131,6 +132,79 @@ do_test incrvacuum2-3.2 { } } {} -integrity_check incremental2-3.3 +integrity_check incrvacuum2-3.3 + +ifcapable wal { + # At one point, when a specific page was being extracted from the b-tree + # free-list (e.g. during an incremental-vacuum), all trunk pages that + # occurred before the specific page in the free-list trunk were being + # written to the journal or wal file. This is not necessary. Only the + # extracted page and the page that contains the pointer to it need to + # be journalled. + # + # This problem was fixed by [d03d63d77e] (just before 3.7.6 release). + # + # This test case builds a database containing many free pages. Then runs + # "PRAGMA incremental_vacuum(1)" until the db contains zero free pages. + # Each "PRAGMA incremental_vacuum(1)" should modify at most 4 pages. The + # worst case is when a trunk page is removed from the end of the db file. + # In this case pages written are: + # + # 1. The previous trunk page (that contains a pointer to the recycled + # trunk page), and + # 2. The leaf page transformed into a trunk page to replace the recycled + # page, and + # 3. The trunk page that contained a pointer to the leaf page used + # in (2), and + # 4. Page 1. Page 1 is always updated, even in WAL mode, since it contains + # the "number of free-list pages" field. + # + db close + forcedelete test.db + sqlite3 db test.db + + do_execsql_test 4.1 { + PRAGMA page_size = 512; + PRAGMA auto_vacuum = 2; + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(randomblob(400)); + INSERT INTO t1 SELECT * FROM t1; -- 2 + INSERT INTO t1 SELECT * FROM t1; -- 4 + INSERT INTO t1 SELECT * FROM t1; -- 8 + INSERT INTO t1 SELECT * FROM t1; -- 16 + INSERT INTO t1 SELECT * FROM t1; -- 32 + INSERT INTO t1 SELECT * FROM t1; -- 128 + INSERT INTO t1 SELECT * FROM t1; -- 256 + INSERT INTO t1 SELECT * FROM t1; -- 512 + INSERT INTO t1 SELECT * FROM t1; -- 1024 + INSERT INTO t1 SELECT * FROM t1; -- 2048 + INSERT INTO t1 SELECT * FROM t1; -- 4096 + INSERT INTO t1 SELECT * FROM t1; -- 8192 + DELETE FROM t1 WHERE oid>512; + DELETE FROM t1; + } + + do_test 4.2 { + execsql { + PRAGMA journal_mode = WAL; + PRAGMA incremental_vacuum(1); + PRAGMA wal_checkpoint; + } + file size test.db-wal + } {1640} + + do_test 4.3 { + db close + sqlite3 db test.db + set maxsz 0 + while {[file size test.db] > [expr 512*3]} { + execsql { PRAGMA wal_checkpoint } + execsql { PRAGMA incremental_vacuum(1) } + set newsz [file size test.db-wal] + if {$newsz>$maxsz} {set maxsz $newsz} + } + set maxsz + } {2176} +} finish_test From 041e09f189b6432db5c02503413513e674fdbdd6 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Apr 2011 19:56:21 +0000 Subject: [PATCH 10/19] Change two new internal functions in where.c from global to file scope. FossilOrigin-Name: 5bbfa17d4d6db18f8077f758d70c1bc253b58e2e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f1d58d0456..f965a8c03f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scase\sto\sverify\s[d03d63d77e]\sworks. -D 2011-04-07T15:24:08.318 +C Change\stwo\snew\sinternal\sfunctions\sin\swhere.c\sfrom\sglobal\sto\sfile\sscope. +D 2011-04-07T19:56:21.304 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -247,7 +247,7 @@ F src/vtab.c b0abc931f95af94c9ffdf9f747eb191cda953123 F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 71e6808f74b9df913b5cdf242419b0edaf768310 +F src/where.c 9af3810842aa57c7de99dcb209e6a8b25acd5bb7 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d03d63d77ed144ac2c02a0245c4b4b070b79c88e -R f5495057ba04c126989ad94dcb1c1777 -U dan -Z 4011134d338b456807276b30795357fc +P bf78acb9dfacde0f08a5b3ceac13480f12a06168 +R a9f2f9a05093271e91b30b504fa13d37 +U drh +Z 889e513b13f7f64ff3dfde333fe1ea41 diff --git a/manifest.uuid b/manifest.uuid index f48873c287..ed3205e9f2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf78acb9dfacde0f08a5b3ceac13480f12a06168 \ No newline at end of file +5bbfa17d4d6db18f8077f758d70c1bc253b58e2e \ No newline at end of file diff --git a/src/where.c b/src/where.c index ca1fcf6d36..851d59fff5 100644 --- a/src/where.c +++ b/src/where.c @@ -2532,7 +2532,7 @@ range_est_fallback: ** for a UTF conversion required for comparison. The error is stored ** in the pParse structure. */ -int whereEqualScanEst( +static int whereEqualScanEst( Parse *pParse, /* Parsing & code generating context */ Index *p, /* The index whose left-most column is pTerm */ Expr *pExpr, /* Expression for VALUE in the x=VALUE constraint */ @@ -2589,7 +2589,7 @@ whereEqualScanEst_cancel: ** for a UTF conversion required for comparison. The error is stored ** in the pParse structure. */ -int whereInScanEst( +static int whereInScanEst( Parse *pParse, /* Parsing & code generating context */ Index *p, /* The index whose left-most column is pTerm */ ExprList *pList, /* The value list on the RHS of "x IN (v1,v2,v3,...)" */ From e620c5e5ba9c08b2c2cea1de2088ef74a73cf865 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Apr 2011 17:22:30 +0000 Subject: [PATCH 11/19] Fix incrvacuum2.test so that it works with the inmemory_journal permutation. FossilOrigin-Name: 7b8e176143bb8b55e34fd70cbfa639b1097b2c34 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/incrvacuum2.test | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f965a8c03f..65186f2ae7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\stwo\snew\sinternal\sfunctions\sin\swhere.c\sfrom\sglobal\sto\sfile\sscope. -D 2011-04-07T19:56:21.304 +C Fix\sincrvacuum2.test\sso\sthat\sit\sworks\swith\sthe\sinmemory_journal\spermutation. +D 2011-04-08T17:22:30.300 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -494,7 +494,7 @@ F test/incrblob3.test aedbb35ea1b6450c33b98f2b6ed98e5020be8dc7 F test/incrblob_err.test c577c91d4ed9e8336cdb188b15d6ee2a6fe9604e F test/incrblobfault.test 917c0292224c64a56ef7215fd633a3a82f805be0 F test/incrvacuum.test 453d1e490d8f5ad2c9b3a54282a0690d6ae56462 -F test/incrvacuum2.test 33f8f47edf361e6f31f67c46c4963d3f6841bc07 +F test/incrvacuum2.test ae04573b73ad52179f56e194fff0fbe43b509d23 F test/incrvacuum_ioerr.test 57d2f5777ab13fa03b87b262a4ea1bad5cfc0291 F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P bf78acb9dfacde0f08a5b3ceac13480f12a06168 -R a9f2f9a05093271e91b30b504fa13d37 -U drh -Z 889e513b13f7f64ff3dfde333fe1ea41 +P 5bbfa17d4d6db18f8077f758d70c1bc253b58e2e +R 2679548d57f4894ca8b9b15361fa4466 +U dan +Z eb5d19ab4e4ff1806dfa7f05c67aa6f7 diff --git a/manifest.uuid b/manifest.uuid index ed3205e9f2..e58dc16e39 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5bbfa17d4d6db18f8077f758d70c1bc253b58e2e \ No newline at end of file +7b8e176143bb8b55e34fd70cbfa639b1097b2c34 \ No newline at end of file diff --git a/test/incrvacuum2.test b/test/incrvacuum2.test index 2ecee12ab3..902517c949 100644 --- a/test/incrvacuum2.test +++ b/test/incrvacuum2.test @@ -198,6 +198,7 @@ ifcapable wal { sqlite3 db test.db set maxsz 0 while {[file size test.db] > [expr 512*3]} { + execsql { PRAGMA journal_mode = WAL } execsql { PRAGMA wal_checkpoint } execsql { PRAGMA incremental_vacuum(1) } set newsz [file size test.db-wal] From 1c152101cae48fa2d5f9cc979d1642a7ddde78e8 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Apr 2011 18:47:24 +0000 Subject: [PATCH 12/19] Add some rtree tests to the backcompat.test script. FossilOrigin-Name: 8ea3601cd11088ae4d62bd4a05d1675301b26ace --- manifest | 12 ++++---- manifest.uuid | 2 +- test/backcompat.test | 73 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 65186f2ae7..e366f2d986 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sincrvacuum2.test\sso\sthat\sit\sworks\swith\sthe\sinmemory_journal\spermutation. -D 2011-04-08T17:22:30.300 +C Add\ssome\srtree\stests\sto\sthe\sbackcompat.test\sscript. +D 2011-04-08T18:47:24.227 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -281,7 +281,7 @@ F test/autoindex1.test 860fc83f4fefb0c68ad062afc3ff43faa1534fc4 F test/autovacuum.test bb7c0885e6f8f1d633045de48f2b66082162766d F test/autovacuum_ioerr2.test 598b0663074d3673a9c1bc9a16e80971313bafe6 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 -F test/backcompat.test 541314d69ec9db3e03630b7616696ddc5048efb1 +F test/backcompat.test 0f23ff8d516acdf42f3d866a66d85306de2d02bc F test/backup.test 004d3b78bffd990741ab50133ed4347c25c172b1 F test/backup2.test b7c69f937c912e85ac8a5dbd1e1cf290302b2d49 F test/backup_ioerr.test 1f012e692f42c0442ae652443258f70e9f20fa38 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 5bbfa17d4d6db18f8077f758d70c1bc253b58e2e -R 2679548d57f4894ca8b9b15361fa4466 +P 7b8e176143bb8b55e34fd70cbfa639b1097b2c34 +R 721738e1b7737b5721b6d7302a3c4ca3 U dan -Z eb5d19ab4e4ff1806dfa7f05c67aa6f7 +Z 88b5a8ea4fcbb765bca47e95e089b60f diff --git a/manifest.uuid b/manifest.uuid index e58dc16e39..704f01b16d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7b8e176143bb8b55e34fd70cbfa639b1097b2c34 \ No newline at end of file +8ea3601cd11088ae4d62bd4a05d1675301b26ace \ No newline at end of file diff --git a/test/backcompat.test b/test/backcompat.test index 3b11607274..fa643f9b76 100644 --- a/test/backcompat.test +++ b/test/backcompat.test @@ -369,4 +369,77 @@ do_allbackcompat_test { } } +#------------------------------------------------------------------------- +# Test that Rtree tables may be read/written by different versions of +# SQLite. +# +set contents { + CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2, y1, y2); +} +foreach {id x1 x2 y1 y2} { + 1 -47.64 43.87 33.86 34.42 2 -21.51 17.32 2.05 31.04 + 3 -43.67 -38.33 -19.79 3.43 4 32.41 35.16 9.12 19.82 + 5 33.28 34.87 14.78 28.26 6 49.31 116.59 -9.87 75.09 + 7 -14.93 34.51 -17.64 64.09 8 -43.05 23.43 -1.19 69.44 + 9 44.79 133.56 28.09 80.30 10 -2.66 81.47 -41.38 -10.46 + 11 -42.89 -3.54 15.76 71.63 12 -3.50 84.96 -11.64 64.95 + 13 -45.69 26.25 11.14 55.06 14 -44.09 11.23 17.52 44.45 + 15 36.23 133.49 -19.38 53.67 16 -17.89 81.54 14.64 50.61 + 17 -41.97 -24.04 -39.43 28.95 18 -5.85 7.76 -6.38 47.02 + 19 18.82 27.10 42.82 100.09 20 39.17 113.45 26.14 73.47 + 21 22.31 103.17 49.92 106.05 22 -43.06 40.38 -1.75 76.08 + 23 2.43 57.27 -14.19 -3.83 24 -47.57 -4.35 8.93 100.06 + 25 -37.47 49.14 -29.11 8.81 26 -7.86 75.72 49.34 107.42 + 27 1.53 45.49 20.36 49.74 28 -48.48 32.54 28.81 54.45 + 29 2.67 39.77 -4.05 13.67 30 4.11 62.88 -47.44 -5.72 + 31 -21.47 51.75 37.25 116.09 32 45.59 111.37 -6.43 43.64 + 33 35.23 48.29 23.54 113.33 34 16.61 68.35 -14.69 65.97 + 35 13.98 16.60 48.66 102.87 36 19.74 23.84 31.15 77.27 + 37 -27.61 24.43 7.96 94.91 38 -34.77 12.05 -22.60 -6.29 + 39 -25.83 8.71 -13.48 -12.53 40 -17.11 -1.01 18.06 67.89 + 41 14.13 71.72 -3.78 39.25 42 23.75 76.00 -16.30 8.23 + 43 -39.15 28.63 38.12 125.88 44 48.62 86.09 36.49 102.95 + 45 -31.39 -21.98 2.52 89.78 46 5.65 56.04 15.94 89.10 + 47 18.28 95.81 46.46 143.08 48 30.93 102.82 -20.08 37.36 + 49 -20.78 -3.48 -5.58 35.46 50 49.85 90.58 -24.48 46.29 +} { +if {$x1 >= $x2 || $y1 >= $y2} { error "$x1 $x2 $y1 $y2" } + append contents "INSERT INTO t1 VALUES($id, $x1, $x2, $y1, $y2);" +} +set queries { + 1 "SELECT id FROM t1 WHERE x1>10 AND x2<44" + 2 "SELECT id FROM t1 WHERE y1<100" + 3 "SELECT id FROM t1 WHERE y1<100 AND x1>0" + 4 "SELECT id FROM t1 WHERE y1>10 AND x1>0 AND x2<50 AND y2<550" +} +do_allbackcompat_test { + if {[code1 {set ::sqlite_options(fts3)}] + && [code2 {set ::sqlite_options(fts3)}] + } { + + do_test backcompat-4.1 { sql1 $contents } {} + + foreach {n q} $::queries { + do_test backcompat-4.2.$n [list sql1 $q] [sql2 $q] + } + + do_test backcompat-4.3 { sql1 { + INSERT INTO t1 SELECT id+100, x1+10.0, x2+10.0, y1-10.0, y2-10.0 FROM t1; + } } {} + + foreach {n q} $::queries { + do_test backcompat-4.4.$n [list sql1 $q] [sql2 $q] + } + + do_test backcompat-4.5 { sql2 { + INSERT INTO t1 SELECT id+200, x1+20.0, x2+20.0, y1-20.0, y2-20.0 FROM t1; + } } {} + + foreach {n q} $::queries { + do_test backcompat-4.6.$n [list sql1 $q] [sql2 $q] + } + + } +} + finish_test From ea6dc4458b335a4fafd7d736c3e23f2e2e765ef8 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Apr 2011 21:35:26 +0000 Subject: [PATCH 13/19] Always make sure the left-hand side of the IS NOT NULL operator is a smiple column, not a general expression, before applying the IS NOT NULL query optimization. FossilOrigin-Name: 543f75a6abe3aa4f49df43e71a462702d40b3251 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/where.c | 5 ++++- test/analyze5.test | 2 ++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e366f2d986..a1fe7b9d14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssome\srtree\stests\sto\sthe\sbackcompat.test\sscript. -D 2011-04-08T18:47:24.227 +C Always\smake\ssure\sthe\sleft-hand\sside\sof\sthe\sIS\sNOT\sNULL\soperator\sis\sa\nsmiple\scolumn,\snot\sa\sgeneral\sexpression,\sbefore\sapplying\sthe\sIS\sNOT\sNULL\nquery\soptimization. +D 2011-04-08T21:35:26.364 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -247,7 +247,7 @@ F src/vtab.c b0abc931f95af94c9ffdf9f747eb191cda953123 F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 9af3810842aa57c7de99dcb209e6a8b25acd5bb7 +F src/where.c 494d106959a492838ab3723e284de46ddd520da1 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 @@ -260,7 +260,7 @@ F test/analyze.test c8cb89e8736336f1f0646c8123e6028a14c7b55e F test/analyze2.test 8f2b1534d43f5547ce9a6b736c021d4192c75be3 F test/analyze3.test d61f55d8b472fc6e713160b1e577f7a68e63f38b F test/analyze4.test 757b37875cf9bb528d46f74497bc789c88365045 -F test/analyze5.test adc89b92fc9fee5ca1cb0bc8512f3206ad0fe5aa +F test/analyze5.test 1de8d66b11aae5a1453aa042d62e834a476bac9c F test/analyze6.test c125622a813325bba1b4999040ddc213773c2290 F test/analyze7.test 5508e7828164ea0b518ed219bed7320a481863d4 F test/async.test ad4ba51b77cd118911a3fe1356b0809da9c108c3 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7b8e176143bb8b55e34fd70cbfa639b1097b2c34 -R 721738e1b7737b5721b6d7302a3c4ca3 -U dan -Z 88b5a8ea4fcbb765bca47e95e089b60f +P 8ea3601cd11088ae4d62bd4a05d1675301b26ace +R 7e699a3cf12fb4b90da6a0d2b765dc1b +U drh +Z b346c2d4f65ea7f3ece8de7fdcc289fd diff --git a/manifest.uuid b/manifest.uuid index 704f01b16d..92e5270f31 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ea3601cd11088ae4d62bd4a05d1675301b26ace \ No newline at end of file +543f75a6abe3aa4f49df43e71a462702d40b3251 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 851d59fff5..5c6d158363 100644 --- a/src/where.c +++ b/src/where.c @@ -1342,7 +1342,10 @@ static void exprAnalyze( ** of the loop. Without the TERM_VNULL flag, the not-null check at ** the start of the loop will prevent any results from being returned. */ - if( pExpr->op==TK_NOTNULL && pExpr->pLeft->iColumn>=0 ){ + if( pExpr->op==TK_NOTNULL + && pExpr->pLeft->op==TK_COLUMN + && pExpr->pLeft->iColumn>=0 + ){ Expr *pNewExpr; Expr *pLeft = pExpr->pLeft; int idxNew; diff --git a/test/analyze5.test b/test/analyze5.test index 224433b7df..a0469da125 100644 --- a/test/analyze5.test +++ b/test/analyze5.test @@ -209,6 +209,8 @@ foreach {testid where index rows} { 502 {x IS NULL} {} 100 503 {x=1} t1x 50 504 {x IS NOT NULL} t1x 25 + 505 {+x IS NOT NULL} {} 500 + 506 {upper(x) IS NOT NULL} {} 500 } { # Verify that the expected index is used with the expected row count From 2b89fbcb1ecf6cdae61ecb4e7b6433801f7970ed Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 Apr 2011 02:09:44 +0000 Subject: [PATCH 14/19] Do not do a backup if the number of reserved bytes in the source and destination do not match. Try to make the match, but if unable fail. FossilOrigin-Name: 0ca8a2332b28d88585dc890e5162b095e783fc20 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/backup.c | 22 ++++++++++++++++++++-- src/prepare.c | 2 +- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index a1fe7b9d14..1c6fe4c3e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Always\smake\ssure\sthe\sleft-hand\sside\sof\sthe\sIS\sNOT\sNULL\soperator\sis\sa\nsmiple\scolumn,\snot\sa\sgeneral\sexpression,\sbefore\sapplying\sthe\sIS\sNOT\sNULL\nquery\soptimization. -D 2011-04-08T21:35:26.364 +C Do\snot\sdo\sa\sbackup\sif\sthe\snumber\sof\sreserved\sbytes\sin\sthe\ssource\sand\ndestination\sdo\snot\smatch.\s\sTry\sto\smake\sthe\smatch,\sbut\sif\sunable\sfail. +D 2011-04-09T02:09:44.933 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -118,7 +118,7 @@ F src/alter.c 280f5c04b11b492703a342222b3de0a999445280 F src/analyze.c a1ad9f4d8aac055c4a4bbd99073e2e78fe66129c F src/attach.c 7cae2cf0c14762ce14c074a860ec52890a973a56 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c b7529a6691f0fd534ae8ff622203c46a7f1b626b +F src/backup.c 8d738af17e87eb6fcf2dab8b26153a918a114e48 F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c 6a9164af8a2ef4612ee30b253635a9bd8e5e1b1b @@ -171,7 +171,7 @@ F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c d548e31beafa792d1994b663a29a5303569efc4e F src/pragma.c 49c90ab27a4339d4b5bc0b03c08cbcf20ed8d454 -F src/prepare.c 206e1f06479fb5f756592bded468bd3ece3f41d4 +F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 F src/printf.c 585a36b6a963df832cfb69505afa3a34ed5ef8a1 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8ea3601cd11088ae4d62bd4a05d1675301b26ace -R 7e699a3cf12fb4b90da6a0d2b765dc1b +P 543f75a6abe3aa4f49df43e71a462702d40b3251 +R ecb9137cdfc6a112de5c41c40942b0a2 U drh -Z b346c2d4f65ea7f3ece8de7fdcc289fd +Z e9521ab4b4c4425c6bb8ec5417657a53 diff --git a/manifest.uuid b/manifest.uuid index 92e5270f31..bc219ca403 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -543f75a6abe3aa4f49df43e71a462702d40b3251 \ No newline at end of file +0ca8a2332b28d88585dc890e5162b095e783fc20 \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index c062744c5c..5e45a00258 100644 --- a/src/backup.c +++ b/src/backup.c @@ -219,6 +219,10 @@ static int backupOnePage(sqlite3_backup *p, Pgno iSrcPg, const u8 *zSrcData){ int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest); const int nCopy = MIN(nSrcPgsz, nDestPgsz); const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz; +#ifdef SQLITE_HAS_CODEC + int nSrcReserve = sqlite3BtreeGetReserve(p->pSrc); + int nDestReserve = sqlite3BtreeGetReserve(p->pDest); +#endif int rc = SQLITE_OK; i64 iOff; @@ -237,11 +241,22 @@ static int backupOnePage(sqlite3_backup *p, Pgno iSrcPg, const u8 *zSrcData){ #ifdef SQLITE_HAS_CODEC /* Backup is not possible if the page size of the destination is changing - ** a a codec is in use. + ** and a codec is in use. */ if( nSrcPgsz!=nDestPgsz && sqlite3PagerGetCodec(pDestPager)!=0 ){ rc = SQLITE_READONLY; } + + /* Backup is not possible if the number of bytes of reserve space differ + ** between source and destination. If there is a difference, try to + ** fix the destination to agree with the source. If that is not possible, + ** then the backup cannot proceed. + */ + if( nSrcReserve!=nDestReserve ){ + u32 newPgsz = nSrcPgsz; + rc = sqlite3PagerSetPagesize(pDestPager, &newPgsz, nSrcReserve); + if( rc==SQLITE_OK && newPgsz!=nSrcPgsz ) rc = SQLITE_READONLY; + } #endif /* This loop runs once for each destination page spanned by the source @@ -607,7 +622,10 @@ void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){ ** has been modified by a transaction on the source pager. Copy ** the new data into the backup. */ - int rc = backupOnePage(p, iPage, aData); + int rc; + if( p->pDestDb ) sqlite3_mutex_enter(p->pDestDb->mutex); + rc = backupOnePage(p, iPage, aData); + if( p->pDestDb ) sqlite3_mutex_leave(p->pDestDb->mutex); assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED ); if( rc!=SQLITE_OK ){ p->rc = rc; diff --git a/src/prepare.c b/src/prepare.c index b5edaf5032..fc45b8e6aa 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -34,7 +34,7 @@ static void corruptSchema( "%s - %s", *pData->pzErrMsg, zExtra); } } - pData->rc = db->mallocFailed ? SQLITE_NOMEM : SQLITE_CORRUPT; + pData->rc = db->mallocFailed ? SQLITE_NOMEM : SQLITE_CORRUPT_BKPT; } /* From 9f6106f5ee181bec83544572a2a6810df38c943f Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 Apr 2011 02:34:33 +0000 Subject: [PATCH 15/19] When ATTACH-ing a new database to an existing database with a codec, do not enable the codec in the attached database if it is not enabled in the existing database and it is not requested by the USING clause. FossilOrigin-Name: 4caa5fc86e7fe404cd188713277f2801cd02dbc9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/attach.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1c6fe4c3e0..e52034906d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sdo\sa\sbackup\sif\sthe\snumber\sof\sreserved\sbytes\sin\sthe\ssource\sand\ndestination\sdo\snot\smatch.\s\sTry\sto\smake\sthe\smatch,\sbut\sif\sunable\sfail. -D 2011-04-09T02:09:44.933 +C When\sATTACH-ing\sa\snew\sdatabase\sto\san\sexisting\sdatabase\swith\sa\scodec,\sdo\nnot\senable\sthe\scodec\sin\sthe\sattached\sdatabase\sif\sit\sis\snot\senabled\sin\sthe\nexisting\sdatabase\sand\sit\sis\snot\srequested\sby\sthe\sUSING\sclause. +D 2011-04-09T02:34:33.149 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -116,7 +116,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 280f5c04b11b492703a342222b3de0a999445280 F src/analyze.c a1ad9f4d8aac055c4a4bbd99073e2e78fe66129c -F src/attach.c 7cae2cf0c14762ce14c074a860ec52890a973a56 +F src/attach.c 7f97ca76ef2453440170929531a9c778267c0830 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 8d738af17e87eb6fcf2dab8b26153a918a114e48 F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 543f75a6abe3aa4f49df43e71a462702d40b3251 -R ecb9137cdfc6a112de5c41c40942b0a2 +P 0ca8a2332b28d88585dc890e5162b095e783fc20 +R b19292a0a4e4c797c8f7e19da3cea01c U drh -Z e9521ab4b4c4425c6bb8ec5417657a53 +Z 6219854df534fe7fd4126ed86b170468 diff --git a/manifest.uuid b/manifest.uuid index bc219ca403..d14c40154d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0ca8a2332b28d88585dc890e5162b095e783fc20 \ No newline at end of file +4caa5fc86e7fe404cd188713277f2801cd02dbc9 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index fe88aa73cd..bda1c87445 100644 --- a/src/attach.c +++ b/src/attach.c @@ -176,7 +176,9 @@ static void attachFunc( case SQLITE_NULL: /* No key specified. Use the key from the main database */ sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey); - rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey); + if( nKey>0 || sqlite3BtreeGetReserve(db->aDb[0].pBt)>0 ){ + rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey); + } break; } } From 2184fc75a229a881b1c265f135c5bb114704cc28 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 Apr 2011 03:04:13 +0000 Subject: [PATCH 16/19] Back out the SQLITE_OMIT_UNIQUE_ENFORCEMENT compile-option. It is an unneeded complication. FossilOrigin-Name: 927e955b93e869727c55b784401de3ea07bee257 --- manifest | 17 ++--- manifest.uuid | 2 +- src/ctime.c | 3 - src/insert.c | 9 +-- src/test_config.c | 6 -- test/omitunique.test | 170 ------------------------------------------- 6 files changed, 10 insertions(+), 197 deletions(-) delete mode 100644 test/omitunique.test diff --git a/manifest b/manifest index e52034906d..5a7b5d2018 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sATTACH-ing\sa\snew\sdatabase\sto\san\sexisting\sdatabase\swith\sa\scodec,\sdo\nnot\senable\sthe\scodec\sin\sthe\sattached\sdatabase\sif\sit\sis\snot\senabled\sin\sthe\nexisting\sdatabase\sand\sit\sis\snot\srequested\sby\sthe\sUSING\sclause. -D 2011-04-09T02:34:33.149 +C Back\sout\sthe\sSQLITE_OMIT_UNIQUE_ENFORCEMENT\scompile-option.\s\sIt\sis\san\sunneeded\ncomplication. +D 2011-04-09T03:04:13.095 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -127,7 +127,7 @@ F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 F src/build.c b7c993274ee2a029937b0bc4815bdef80b330017 F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac -F src/ctime.c 52ff72f966cee3087e0138a3ec69371c22be3c01 +F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b F src/delete.c 7a24fcc9a31664d145acb97ce56b6d9f249a25e4 F src/expr.c e3cf0957c6b8faaaf7386a3bc69e53c0dc9705be @@ -138,7 +138,7 @@ F src/global.c 02335177cf6946fe5525c6f0755cf181140debf3 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 6873a0b359e538d0568a8b459ca630edef8dde2c +F src/insert.c acfb89fe4a73d703e425e167bfcc72985f4299ae F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e @@ -198,7 +198,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2 -F src/test_config.c 8f9599650fcd896f62a17be226ae3e439debb5e4 +F src/test_config.c d536042f27226b4639f0f87d4795fd37428a9ddf F src/test_demovfs.c 31050680fa6925b4f677cfd4fa965b5f19195e50 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_func.c cbdec5cededa0761daedde5baf06004a9bf416b5 @@ -593,7 +593,6 @@ F test/notify2.test 195a467e021f74197be2c4fb02d6dee644b8d8db F test/notify3.test d60923e186e0900f4812a845fcdfd8eea096e33a F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 -F test/omitunique.test bbb2ec4345d9125d9ee21cd9488d97a163020d5f F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec F test/oserror.test 498d8337e9d15543eb7b004fef8594bf204ff43c F test/pager1.test d8672fd0af5f4f9b99b06283d00f01547809bebe @@ -927,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 0ca8a2332b28d88585dc890e5162b095e783fc20 -R b19292a0a4e4c797c8f7e19da3cea01c +P 4caa5fc86e7fe404cd188713277f2801cd02dbc9 +R 7c13920af52add3fb4004361c1b744b2 U drh -Z 6219854df534fe7fd4126ed86b170468 +Z f0a05ecbdcea6caa1b19a9a2e8b6f008 diff --git a/manifest.uuid b/manifest.uuid index d14c40154d..140a8fe496 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4caa5fc86e7fe404cd188713277f2801cd02dbc9 \ No newline at end of file +927e955b93e869727c55b784401de3ea07bee257 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index a04c567b40..a128f61a69 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -302,9 +302,6 @@ static const char * const azCompileOpt[] = { #ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION "OMIT_TRUNCATE_OPTIMIZATION", #endif -#ifdef SQLITE_OMIT_UNIQUE_ENFORCEMENT - "OMIT_UNIQUE_ENFORCEMENT", -#endif #ifdef SQLITE_OMIT_UTF16 "OMIT_UTF16", #endif diff --git a/src/insert.c b/src/insert.c index f8112f0103..588a84f36d 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1312,9 +1312,8 @@ void sqlite3GenerateConstraintChecks( */ for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){ int regIdx; -#ifndef SQLITE_OMIT_UNIQUE_ENFORCEMENT int regR; -#endif + if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */ /* Create a key for accessing the index entry */ @@ -1332,11 +1331,6 @@ void sqlite3GenerateConstraintChecks( sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx->nColumn+1); -#ifdef SQLITE_OMIT_UNIQUE_ENFORCEMENT - sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1); - continue; /* Treat pIdx as if it is not a UNIQUE index */ -#else - /* Find out what action to take in case there is an indexing conflict */ onError = pIdx->onError; if( onError==OE_None ){ @@ -1410,7 +1404,6 @@ void sqlite3GenerateConstraintChecks( } sqlite3VdbeJumpHere(v, j3); sqlite3ReleaseTempReg(pParse, regR); -#endif } if( pbMayReplace ){ diff --git a/src/test_config.c b/src/test_config.c index 4dc6441f51..03d2f4e976 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -481,12 +481,6 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double", Tcl_SetVar2(interp, "sqlite_options", "truncate_opt", "1", TCL_GLOBAL_ONLY); #endif -#ifdef SQLITE_OMIT_UNIQUE_ENFORCEMENT - Tcl_SetVar2(interp, "sqlite_options", "unique_enforcement", "0", TCL_GLOBAL_ONLY); -#else - Tcl_SetVar2(interp, "sqlite_options", "unique_enforcement", "1", TCL_GLOBAL_ONLY); -#endif - #ifdef SQLITE_OMIT_UTF16 Tcl_SetVar2(interp, "sqlite_options", "utf16", "0", TCL_GLOBAL_ONLY); #else diff --git a/test/omitunique.test b/test/omitunique.test deleted file mode 100644 index 83a2a95bdc..0000000000 --- a/test/omitunique.test +++ /dev/null @@ -1,170 +0,0 @@ -# 2011 March 10 -# -# The author disclaims copyright to this source code. In place of -# a legal notice, here is a blessing: -# -# May you do good and not evil. -# May you find forgiveness for yourself and forgive others. -# May you share freely, never taking more than you give. -# -#*********************************************************************** -# This file implements regression tests for SQLite library. The -# focus of this file is testing the SQLITE_OMIT_UNIQUE_ENFORCEMENT -# compiler option. -# - -set testdir [file dirname $argv0] -source $testdir/tester.tcl - -set uniq_enforced 1 -ifcapable !unique_enforcement { - set uniq_enforced 0 -} - -# table with UNIQUE keyword on column -do_test omitunique-1.1 { - catchsql { CREATE TABLE t1(a TEXT UNIQUE); } -} {0 {}} - -# table with UNIQUE clause on column -do_test omitunique-1.2 { - catchsql { CREATE TABLE t2(a TEXT, UNIQUE(a)); } -} {0 {}} - -# table with UNIQUE index on column -do_test omitunique-1.3 { - catchsql { - CREATE TABLE t3(a TEXT); - CREATE UNIQUE INDEX t3a ON t3(a); - } -} {0 {}} - -# table with regular index on column -do_test omitunique-1.4 { - catchsql { - CREATE TABLE t4(a TEXT); - CREATE INDEX t4a ON t4(a); - } -} {0 {}} - -# table with no index on column -do_test omitunique-1.5 { - catchsql { CREATE TABLE t5(a TEXT); } -} {0 {}} - -# run our tests using several table/index forms -foreach {j tbl uniq cnt qp_est stat_enforce stat_omit } { -1 {t1} 1 1 1 {2 1} {9 9} -2 {t2} 1 1 1 {2 1} {9 9} -3 {t3} 1 1 1 {2 1} {9 9} -4 {t4} 0 9 10 {9 9} {9 9} -5 {t5} 0 9 100000 9 9 -} { - - do_test omitunique-2.0.$j.1 { - catchsql [ subst {INSERT INTO $tbl (a) VALUES('abc'); }] - } {0 {}} - do_test omitunique-2.0.$j.2 { - catchsql [ subst {INSERT INTO $tbl (a) VALUES('123'); }] - } {0 {}} - - # check various INSERT commands - foreach {i cmd err} { - 1 {INSERT} 1 - 2 {INSERT OR IGNORE} 0 - 3 {INSERT OR REPLACE} 0 - 4 {REPLACE} 0 - 5 {INSERT OR FAIL} 1 - 6 {INSERT OR ABORT} 1 - 7 {INSERT OR ROLLBACK} 1 - } { - - ifcapable explain { - set x [execsql [ subst { EXPLAIN $cmd INTO $tbl (a) VALUES('abc'); }]] - ifcapable unique_enforcement { - do_test omitunique-2.1.$j.$i.1 { - regexp { IsUnique } $x - } $uniq - } - ifcapable !unique_enforcement { - do_test omitunique-2.1.$j.$i.1 { - regexp { IsUnique } $x - } {0} - } - } - - if { $uniq_enforced==0 || $uniq==0 || $err==0 } { - set msg {0 {}} - } { - set msg {1 {column a is not unique}} - } - do_test omitunique-2.1.$j.$i.3 { - catchsql [ subst {$cmd INTO $tbl (a) VALUES('abc'); }] - } $msg - - } - # end foreach cmd - - # check UPDATE command - ifcapable explain { - set x [execsql [ subst { EXPLAIN UPDATE $tbl SET a='abc'; }]] - ifcapable unique_enforcement { - do_test omitunique-2.2.$j.1 { - regexp { IsUnique } $x - } $uniq - } - ifcapable !unique_enforcement { - do_test omitunique-2.2.$j.1 { - regexp { IsUnique } $x - } {0} - } - } - if { $uniq_enforced==0 || $uniq==0 } { - set msg {0 {}} - } { - set msg {1 {column a is not unique}} - } - do_test omitunique-2.2.$j.3 { - catchsql [ subst { UPDATE $tbl SET a='abc'; }] - } $msg - - # check record counts - do_test omitunique-2.3.$j { - execsql [ subst { SELECT count(*) FROM $tbl WHERE a='abc'; }] - } $cnt - - # make sure the query planner row estimate not affected because of omit enforcement - ifcapable explain { - do_test omitunique-2.4.$j { - set x [ execsql [ subst { EXPLAIN QUERY PLAN SELECT count(*) FROM $tbl WHERE a='abc'; }]] - set y [ subst {~$qp_est row} ] - regexp $y $x - } {1} - } - - # make sure we omit extra OP_Next opcodes when the UNIQUE constraints - # mean there will only be a single pass through the code - ifcapable explain { - set x [execsql [ subst { EXPLAIN SELECT * FROM $tbl WHERE a='abc'; }]] - do_test omitunique-2.5.$j { - if { [ regexp { Next } $x ] } { expr { 0 } } { expr { 1 } } - } $uniq - } - - # make sure analyze index stats correct - ifcapable analyze { - if { $uniq_enforced==0 } { - set msg [ list $stat_omit ] - } { - set msg [ list $stat_enforce ] - } - do_test omitunique-2.6.$j { - execsql [ subst { ANALYZE $tbl; } ] - execsql [ subst { SELECT stat FROM sqlite_stat1 WHERE tbl='$tbl'; } ] - } $msg - } - -} -# end foreach tbl - -finish_test From 7687c83d4c8837e42d6b813695fec95afd00dc9d Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 9 Apr 2011 15:39:02 +0000 Subject: [PATCH 17/19] Add an OP_VerifyCookie instruction to "CREATE XXX IF NOT EXISTS" commands. This way, if the specified database object existed when the statement was compiled but removed from the database before sqlite3_step() was called, the statement still works as expected (and creates the object). FossilOrigin-Name: b9dbd9936191666c3fc9889e938344a82cc03aeb --- manifest | 17 ++++++----- manifest.uuid | 2 +- src/build.c | 6 ++++ src/trigger.c | 3 ++ test/exists.test | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 test/exists.test diff --git a/manifest b/manifest index 79217168e8..7b7d0cd93d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sthe\skeyword\s"unordered"\sappears\sat\sthe\send\sof\sthe\sSQLITE_STAT1.STAT\s\ncolumn\sfor\san\sindex,\sthen\suse\sthat\sindex\sfor\sequality\slookups\sonly,\snever\s\nfor\srange\squeries\sor\ssorting.\s\sThis\sfeature\sis\scurrently\sundocumented\sand\nmy\schange\sor\sbe\sremoved\sin\sa\sfuture\srelease. -D 2011-04-09T03:20:59.281 +C Add\san\sOP_VerifyCookie\sinstruction\sto\s"CREATE\sXXX\sIF\sNOT\sEXISTS"\scommands.\sThis\sway,\sif\sthe\sspecified\sdatabase\sobject\sexisted\swhen\sthe\sstatement\swas\scompiled\sbut\sremoved\sfrom\sthe\sdatabase\sbefore\ssqlite3_step()\swas\scalled,\sthe\sstatement\sstill\sworks\sas\sexpected\s(and\screates\sthe\sobject). +D 2011-04-09T15:39:02.585 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,7 +124,7 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c 6a9164af8a2ef4612ee30b253635a9bd8e5e1b1b F src/btree.h 11753dd46597a20702bca8746cb4caa4486a82b5 F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 -F src/build.c b7c993274ee2a029937b0bc4815bdef80b330017 +F src/build.c 84d4a8030d38c8f8cea6bbfa3b9a9e92932b0d03 F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 @@ -230,7 +230,7 @@ F src/test_vfstrace.c 2265c9895f350c8d3c39b079998fbe7481505cc1 F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 604607d6813e9551cf5189d899e0a25c12681080 -F src/trigger.c d5bc8b9ffa2b54569ce635084765c6e41aa9d174 +F src/trigger.c c31aeb3c33e8cef9029e83f5fd9111ef644ca6b9 F src/update.c 81911be16ece3c3e7716aa18565b4814ec41f8b9 F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 F src/util.c cd997077bad039efc0597eb027c929658f93c018 @@ -388,6 +388,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 5e14325e4b2ea28709ff82d8d2605a129b5aec72 F test/expr.test 19e8ac40313e2282a47b586d11c4892040990d3a F test/fallocate.test 43dc34b8c24be6baffadc3b4401ee15710ce83c6 F test/filectrl.test 97003734290887566e01dded09dc9e99cb937e9e @@ -926,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 927e955b93e869727c55b784401de3ea07bee257 3b964155f611c437d53d44feafa22f531942b1b4 -R 8f730b36ea51ef307e60876151b20fbc -U drh -Z ad8576a5ee09c7cb93d286363cb1b8eb +P 8a42e236701c8afd9ada7d4568712a21690ea087 +R 962a8a84c94502671291e1b24e5febe9 +U dan +Z a74ebc24c62ba84a876e128dc1be558a diff --git a/manifest.uuid b/manifest.uuid index 822c3cbb9e..0989210735 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8a42e236701c8afd9ada7d4568712a21690ea087 \ No newline at end of file +b9dbd9936191666c3fc9889e938344a82cc03aeb \ No newline at end of file diff --git a/src/build.c b/src/build.c index 8ab07c857c..2d1d8dc6a3 100644 --- a/src/build.c +++ b/src/build.c @@ -813,6 +813,9 @@ void sqlite3StartTable( if( pTable ){ if( !noErr ){ sqlite3ErrorMsg(pParse, "table %T already exists", pName); + }else{ + assert( !db->init.busy ); + sqlite3CodeVerifySchema(pParse, iDb); } goto begin_table_error; } @@ -2518,6 +2521,9 @@ Index *sqlite3CreateIndex( if( sqlite3FindIndex(db, zName, pDb->zName)!=0 ){ if( !ifNotExist ){ sqlite3ErrorMsg(pParse, "index %s already exists", zName); + }else{ + assert( !db->init.busy ); + sqlite3CodeVerifySchema(pParse, iDb); } goto exit_create_index; } diff --git a/src/trigger.c b/src/trigger.c index 8a050eac50..8952ad59a1 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -171,6 +171,9 @@ void sqlite3BeginTrigger( zName, sqlite3Strlen30(zName)) ){ if( !noErr ){ sqlite3ErrorMsg(pParse, "trigger %T already exists", pName); + }else{ + assert( !db->init.busy ); + sqlite3CodeVerifySchema(pParse, iDb); } goto trigger_cleanup; } diff --git a/test/exists.test b/test/exists.test new file mode 100644 index 0000000000..05914d3cc1 --- /dev/null +++ b/test/exists.test @@ -0,0 +1,76 @@ +# 2011 April 9 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the various schema modification statements +# that feature "IF EXISTS" or "IF NOT EXISTS" clauses. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/lock_common.tcl + +set testprefix exists + +do_multiclient_test tn { + + # TABLE objects. + # + do_test $tn.1.1 { + sql2 { CREATE TABLE t1(x) } + sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) } + sql2 { DROP TABLE t1 } + sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) } + sql2 { SELECT name FROM sqlite_master WHERE type = 'table' } + } {t1} + + do_test $tn.1.2 { + sql2 { CREATE TABLE t2(x) } + sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 } + sql2 { DROP TABLE t2 } + sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 } + sql2 { SELECT name FROM sqlite_master WHERE type = 'table' } + } {t1 t2} + + + # INDEX objects. + # + do_test $tn.2 { + sql2 { CREATE INDEX i1 ON t1(a) } + sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) } + sql2 { DROP INDEX i1 } + sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) } + sql2 { SELECT name FROM sqlite_master WHERE type = 'index' } + } {i1} + + # VIEW objects. + # + do_test $tn.3 { + sql2 { CREATE VIEW v1 AS SELECT * FROM t1 } + sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 } + sql2 { DROP VIEW v1 } + sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 } + sql2 { SELECT name FROM sqlite_master WHERE type = 'view' } + } {v1} + + # TRIGGER objects. + # + do_test $tn.4 { + sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END } +sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END } + sql2 { DROP TRIGGER tr1 } +sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END } + sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' } + } {tr1} + +} + + +finish_test From 579667537a4bb6029d19ed46fcc7ace2fdca1cad Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 9 Apr 2011 17:32:58 +0000 Subject: [PATCH 18/19] Add VerifyCookie instructions to "DROP XXX IF EXISTS" statements if the specified database object does not exist when the statement is prepared. FossilOrigin-Name: a46f32900a013aa6bb2dad2a9ed3ce00ab2493fd --- manifest | 18 +++---- manifest.uuid | 2 +- src/build.c | 18 +++++++ src/sqliteInt.h | 1 + src/trigger.c | 2 + test/exists.test | 124 +++++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 151 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 7b7d0cd93d..e6ae396044 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sOP_VerifyCookie\sinstruction\sto\s"CREATE\sXXX\sIF\sNOT\sEXISTS"\scommands.\sThis\sway,\sif\sthe\sspecified\sdatabase\sobject\sexisted\swhen\sthe\sstatement\swas\scompiled\sbut\sremoved\sfrom\sthe\sdatabase\sbefore\ssqlite3_step()\swas\scalled,\sthe\sstatement\sstill\sworks\sas\sexpected\s(and\screates\sthe\sobject). -D 2011-04-09T15:39:02.585 +C Add\sVerifyCookie\sinstructions\sto\s"DROP\sXXX\sIF\sEXISTS"\sstatements\sif\sthe\sspecified\sdatabase\sobject\sdoes\snot\sexist\swhen\sthe\sstatement\sis\sprepared. +D 2011-04-09T17:32:58.132 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,7 +124,7 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c 6a9164af8a2ef4612ee30b253635a9bd8e5e1b1b F src/btree.h 11753dd46597a20702bca8746cb4caa4486a82b5 F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 -F src/build.c 84d4a8030d38c8f8cea6bbfa3b9a9e92932b0d03 +F src/build.c f09c46c66a1e7668c6ee25c9a2518aaa6842044c F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 @@ -180,7 +180,7 @@ F src/select.c 649a6f10f7eb7b52a5a28847773cb9968a828ae8 F src/shell.c 9c8389796764f65d4506bcd614ac8061f4160d5c F src/sqlite.h.in 4d28db70c37a1b17942820308eb59f211140da43 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h 9e53256aa7cb22ed2126c5350bc25e96bc7c4ed8 +F src/sqliteInt.h ac8f3f5846275c634f6649969304a9e97f6f9854 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -230,7 +230,7 @@ F src/test_vfstrace.c 2265c9895f350c8d3c39b079998fbe7481505cc1 F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 604607d6813e9551cf5189d899e0a25c12681080 -F src/trigger.c c31aeb3c33e8cef9029e83f5fd9111ef644ca6b9 +F src/trigger.c 144cc18bb701f3286484aae4292a9531f09278c8 F src/update.c 81911be16ece3c3e7716aa18565b4814ec41f8b9 F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 F src/util.c cd997077bad039efc0597eb027c929658f93c018 @@ -388,7 +388,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 5e14325e4b2ea28709ff82d8d2605a129b5aec72 +F test/exists.test 81363f6982ea49dfd820a50845466390e60a4a0c F test/expr.test 19e8ac40313e2282a47b586d11c4892040990d3a F test/fallocate.test 43dc34b8c24be6baffadc3b4401ee15710ce83c6 F test/filectrl.test 97003734290887566e01dded09dc9e99cb937e9e @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8a42e236701c8afd9ada7d4568712a21690ea087 -R 962a8a84c94502671291e1b24e5febe9 +P b9dbd9936191666c3fc9889e938344a82cc03aeb +R 0b11aa72c3fba72615e4990e1f23fca6 U dan -Z a74ebc24c62ba84a876e128dc1be558a +Z 1024ea561694dc92b045ac4bc887de85 diff --git a/manifest.uuid b/manifest.uuid index 0989210735..06d24001e8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b9dbd9936191666c3fc9889e938344a82cc03aeb \ No newline at end of file +a46f32900a013aa6bb2dad2a9ed3ce00ab2493fd \ No newline at end of file diff --git a/src/build.c b/src/build.c index 2d1d8dc6a3..83a1db8400 100644 --- a/src/build.c +++ b/src/build.c @@ -2003,6 +2003,7 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){ if( noErr ) db->suppressErr--; if( pTab==0 ){ + if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); goto exit_drop_table; } iDb = sqlite3SchemaToIndex(db, pTab->pSchema); @@ -2917,6 +2918,8 @@ void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){ if( pIndex==0 ){ if( !ifExists ){ sqlite3ErrorMsg(pParse, "no such index: %S", pName, 0); + }else{ + sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); } pParse->checkSchema = 1; goto exit_drop_index; @@ -3506,6 +3509,21 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ } } +/* +** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each +** attached database. Otherwise, invoke it for the database named zDb only. +*/ +void sqlite3CodeVerifyNamedSchema(Parse *pParse, const char *zDb){ + sqlite3 *db = pParse->db; + int i; + for(i=0; inDb; i++){ + Db *pDb = &db->aDb[i]; + if( pDb->pBt && (!zDb || 0==sqlite3StrICmp(zDb, pDb->zName)) ){ + sqlite3CodeVerifySchema(pParse, i); + } + } +} + /* ** Generate VDBE code that prepares for doing an operation that ** might change the database. diff --git a/src/sqliteInt.h b/src/sqliteInt.h index d663742778..ea0925e417 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2768,6 +2768,7 @@ void sqlite3PrngRestoreState(void); void sqlite3PrngResetState(void); void sqlite3RollbackAll(sqlite3*); void sqlite3CodeVerifySchema(Parse*, int); +void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb); void sqlite3BeginTransaction(Parse*, int); void sqlite3CommitTransaction(Parse*); void sqlite3RollbackTransaction(Parse*); diff --git a/src/trigger.c b/src/trigger.c index 8952ad59a1..0f3f5bad39 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -502,6 +502,8 @@ void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){ if( !pTrigger ){ if( !noErr ){ sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0); + }else{ + sqlite3CodeVerifyNamedSchema(pParse, zDb); } pParse->checkSchema = 1; goto drop_trigger_cleanup; diff --git a/test/exists.test b/test/exists.test index 05914d3cc1..db87afc788 100644 --- a/test/exists.test +++ b/test/exists.test @@ -19,11 +19,13 @@ source $testdir/lock_common.tcl set testprefix exists +# This block of tests is targeted at CREATE XXX IF NOT EXISTS statements. +# do_multiclient_test tn { # TABLE objects. # - do_test $tn.1.1 { + do_test 1.$tn.1.1 { sql2 { CREATE TABLE t1(x) } sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) } sql2 { DROP TABLE t1 } @@ -31,7 +33,7 @@ do_multiclient_test tn { sql2 { SELECT name FROM sqlite_master WHERE type = 'table' } } {t1} - do_test $tn.1.2 { + do_test 1.$tn.1.2 { sql2 { CREATE TABLE t2(x) } sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 } sql2 { DROP TABLE t2 } @@ -42,7 +44,7 @@ do_multiclient_test tn { # INDEX objects. # - do_test $tn.2 { + do_test 1.$tn.2 { sql2 { CREATE INDEX i1 ON t1(a) } sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) } sql2 { DROP INDEX i1 } @@ -52,7 +54,7 @@ do_multiclient_test tn { # VIEW objects. # - do_test $tn.3 { + do_test 1.$tn.3 { sql2 { CREATE VIEW v1 AS SELECT * FROM t1 } sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 } sql2 { DROP VIEW v1 } @@ -69,7 +71,121 @@ sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END } sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END } sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' } } {tr1} +} +# This block of tests is targeted at DROP XXX IF EXISTS statements. +# +do_multiclient_test tn { + + # TABLE objects. + # + do_test 2.$tn.1 { + sql1 { DROP TABLE IF EXISTS t1 } + sql2 { CREATE TABLE t1(x) } + sql1 { DROP TABLE IF EXISTS t1 } + sql2 { SELECT name FROM sqlite_master WHERE type = 'table' } + } {} + + # INDEX objects. + # + do_test 2.$tn.2 { + sql1 { CREATE TABLE t2(x) } + sql1 { DROP INDEX IF EXISTS i2 } + sql2 { CREATE INDEX i2 ON t2(x) } + sql1 { DROP INDEX IF EXISTS i2 } + sql2 { SELECT name FROM sqlite_master WHERE type = 'index' } + } {} + + # VIEW objects. + # + do_test 2.$tn.3 { + sql1 { DROP VIEW IF EXISTS v1 } + sql2 { CREATE VIEW v1 AS SELECT * FROM t2 } + sql1 { DROP VIEW IF EXISTS v1 } + sql2 { SELECT name FROM sqlite_master WHERE type = 'view' } + } {} + + # TRIGGER objects. + # + do_test 2.$tn.4 { + sql1 { DROP TRIGGER IF EXISTS tr1 } + sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END } + sql1 { DROP TRIGGER IF EXISTS tr1 } + sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' } + } {} +} + +# This block of tests is targeted at DROP XXX IF EXISTS statements with +# attached databases. +# +do_multiclient_test tn { + + forcedelete test.db2 + do_test 3.$tn.0 { + sql1 { ATTACH 'test.db2' AS aux } + sql2 { ATTACH 'test.db2' AS aux } + } {} + + # TABLE objects. + # + do_test 3.$tn.1.1 { + sql1 { DROP TABLE IF EXISTS aux.t1 } + sql2 { CREATE TABLE aux.t1(x) } + sql1 { DROP TABLE IF EXISTS aux.t1 } + sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' } + } {} + do_test 3.$tn.1.2 { + sql1 { DROP TABLE IF EXISTS t1 } + sql2 { CREATE TABLE aux.t1(x) } + sql1 { DROP TABLE IF EXISTS t1 } + sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' } + } {} + + # INDEX objects. + # + do_test 3.$tn.2.1 { + sql1 { CREATE TABLE aux.t2(x) } + sql1 { DROP INDEX IF EXISTS aux.i2 } + sql2 { CREATE INDEX aux.i2 ON t2(x) } + sql1 { DROP INDEX IF EXISTS aux.i2 } + sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' } + } {} + do_test 3.$tn.2.2 { + 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' } + } {} + + # VIEW objects. + # + do_test 3.$tn.3.1 { + sql1 { DROP VIEW IF EXISTS aux.v1 } + sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 } + sql1 { DROP VIEW IF EXISTS aux.v1 } + sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' } + } {} + do_test 3.$tn.3.2 { + sql1 { DROP VIEW IF EXISTS v1 } + sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 } + sql1 { DROP VIEW IF EXISTS v1 } + sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' } + } {} + + # TRIGGER objects. + # + do_test 3.$tn.4.1 { + sql1 { DROP TRIGGER IF EXISTS aux.tr1 } + sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END } + sql1 { DROP TRIGGER IF EXISTS aux.tr1 } + sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' } + } {} + do_test 3.$tn.4.2 { + sql1 { DROP TRIGGER IF EXISTS tr1 } + sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END } + sql1 { DROP TRIGGER IF EXISTS tr1 } + sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' } + } {} } From 806ebcb4499b5dc43806cd976f533c1b00908b7f Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 Apr 2011 17:53:30 +0000 Subject: [PATCH 19/19] Remove an always-true conditional. Replace it with an assert(). FossilOrigin-Name: 1c2f0f8477bcf251fe874a2cfae4d7a403cb88ff --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/backup.c | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e6ae396044..36e2f96988 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sVerifyCookie\sinstructions\sto\s"DROP\sXXX\sIF\sEXISTS"\sstatements\sif\sthe\sspecified\sdatabase\sobject\sdoes\snot\sexist\swhen\sthe\sstatement\sis\sprepared. -D 2011-04-09T17:32:58.132 +C Remove\san\salways-true\sconditional.\s\sReplace\sit\swith\san\sassert(). +D 2011-04-09T17:53:30.201 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -118,7 +118,7 @@ F src/alter.c 280f5c04b11b492703a342222b3de0a999445280 F src/analyze.c a425d62e8fa9ebcb4359ab84ff0c62c6563d2e2a F src/attach.c 7f97ca76ef2453440170929531a9c778267c0830 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 8d738af17e87eb6fcf2dab8b26153a918a114e48 +F src/backup.c 986c15232757f2873dff35ee3b35cbf935fc573c F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c 6a9164af8a2ef4612ee30b253635a9bd8e5e1b1b @@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b9dbd9936191666c3fc9889e938344a82cc03aeb -R 0b11aa72c3fba72615e4990e1f23fca6 -U dan -Z 1024ea561694dc92b045ac4bc887de85 +P a46f32900a013aa6bb2dad2a9ed3ce00ab2493fd +R 82deaf50c44bacb7e77b8358435cc0c9 +U drh +Z 1d377ca5bb92e1cc67ae34d0dbcea9e6 diff --git a/manifest.uuid b/manifest.uuid index 06d24001e8..e9b55b99fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a46f32900a013aa6bb2dad2a9ed3ce00ab2493fd \ No newline at end of file +1c2f0f8477bcf251fe874a2cfae4d7a403cb88ff \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 5e45a00258..4d7ae31834 100644 --- a/src/backup.c +++ b/src/backup.c @@ -623,9 +623,10 @@ void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){ ** the new data into the backup. */ int rc; - if( p->pDestDb ) sqlite3_mutex_enter(p->pDestDb->mutex); + assert( p->pDestDb ); + sqlite3_mutex_enter(p->pDestDb->mutex); rc = backupOnePage(p, iPage, aData); - if( p->pDestDb ) sqlite3_mutex_leave(p->pDestDb->mutex); + sqlite3_mutex_leave(p->pDestDb->mutex); assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED ); if( rc!=SQLITE_OK ){ p->rc = rc;