From f3ccc38a697da306aee63e66c22c2d480d292875 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 7 Mar 2014 14:57:07 +0000 Subject: [PATCH 1/5] Improved comment on the pager.c PERSIST rollback journal delete logic inside of hasHotJournal(). No changes to code. FossilOrigin-Name: e5b17a9d07a35c9b44ff977ba81b93d745d26a11 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pager.c | 14 ++++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 9e997b1eb1..f1ed65c66d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revise\schange\sfrom\sthe\sprevious\scheck-in\sto\sclarify\sthe\ssituation\swhen\shandling\sopen\sjournal\sfiles,\sregardless\sof\sjournal\smode. -D 2014-03-07T03:31:35.143 +C Improved\scomment\son\sthe\spager.c\sPERSIST\srollback\sjournal\sdelete\slogic\ninside\sof\shasHotJournal().\s\sNo\schanges\sto\scode. +D 2014-03-07T14:57:07.028 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -204,7 +204,7 @@ F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 18f7f95dc6bcb9cf4d4a238d8e2de96611bc2ae5 F src/os_win.c e71678ac927d0a0fb11d993db20a9748eabf808e -F src/pager.c ab9b5331e402f438effb02575955ffea673246cd +F src/pager.c 97a8908bf4e6e7c3adea09d3597cfa48ae33ab4e F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 F src/parse.y 2613ca5d609c2f3d71dd297351f010bcec16e1e0 F src/pcache.c d8eafac28290d4bb80332005435db44991d07fc2 @@ -1155,7 +1155,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P fdc651e2ec7a0babee669e24fd56632e7cd5f0e9 -R dd6c54a8aa52f6e2a8e41a668b913ede -U mistachkin -Z 7a2dfaabd9df7aaa8958f21cc25c2459 +P 1c318ef3b76e9a9a5ff2f156a9acddfc1bda0949 +R 061864752fb659e79b9068736cf1ac45 +U drh +Z 9721365445b2c154201b5f1346741e86 diff --git a/manifest.uuid b/manifest.uuid index 13a19cc1e7..e76365c166 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c318ef3b76e9a9a5ff2f156a9acddfc1bda0949 \ No newline at end of file +e5b17a9d07a35c9b44ff977ba81b93d745d26a11 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index e2486caa0a..c6485a4d45 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4889,14 +4889,16 @@ static int hasHotJournal(Pager *pPager, int *pExists){ if( rc==SQLITE_OK && !locked ){ Pgno nPage; /* Number of pages in database file */ - /* Check the size of the database file. If it consists of 0 pages - ** and the journal is not being persisted, then delete the journal - ** file. See the header comment above for the reasoning here. - ** Delete the obsolete journal file under a RESERVED lock to avoid - ** race conditions and to avoid violating [H33020]. - */ rc = pagerPagecount(pPager, &nPage); if( rc==SQLITE_OK ){ + /* If the database is zero pages in size, that means that either (1) the + ** journal is a remnant from a prior database with the same name where + ** the database file but not the journal was deleted, or (2) the initial + ** transaction that populates a new database is being rolled back. + ** In either case, the journal file can be deleted. However, take care + ** not to delete the journal file if it is already open due to + ** journal_mode=PERSIST. + */ if( nPage==0 && !jrnlOpen ){ sqlite3BeginBenignMalloc(); if( pagerLockDb(pPager, RESERVED_LOCK)==SQLITE_OK ){ From b72cad14d03c6198e88b90005a2e0318702c0610 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 8 Mar 2014 19:07:03 +0000 Subject: [PATCH 2/5] Fix a bug causing "SELECT char()" to return SQLITE_NOMEM. FossilOrigin-Name: ba39df9d4f7ffc6475ae0dc794f7d3f58c486de8 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/func.c | 2 +- test/func.test | 5 +++++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f1ed65c66d..95666febf7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\scomment\son\sthe\spager.c\sPERSIST\srollback\sjournal\sdelete\slogic\ninside\sof\shasHotJournal().\s\sNo\schanges\sto\scode. -D 2014-03-07T14:57:07.028 +C Fix\sa\sbug\scausing\s"SELECT\schar()"\sto\sreturn\sSQLITE_NOMEM. +D 2014-03-08T19:07:03.394 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/delete.c cdd57149543bb28304d8f717c243f2a86b1fc280 F src/expr.c 014b8087a15c4c314bdd798cb1cb0b32693f8b40 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 5269ef07b100763134f71b889327c333bd0989cf -F src/func.c f4499b39d66b71825514334ce67b32ff14bd19f5 +F src/func.c 2945bb2c4cdc0ac43733046285a4434310be1811 F src/global.c 1d7bb7ea8254ae6a68ed9bfaf65fcb3d1690b486 F src/hash.c d139319967164f139c8d1bb8a11b14db9c4ba3cd F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 @@ -573,7 +573,7 @@ F test/fts4merge4.test c19c85ca1faa7b6d536832b49c12e1867235f584 F test/fts4noti.test aed33ba44808852dcb24bf70fa132e7bf530f057 F test/fts4unicode.test 01ec3fe2a7c3cfff3b4c0581b83caa11b33efa36 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test 00667bbeac044d007f6f021af1b9f6150f0c7ff8 +F test/func.test a21814945d32137412b553d98ad2107f9b2173a9 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test dbccee9133cfef1473c59ec07b5f0262b9d72f9a F test/func4.test 6beacdfcb0e18c358e6c2dcacf1b65d1fa80955f @@ -1155,7 +1155,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 1c318ef3b76e9a9a5ff2f156a9acddfc1bda0949 -R 061864752fb659e79b9068736cf1ac45 -U drh -Z 9721365445b2c154201b5f1346741e86 +P e5b17a9d07a35c9b44ff977ba81b93d745d26a11 +R f73df97bd275791734e233575a443767 +U dan +Z 7931bffb2eb7579d713d462f61979bc1 diff --git a/manifest.uuid b/manifest.uuid index e76365c166..afb40009da 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e5b17a9d07a35c9b44ff977ba81b93d745d26a11 \ No newline at end of file +ba39df9d4f7ffc6475ae0dc794f7d3f58c486de8 \ No newline at end of file diff --git a/src/func.c b/src/func.c index e657558ba2..6be963580c 100644 --- a/src/func.c +++ b/src/func.c @@ -1017,7 +1017,7 @@ static void charFunc( ){ unsigned char *z, *zOut; int i; - zOut = z = sqlite3_malloc( argc*4 ); + zOut = z = sqlite3_malloc( argc*4+1 ); if( z==0 ){ sqlite3_result_error_nomem(context); return; diff --git a/test/func.test b/test/func.test index edec591eae..0fafd1828d 100644 --- a/test/func.test +++ b/test/func.test @@ -1361,4 +1361,9 @@ for {set i 65536} {$i<=0x10ffff} {incr i 139} { do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i } +# Test char(). +# +do_execsql_test func-31.1 { + SELECT char(), length(char()), typeof(char()) +} {{} 0 text} finish_test From 55aeee4b48d99d97c9108a385318c54292895410 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 10 Mar 2014 12:20:37 +0000 Subject: [PATCH 3/5] Version 3.8.4 FossilOrigin-Name: 530a1ee7dc2435f80960ce4710a3c2d2bfaaccc5 --- manifest | 13 ++++++++----- manifest.uuid | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 95666febf7..f4391b3680 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\scausing\s"SELECT\schar()"\sto\sreturn\sSQLITE_NOMEM. -D 2014-03-08T19:07:03.394 +C Version\s3.8.4 +D 2014-03-10T12:20:37.813 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1155,7 +1155,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P e5b17a9d07a35c9b44ff977ba81b93d745d26a11 +P ba39df9d4f7ffc6475ae0dc794f7d3f58c486de8 R f73df97bd275791734e233575a443767 -U dan -Z 7931bffb2eb7579d713d462f61979bc1 +T +bgcolor * #d0c0ff +T +sym-release * +T +sym-version-3.8.4 * +U drh +Z 82f901d4413784b1ea9af3cba9303801 diff --git a/manifest.uuid b/manifest.uuid index afb40009da..6e62e57b7b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ba39df9d4f7ffc6475ae0dc794f7d3f58c486de8 \ No newline at end of file +530a1ee7dc2435f80960ce4710a3c2d2bfaaccc5 \ No newline at end of file From b06a4ec1f01f6140206374a58a240abdefc9a356 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 10 Mar 2014 18:03:09 +0000 Subject: [PATCH 4/5] Attempt to work around MSVC's treatment of __LINE__ as a non-constant value in "Edit and Continue" mode by avoiding the use of __LINE__ when SQLITE_VDBE_COVERAGE is not defined. FossilOrigin-Name: 0a5318bc272b844e937cb1df3a07224034bc3450 --- manifest | 21 +++++++++------------ manifest.uuid | 2 +- src/pragma.c | 6 +++--- src/trigger.c | 2 +- src/vdbe.h | 2 ++ src/vdbeblob.c | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index f4391b3680..f54d726bd9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.8.4 -D 2014-03-10T12:20:37.813 +C Attempt\sto\swork\saround\sMSVC's\streatment\sof\s__LINE__\sas\sa\snon-constant\svalue\nin\s"Edit\sand\sContinue"\smode\sby\savoiding\sthe\suse\sof\s__LINE__\swhen\nSQLITE_VDBE_COVERAGE\sis\snot\sdefined. +D 2014-03-10T18:03:09.341 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -210,7 +210,7 @@ F src/parse.y 2613ca5d609c2f3d71dd297351f010bcec16e1e0 F src/pcache.c d8eafac28290d4bb80332005435db44991d07fc2 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222 F src/pcache1.c 102e6f5a2fbc646154463eb856d1fd716867b64c -F src/pragma.c a46ee83671f5c95f53d2ceeb5e1a818d7b1df99a +F src/pragma.c e78b4bf2a267de2c17ee09f90b6807cf8d40e6a3 F src/prepare.c 677521ab7132615a8a26107a1d1c3132f44ae337 F src/printf.c 85d07756e45d7496d19439dcae3e6e9e0090f269 F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece @@ -272,17 +272,17 @@ F src/test_vfs.c e72f555ef7a59080f898fcf1a233deb9eb704ea9 F src/test_vfstrace.c 3a0ab304682fecbceb689e7d9b904211fde11d78 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 6da2de6e12218ccb0aea5184b56727d011f4bee7 -F src/trigger.c a80036fcbd992729adc7cd34a875d59a71fa10cc +F src/trigger.c 66f3470b03b52b395e839155786966e3e037fddb F src/update.c 5b3e74a03b3811e586b4f2b4cbd7c49f01c93115 F src/utf.c 6dc9ec9f1b3db43ae8ba0365377f11df1ee4c01c F src/util.c c46c90459ef9bdc0c6c73803cf4c55425b4771cf F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 F src/vdbe.c 5f0fffa9bf49a90c05dc3d46d8217603fd0ee00e -F src/vdbe.h d189f92468a17a6f04daeec9df3b767f50557b21 +F src/vdbe.h fb2c48c198300a7c632f09fc940011d2ad2fc2ae F src/vdbeInt.h e54fc4f289fce48e81b3371128446033d097733b F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 F src/vdbeaux.c e45e3f9daf38c5be3fd39e9aacc1c9066af57a06 -F src/vdbeblob.c d939997de046b8fcc607cfee4248f3d33dbcca50 +F src/vdbeblob.c 15377abfb59251bccedd5a9c7d014a895f0c04aa F src/vdbemem.c 6fc77594c60f6155404f3f8d71bf36d1fdeb4447 F src/vdbesort.c 46801acb342e5e4c07ba1777fe58880c143abb59 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767 @@ -1155,10 +1155,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P ba39df9d4f7ffc6475ae0dc794f7d3f58c486de8 -R f73df97bd275791734e233575a443767 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.8.4 * +P 530a1ee7dc2435f80960ce4710a3c2d2bfaaccc5 +R 760c031eed969eb2e4721ef1a6cbabbc U drh -Z 82f901d4413784b1ea9af3cba9303801 +Z a6c38cee4adc797ddcb5e254b94d119b diff --git a/manifest.uuid b/manifest.uuid index 6e62e57b7b..b4216cd100 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -530a1ee7dc2435f80960ce4710a3c2d2bfaaccc5 \ No newline at end of file +0a5318bc272b844e937cb1df3a07224034bc3450 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index a211633f23..fcecad269a 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -824,7 +824,7 @@ void sqlite3Pragma( ** size of historical compatibility. */ case PragTyp_DEFAULT_CACHE_SIZE: { - static const int iLn = __LINE__+2; + static const int iLn = VDBE_OFFSET_LINENO(2); static const VdbeOpList getCacheSize[] = { { OP_Transaction, 0, 0, 0}, /* 0 */ { OP_ReadCookie, 0, 1, BTREE_DEFAULT_CACHE_SIZE}, /* 1 */ @@ -1087,7 +1087,7 @@ void sqlite3Pragma( ** file. Before writing to meta[6], check that meta[3] indicates ** that this really is an auto-vacuum capable database. */ - static const int iLn = __LINE__+2; + static const int iLn = VDBE_OFFSET_LINENO(2); static const VdbeOpList setMeta6[] = { { OP_Transaction, 0, 1, 0}, /* 0 */ { OP_ReadCookie, 0, 1, BTREE_LARGEST_ROOT_PAGE}, @@ -1790,7 +1790,7 @@ void sqlite3Pragma( ** messages have been generated, output OK. Otherwise output the ** error message */ - static const int iLn = __LINE__+2; + static const int iLn = VDBE_OFFSET_LINENO(2); static const VdbeOpList endCode[] = { { OP_AddImm, 1, 0, 0}, /* 0 */ { OP_IfNeg, 1, 0, 0}, /* 1 */ diff --git a/src/trigger.c b/src/trigger.c index dcbaf5d332..01f7b21f74 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -566,7 +566,7 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){ assert( pTable!=0 ); if( (v = sqlite3GetVdbe(pParse))!=0 ){ int base; - static const int iLn = __LINE__+2; + static const int iLn = VDBE_OFFSET_LINENO(2); static const VdbeOpList dropTrigger[] = { { OP_Rewind, 0, ADDR(9), 0}, { OP_String8, 0, 1, 0}, /* 1 */ diff --git a/src/vdbe.h b/src/vdbe.h index 66ca602ab7..8e300b88a6 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -272,11 +272,13 @@ void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); # define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__) # define VdbeCoverageAlwaysTaken(v) sqlite3VdbeSetLineNumber(v,2); # define VdbeCoverageNeverTaken(v) sqlite3VdbeSetLineNumber(v,1); +# define VDBE_OFFSET_LINENO(x) (__LINE__+x) #else # define VdbeCoverage(v) # define VdbeCoverageIf(v,x) # define VdbeCoverageAlwaysTaken(v) # define VdbeCoverageNeverTaken(v) +# define VDBE_OFFSET_LINENO(x) 0 #endif #endif diff --git a/src/vdbeblob.c b/src/vdbeblob.c index 4b34f2c295..cf7495e5b4 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -133,7 +133,7 @@ int sqlite3_blob_open( ** which closes the b-tree cursor and (possibly) commits the ** transaction. */ - static const int iLn = __LINE__+4; + static const int iLn = VDBE_OFFSET_LINENO(4); static const VdbeOpList openBlob[] = { /* {OP_Transaction, 0, 0, 0}, // 0: Inserted separately */ {OP_TableLock, 0, 0, 0}, /* 1: Acquire a read or write lock */ From 89212fb9f9f0c35bb4725bfc8b85eb96ad751939 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 10 Mar 2014 20:12:31 +0000 Subject: [PATCH 5/5] Adjustments to the cost computation for the skip-scan query plan, to take into account the fact that a seek has to occur on each skip. FossilOrigin-Name: 0769eebd028ce31375cf93509a1d3687f7b117eb --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 3 +++ test/skipscan1.test | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f54d726bd9..37e199a7ca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Attempt\sto\swork\saround\sMSVC's\streatment\sof\s__LINE__\sas\sa\snon-constant\svalue\nin\s"Edit\sand\sContinue"\smode\sby\savoiding\sthe\suse\sof\s__LINE__\swhen\nSQLITE_VDBE_COVERAGE\sis\snot\sdefined. -D 2014-03-10T18:03:09.341 +C Adjustments\sto\sthe\scost\scomputation\sfor\sthe\sskip-scan\squery\splan,\sto\stake\ninto\saccount\sthe\sfact\sthat\sa\sseek\shas\sto\soccur\son\seach\sskip. +D 2014-03-10T20:12:31.746 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -290,7 +290,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 95d30485879122acc5284d4523e01399b23b6148 +F src/where.c bb50b5aed4f9b2284eb92c944253e60df2fb8259 F src/whereInt.h 921f935af8b684ffb49705610bda7284db1db138 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -810,7 +810,7 @@ F test/shell5.test bb755ea9144b8078a752fc56223582627070b5f1 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868 F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329 -F test/skipscan1.test 8c777ffd9dad6ee6d2568160cb2158f0b5cd9dd2 +F test/skipscan1.test bed8cbe9d554c8c27afb6c88500f704c86a9196f F test/skipscan2.test 5a4db0799c338ddbacb154aaa5589c0254b36a8d F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 40562fe6cac6d9827b7b42b86d45aedf12c15e24 @@ -1155,7 +1155,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 530a1ee7dc2435f80960ce4710a3c2d2bfaaccc5 -R 760c031eed969eb2e4721ef1a6cbabbc +P 0a5318bc272b844e937cb1df3a07224034bc3450 +R e70fe0ad6a94758a25d6a041a31ecb69 U drh -Z a6c38cee4adc797ddcb5e254b94d119b +Z 344f247bc956540503c85d9ccd8fecb9 diff --git a/manifest.uuid b/manifest.uuid index b4216cd100..ed97f1ebb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a5318bc272b844e937cb1df3a07224034bc3450 \ No newline at end of file +0769eebd028ce31375cf93509a1d3687f7b117eb \ No newline at end of file diff --git a/src/where.c b/src/where.c index 963878d009..6cd9c167a1 100644 --- a/src/where.c +++ b/src/where.c @@ -3974,7 +3974,10 @@ static int whereLoopAddBtreeIndex( pNew->aLTerm[pNew->nLTerm++] = 0; pNew->wsFlags |= WHERE_SKIPSCAN; nIter = sqlite3LogEst(pProbe->aiRowEst[0]/pProbe->aiRowEst[saved_nEq+1]); + pNew->rRun = rLogSize + nIter; + pNew->nOut += nIter; whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter); + pNew->nOut = saved_nOut; } for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){ int nIn = 0; diff --git a/test/skipscan1.test b/test/skipscan1.test index b9eaf2729b..81cbc1dbc5 100644 --- a/test/skipscan1.test +++ b/test/skipscan1.test @@ -209,4 +209,42 @@ do_execsql_test skipscan1-4.1 { SELECT i FROM t4 WHERE h=8; } {9 9 9 9 9 9 9 9} +# Make sure skip-scan cost computation in the query planner takes into +# account the fact that the seek must occur multiple times. +# +# Prior to 2014-03-10, the costs were computed incorrectly which would +# cause index t5i2 to be used instead of t5i1 on the skipscan1-5.3. +# +do_execsql_test skipscan1-5.1 { + CREATE TABLE t5( + id INTEGER PRIMARY KEY, + loc TEXT, + lang INTEGER, + utype INTEGER, + xa INTEGER, + xd INTEGER, + xh INTEGER + ); + CREATE INDEX t5i1 on t5(loc, xh, xa, utype, lang); + CREATE INDEX t5i2 ON t5(xd,loc,utype,lang); + EXPLAIN QUERY PLAN + SELECT xh, loc FROM t5 WHERE loc >= 'M' AND loc < 'N'; +} {/.*COVERING INDEX t5i1 .*/} +do_execsql_test skipscan1-5.2 { + ANALYZE; + DELETE FROM sqlite_stat1; + DROP TABLE IF EXISTS sqlite_stat4; + DROP TABLE IF EXISTS sqlite_stat3; + INSERT INTO sqlite_stat1 VALUES('t5','t5i1','2702931 3 2 2 2 2'); + INSERT INTO sqlite_stat1 VALUES('t5','t5i2','2702931 686 2 2 2'); + ANALYZE sqlite_master; +} {} +db cache flush +do_execsql_test skipscan1-5.3 { + EXPLAIN QUERY PLAN + SELECT xh, loc FROM t5 WHERE loc >= 'M' AND loc < 'N'; +} {/.*COVERING INDEX t5i1 .*/} + + + finish_test