From 97a7e5e68cdfe31e9e020ed59d8f93787e18cd25 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 26 Apr 2016 18:58:54 +0000 Subject: [PATCH 01/18] The pcache and the built-in VFSes should not use mutexes when SQLITE_CONFIG_SINGLETHREAD is set. FossilOrigin-Name: 12418b100196abbfbfb85e0ab4bb6b1cbf335df7 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/os_unix.c | 10 ++++++---- src/os_win.c | 14 ++++++++------ src/pcache1.c | 4 ++-- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 01396063e2..a96ddd6939 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s"checksymbols"\starget\sin\sMakefile.in\sto\sbe\sable\sto\sdeal\swith\sthe\nsqlite3changegroup\sfamily\sof\sinterfaces. -D 2016-04-26T13:13:53.622 +C The\spcache\sand\sthe\sbuilt-in\sVFSes\sshould\snot\suse\smutexes\swhen\nSQLITE_CONFIG_SINGLETHREAD\sis\sset. +D 2016-04-26T18:58:54.655 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -361,15 +361,15 @@ F src/os.c 4d83917f072ad958fba9235136fa2ed43df47905 F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 2488a2b6456709ad6398df2302d427a980e2695a -F src/os_win.c 1997a873bfc8296a701bd8e2df8c3d5da5afe956 +F src/os_unix.c 8422fba2eb592fbbb2d4006b6f2a67cad8951495 +F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c d20fa46d5beda38095be6070dd4c59e502817c72 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c 647bb53a86b7bbcf55ad88089b3ea5a9170b90df F src/pcache.h 4d0ccaad264d360981ec5e6a2b596d6e85242545 -F src/pcache1.c c40cdb93586e21b5dd826b5e671240bd91c26b05 +F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7dd48c10790a7b9c4165214399c261a0aa701297 -R 5836a38779892d93c5f443eeb9cd4151 +P d819bfbd46dc7f065d2a3ab0ef9f8322d8394e11 +R 2246a8395360136a36ef2a0e4a464571 U drh -Z a0cff4b059a2c6bf807105b3b6e856e6 +Z fce32975c383f8c036923c0ce041e29e diff --git a/manifest.uuid b/manifest.uuid index cff4e97ad7..d1ff167696 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d819bfbd46dc7f065d2a3ab0ef9f8322d8394e11 \ No newline at end of file +12418b100196abbfbfb85e0ab4bb6b1cbf335df7 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index aadb414afe..01de00e0dd 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4288,10 +4288,12 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ pShmNode->h = -1; pDbFd->pInode->pShmNode = pShmNode; pShmNode->pInode = pDbFd->pInode; - pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); - if( pShmNode->mutex==0 ){ - rc = SQLITE_NOMEM_BKPT; - goto shm_open_err; + if( sqlite3GlobalConfig.bCoreMutex ){ + pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); + if( pShmNode->mutex==0 ){ + rc = SQLITE_NOMEM_BKPT; + goto shm_open_err; + } } if( pInode->bProcessLock==0 ){ diff --git a/src/os_win.c b/src/os_win.c index 1f26463453..9a34d9a106 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1260,8 +1260,8 @@ int sqlite3_win32_reset_heap(){ int rc; MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */ - MUTEX_LOGIC( pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); ) - MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); ) + MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) + MUTEX_LOGIC( pMem = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); ) sqlite3_mutex_enter(pMaster); sqlite3_mutex_enter(pMem); winMemAssertMagic(); @@ -3764,10 +3764,12 @@ static int winOpenSharedMemory(winFile *pDbFd){ pShmNode->pNext = winShmNodeList; winShmNodeList = pShmNode; - pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); - if( pShmNode->mutex==0 ){ - rc = SQLITE_IOERR_NOMEM_BKPT; - goto shm_open_err; + if( sqlite3GlobalConfig.bCoreMutex ){ + pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); + if( pShmNode->mutex==0 ){ + rc = SQLITE_IOERR_NOMEM_BKPT; + goto shm_open_err; + } } rc = winOpen(pDbFd->pVfs, diff --git a/src/pcache1.c b/src/pcache1.c index d168e7fbcb..5fe963ad05 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -690,8 +690,8 @@ static int pcache1Init(void *NotUsed){ #if SQLITE_THREADSAFE if( sqlite3GlobalConfig.bCoreMutex ){ - pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); - pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM); + pcache1.grp.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU); + pcache1.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PMEM); } #endif if( pcache1.separateCache From e5f06fdc8718d60ae90b5791026b58fd812c3963 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 26 Apr 2016 21:02:53 +0000 Subject: [PATCH 02/18] Remove an unnecessary line from the sqlite3AtoF() routine. FossilOrigin-Name: a9d007494cfe30a26dca5352655dc7702351476e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 3 --- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index a96ddd6939..bd6eed15fa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\spcache\sand\sthe\sbuilt-in\sVFSes\sshould\snot\suse\smutexes\swhen\nSQLITE_CONFIG_SINGLETHREAD\sis\sset. -D 2016-04-26T18:58:54.655 +C Remove\san\sunnecessary\sline\sfrom\sthe\ssqlite3AtoF()\sroutine. +D 2016-04-26T21:02:53.535 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -441,7 +441,7 @@ F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373 F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c -F src/util.c 187a0a2aaa3c5d2ccd2ab0143b2fd9e86d6bc816 +F src/util.c 8ae5e894687fb90cb22a870284eb4a8d077f4f93 F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 F src/vdbe.c d3843a66d74a7696477ee5141e5eb9a7e5e2401c F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d819bfbd46dc7f065d2a3ab0ef9f8322d8394e11 -R 2246a8395360136a36ef2a0e4a464571 +P 12418b100196abbfbfb85e0ab4bb6b1cbf335df7 +R 2a12fe749cf4b5592aed6dd4a1552e1f U drh -Z fce32975c383f8c036923c0ce041e29e +Z ab5ecd1a857f2f93572fff644c4c92bc diff --git a/manifest.uuid b/manifest.uuid index d1ff167696..128c730aca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -12418b100196abbfbfb85e0ab4bb6b1cbf335df7 \ No newline at end of file +a9d007494cfe30a26dca5352655dc7702351476e \ No newline at end of file diff --git a/src/util.c b/src/util.c index 2f77a6033f..e01928815b 100644 --- a/src/util.c +++ b/src/util.c @@ -384,9 +384,6 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ z+=incr; } - /* skip leading zeroes */ - while( z Date: Tue, 26 Apr 2016 23:14:45 +0000 Subject: [PATCH 03/18] Further simplifications to sqlite3AtoF() to remove unneeded branches. FossilOrigin-Name: dd69e53cb077873171af5312c633ca185595bf31 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 11 ++++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index bd6eed15fa..2dd1865c29 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\sline\sfrom\sthe\ssqlite3AtoF()\sroutine. -D 2016-04-26T21:02:53.535 +C Further\ssimplifications\sto\ssqlite3AtoF()\sto\sremove\sunneeded\sbranches. +D 2016-04-26T23:14:45.113 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -441,7 +441,7 @@ F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373 F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c -F src/util.c 8ae5e894687fb90cb22a870284eb4a8d077f4f93 +F src/util.c 7ea35eef53451786b4729d2a64ba9a8574a11e31 F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 F src/vdbe.c d3843a66d74a7696477ee5141e5eb9a7e5e2401c F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 12418b100196abbfbfb85e0ab4bb6b1cbf335df7 -R 2a12fe749cf4b5592aed6dd4a1552e1f +P a9d007494cfe30a26dca5352655dc7702351476e +R bdb81af968b0eff03040af96472e5367 U drh -Z ab5ecd1a857f2f93572fff644c4c92bc +Z 7162b1b4b927db763c29ab3a71a81028 diff --git a/manifest.uuid b/manifest.uuid index 128c730aca..48cc5d7fb4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a9d007494cfe30a26dca5352655dc7702351476e \ No newline at end of file +dd69e53cb077873171af5312c633ca185595bf31 \ No newline at end of file diff --git a/src/util.c b/src/util.c index e01928815b..771213be13 100644 --- a/src/util.c +++ b/src/util.c @@ -400,12 +400,13 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ z+=incr; /* copy digits from after decimal to significand ** (decrease exponent by d to shift decimal right) */ - while( z=zEnd ) goto do_atof_calc; From c6daa01c058378590d0a219d857dfde1acb12866 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 27 Apr 2016 02:35:03 +0000 Subject: [PATCH 04/18] Remove still more unnecessary branches from sqlite3AtoF(). FossilOrigin-Name: 3adfe9f3e6ce7cc09fcb570d9b65e830a96cac15 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 6 ++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 2dd1865c29..06c6814c38 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\ssimplifications\sto\ssqlite3AtoF()\sto\sremove\sunneeded\sbranches. -D 2016-04-26T23:14:45.113 +C Remove\sstill\smore\sunnecessary\sbranches\sfrom\ssqlite3AtoF(). +D 2016-04-27T02:35:03.572 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -441,7 +441,7 @@ F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373 F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c -F src/util.c 7ea35eef53451786b4729d2a64ba9a8574a11e31 +F src/util.c 562f7a85d933b7173a29e331deb28d85d6208f7c F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 F src/vdbe.c d3843a66d74a7696477ee5141e5eb9a7e5e2401c F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a9d007494cfe30a26dca5352655dc7702351476e -R bdb81af968b0eff03040af96472e5367 +P dd69e53cb077873171af5312c633ca185595bf31 +R 4f22b05e3bc28723a991a2f87c87962e U drh -Z 7162b1b4b927db763c29ab3a71a81028 +Z 439e39a464407086f87a7be758f8e1c8 diff --git a/manifest.uuid b/manifest.uuid index 48cc5d7fb4..1f512c3c71 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dd69e53cb077873171af5312c633ca185595bf31 \ No newline at end of file +3adfe9f3e6ce7cc09fcb570d9b65e830a96cac15 \ No newline at end of file diff --git a/src/util.c b/src/util.c index 771213be13..c85ae6a199 100644 --- a/src/util.c +++ b/src/util.c @@ -431,9 +431,7 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ } /* skip trailing spaces */ - if( nDigits && eValid ){ - while( z0 ){ From ad975d539e1357f62b4e6501c2252490dbb9f43b Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 27 Apr 2016 15:24:13 +0000 Subject: [PATCH 05/18] More simplification of the sqlite3AtoF() routine. Add special comments to indicate branches that are for optimization purposes only and that give the correct answer even if always or never taken. FossilOrigin-Name: 0065fe97cb8e5076acae1bf1560fd2f69dab9014 --- manifest | 12 ++++---- manifest.uuid | 2 +- src/util.c | 77 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 52 insertions(+), 39 deletions(-) diff --git a/manifest b/manifest index 06c6814c38..7fa7ebedf8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sstill\smore\sunnecessary\sbranches\sfrom\ssqlite3AtoF(). -D 2016-04-27T02:35:03.572 +C More\ssimplification\sof\sthe\ssqlite3AtoF()\sroutine.\s\sAdd\sspecial\scomments\nto\sindicate\sbranches\sthat\sare\sfor\soptimization\spurposes\sonly\sand\sthat\sgive\nthe\scorrect\sanswer\seven\sif\salways\sor\snever\staken. +D 2016-04-27T15:24:13.573 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -441,7 +441,7 @@ F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373 F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c -F src/util.c 562f7a85d933b7173a29e331deb28d85d6208f7c +F src/util.c d0899604c30b4a9d493980aa7742eeda383fff6d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 F src/vdbe.c d3843a66d74a7696477ee5141e5eb9a7e5e2401c F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dd69e53cb077873171af5312c633ca185595bf31 -R 4f22b05e3bc28723a991a2f87c87962e +P 3adfe9f3e6ce7cc09fcb570d9b65e830a96cac15 +R 676347b15924e075b34cabb43dd7e840 U drh -Z 439e39a464407086f87a7be758f8e1c8 +Z 680dc6a7c6e0d675cd4dc0c16abcab9d diff --git a/manifest.uuid b/manifest.uuid index 1f512c3c71..a6a5e1cabb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3adfe9f3e6ce7cc09fcb570d9b65e830a96cac15 \ No newline at end of file +0065fe97cb8e5076acae1bf1560fd2f69dab9014 \ No newline at end of file diff --git a/src/util.c b/src/util.c index c85ae6a199..1f59a9f731 100644 --- a/src/util.c +++ b/src/util.c @@ -355,7 +355,7 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ int eValid = 1; /* True exponent is either not used or is well-formed */ double result; int nDigits = 0; - int nonNum = 0; + int nonNum = 0; /* True if input contains UTF16 with high byte non-zero */ assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); *pResult = 0.0; /* Default return value, in case of an error */ @@ -368,7 +368,7 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); for(i=3-enc; i=zEnd ) goto do_atof_calc; + + /* This branch is needed to avoid a (harmless) buffer overread. The + ** special comment alerts the mutation tester that the correct answer + ** is obtained even if the branch is omitted */ + if( z>=zEnd ) goto do_atof_calc; /*PREVENTS-HARMLESS-OVERREAD*/ + /* get sign of exponent */ if( *z=='-' ){ esign = -1; @@ -443,41 +448,51 @@ do_atof_calc: esign = 1; } - /* if 0 significand */ - if( !s ) { - /* In the IEEE 754 standard, zero is signed. - ** Add the sign if we've seen at least one digit */ + if( s==0 ) { + /* In the IEEE 754 standard, zero is signed. */ result = sign<0 ? -(double)0 : (double)0; } else { - /* attempt to reduce exponent */ - if( esign>0 ){ - while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10; - }else{ - while( !(s%10) && e>0 ) e--,s/=10; + /* Attempt to reduce exponent. + ** + ** Branches that are not required for the correct answer but which only + ** help to obtain the correct answer faster are marked with special + ** comments, as a hint to the mutation tester. + */ + while( e>0 ){ /*OPTIMIZATION-IF-TRUE*/ + if( esign>0 ){ + if( s>=(LARGEST_INT64/10) ) break; /*OPTIMIZATION-IF-FALSE*/ + s *= 10; + }else{ + if( s%10!=0 ) break; /*OPTIMIZATION-IF-FALSE*/ + s /= 10; + } + e--; } /* adjust the sign of significand */ s = sign<0 ? -s : s; - /* if exponent, scale significand as appropriate - ** and store in result. */ - if( e ){ + if( e==0 ){ /*OPTIMIZATION-IF-TRUE*/ + result = (double)s; + }else{ LONGDOUBLE_TYPE scale = 1.0; /* attempt to handle extremely small/large numbers better */ - if( e>307 && e<342 ){ - while( e%308 ) { scale *= 1.0e+1; e -= 1; } - if( esign<0 ){ - result = s / scale; - result /= 1.0e+308; - }else{ - result = s * scale; - result *= 1.0e+308; - } - }else if( e>=342 ){ - if( esign<0 ){ - result = 0.0*s; - }else{ - result = 1e308*1e308*s; /* Infinity */ + if( e>307 ){ /*OPTIMIZATION-IF-TRUE*/ + if( e<342 ){ /*OPTIMIZATION-IF-TRUE*/ + while( e%308 ) { scale *= 1.0e+1; e -= 1; } + if( esign<0 ){ + result = s / scale; + result /= 1.0e+308; + }else{ + result = s * scale; + result *= 1.0e+308; + } + }else{ assert( e>=342 ); + if( esign<0 ){ + result = 0.0*s; + }else{ + result = 1e308*1e308*s; /* Infinity */ + } } }else{ /* 1.0e+22 is the largest power of 10 than can be @@ -490,8 +505,6 @@ do_atof_calc: result = s * scale; } } - } else { - result = (double)s; } } @@ -499,7 +512,7 @@ do_atof_calc: *pResult = result; /* return true if number and no extra non-whitespace chracters after */ - return z>=zEnd && nDigits>0 && eValid && nonNum==0; + return z==zEnd && nDigits>0 && eValid && nonNum==0; #else return !sqlite3Atoi64(z, pResult, length, enc); #endif /* SQLITE_OMIT_FLOATING_POINT */ From 05accd2216c25d31d98a19c6d8d14a260751452e Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 27 Apr 2016 18:54:49 +0000 Subject: [PATCH 06/18] Modify the permutations.test script so as to set any permutation specific configuration values before running each individual test script. FossilOrigin-Name: 2662d8fef791f7b8b3b14f9c27dfedec84620dee --- ext/session/sessionfault.test | 1 + ext/session/sessionfault2.test | 1 + manifest | 61 ++++++++++++++++++---------------- manifest.uuid | 2 +- src/test1.c | 8 +++-- src/test6.c | 28 +++++++++++++++- src/test_devsym.c | 7 ++++ src/test_journal.c | 27 +++++++++------ src/test_syscall.c | 12 +++++-- test/dbstatus2.test | 2 +- test/e_vacuum.test | 2 +- test/exists.test | 1 + test/hook.test | 2 +- test/incrvacuum2.test | 2 +- test/journal2.test | 2 +- test/permutations.test | 10 +++--- test/pragma3.test | 2 +- test/stat.test | 2 +- test/sync.test | 2 ++ test/tester.tcl | 6 ++++ test/tkt-2d1a5c67d.test | 3 +- test/tkt-313723c356.test | 2 +- test/tkt-5d863f876e.test | 2 +- test/tkt-9d68c883.test | 2 ++ test/zerodamage.test | 2 +- 25 files changed, 127 insertions(+), 64 deletions(-) diff --git a/ext/session/sessionfault.test b/ext/session/sessionfault.test index 6560ea8755..be6c4568ce 100644 --- a/ext/session/sessionfault.test +++ b/ext/session/sessionfault.test @@ -17,6 +17,7 @@ if {![info exists testdir]} { } source [file join [file dirname [info script]] session_common.tcl] source $testdir/tester.tcl +ifcapable !session {finish_test; return} set testprefix sessionfault diff --git a/ext/session/sessionfault2.test b/ext/session/sessionfault2.test index 6b257cf41b..ffdc57b9bc 100644 --- a/ext/session/sessionfault2.test +++ b/ext/session/sessionfault2.test @@ -17,6 +17,7 @@ if {![info exists testdir]} { } source [file join [file dirname [info script]] session_common.tcl] source $testdir/tester.tcl +ifcapable !session {finish_test; return} set testprefix sessionfault2 do_execsql_test 1.0.0 { diff --git a/manifest b/manifest index 7fa7ebedf8..e587ac6205 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\ssimplification\sof\sthe\ssqlite3AtoF()\sroutine.\s\sAdd\sspecial\scomments\nto\sindicate\sbranches\sthat\sare\sfor\soptimization\spurposes\sonly\sand\sthat\sgive\nthe\scorrect\sanswer\seven\sif\salways\sor\snever\staken. -D 2016-04-27T15:24:13.573 +C Modify\sthe\spermutations.test\sscript\sso\sas\sto\sset\sany\spermutation\sspecific\sconfiguration\svalues\sbefore\srunning\seach\sindividual\stest\sscript. +D 2016-04-27T18:54:49.294 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -291,8 +291,8 @@ F ext/session/sessionE.test e60a238c47f0feb3bb707e7f35e22be09c7e8f26 F ext/session/sessionF.test c2f178d4dfd723a5fd94a730ea2ccb44c669e3ce F ext/session/sessionG.test 01ef705096a9d3984eebdcca79807a211dee1b60 F ext/session/session_common.tcl a1293167d14774b5e728836720497f40fe4ea596 -F ext/session/sessionfault.test d52cbb7bee48cc8ee80335e07eb72fcb6b15eb40 -F ext/session/sessionfault2.test ac1dfd77a0fb0ea310aee40a16645ef1b66d3f88 +F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 +F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sqlite3session.c beb300cd1b5c5054062c8e6e807b10475e363410 F ext/session/sqlite3session.h 64e9e7f185725ef43b97f4a9a0c0df0669844f1d F ext/session/test_session.c 464f2c8bf502795d95969387eb8e93f68c513c15 @@ -387,12 +387,12 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 9c4c4589d078de37813ded708d8838b338ffb060 -F src/test1.c abc10e3e81258835aeb59616685d7369ba99ad1e +F src/test1.c 0b0b9483649d48846655ea30345bb3fe917555d6 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1 -F src/test6.c 41cacf3b0dd180823919bf9e1fbab287c9266723 +F src/test6.c 2c014d4977efd6107ec9eef3dfdec56ac516f824 F src/test7.c 9c89a4f1ed6bb13af0ed805b8d782bd83fcd57e3 F src/test8.c fa262391d3edea6490a71bfaa8fed477ccbbac75 F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 @@ -404,14 +404,14 @@ F src/test_blob.c b2551a9b5573232db5f66f292307c37067937239 F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f F src/test_config.c 7003f6f35134de6f19c6588f44783e43390ea277 F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 -F src/test_devsym.c 7e73009d5297b603c11c66d7c7d6723d4b5c73e1 +F src/test_devsym.c 4e58dec2602d8e139ca08659f62a62450587cb58 F src/test_fs.c f10f840ca4f8c72e4837908bd8347ac4bcab074b F src/test_func.c 37453d346cfcf118774efd5bf6187f7e6a7e3254 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 -F src/test_journal.c da540964c675fde39487da2bc664096af97190d8 +F src/test_journal.c d3b83f2bcb7792c709e57abddc456a2b1818643a F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd F src/test_malloc.c 94c18e88d6df6d471a0d04ddb809f833d1739950 F src/test_multiplex.c eafc567ebe162e36f17b5062285dfe90461cf8e9 @@ -427,7 +427,7 @@ F src/test_schema.c 2bdba21b82f601da69793e1f1d11bf481a79b091 F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe F src/test_sqllog.c 0d138a8180a312bf996b37fa66da5c5799d4d57b F src/test_superlock.c 06797157176eb7085027d9dd278c0d7a105e3ec9 -F src/test_syscall.c 4889d374f5a5856b7951f7a67c6401f7b938c6f5 +F src/test_syscall.c 268c072541162564a882c57f54a6fee12ef4a4d2 F src/test_tclvar.c d86412527da65468ee6fa1b8607c65d0af736bc4 F src/test_thread.c af391ec03d23486dffbcc250b7e58e073f172af9 F src/test_vfs.c 4d02f38bfb8f7f273da7ba84bfe000f5babf206c @@ -612,7 +612,7 @@ F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 -F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2 +F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa @@ -644,7 +644,7 @@ F test/e_select2.test aceb80ab927d46fba5ce7586ebabf23e2bb0604f F test/e_totalchanges.test b12ee5809d3e63aeb83238dd501a7bca7fd72c10 F test/e_update.test f46c2554d915c9197548681e8d8c33a267e84528 F test/e_uri.test 25385396082b67fd02ae0038b95a3b3575fe0519 -F test/e_vacuum.test 4d5b391384bb7d56bb9337d956f08035332421fc +F test/e_vacuum.test 120f29ea56bdce4d43279527ece894ab5d1729d3 F test/e_wal.test ae9a593207a77d711443ee69ffe081fda9243625 F test/e_walauto.test 248af31e73c98df23476a22bdb815524c9dc3ba8 F test/e_walckpt.test 28c371a6bb5e5fe7f31679c1df1763a19d19e8a0 @@ -659,7 +659,7 @@ F test/eval.test a64c9105d6ff163df7cf09d6ac29cdad5922078c F test/exclusive.test 9a57bd66e39144b888ca75c309914fcdefb4e3f9 F test/exclusive2.test 32798111aae78a5deec980eee383213f189df308 F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 -F test/exists.test 8f7b27b61c2fbe5822f0a1f899c715d14e416e30 +F test/exists.test 79a75323c78f02bbe9c251ea502a092f9ef63dac F test/expr.test 79c3e7502d9e571553b85f0ecc8ff2ac7d0e4931 F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9 F test/extraquick.test cb254400bd42bfb777ff675356aabf3287978f79 @@ -808,7 +808,7 @@ F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536 F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 F test/hexlit.test d7b0a5f41123df1e43985b91b8b2e70f95282d21 F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711 -F test/hook.test 40523db3aa76d62bda71c26f824fa0eabc420f0e +F test/hook.test 3b7b99d0eece6d279812c2aef6fa08bdfabc633e F test/icu.test 73956798bace8982909c00476b216714a6d0559a F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607 F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 @@ -825,7 +825,7 @@ F test/incrblob_err.test 69f9247fed50278d48ea710d1a8f9cdb09e4c0b8 F test/incrblobfault.test 280474078f6da9e732cd2a215d3d854969014b6e F test/incrcorrupt.test 6c567fbf870aa9e91866fe52ce6f200cd548939a F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32 -F test/incrvacuum2.test 676c41428765d58f1da7dbe659ef27726d3d30ac +F test/incrvacuum2.test 7d26cfda66c7e55898d196de54ac4ec7d86a4e3d F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a F test/incrvacuum_ioerr.test 6ae2f783424e47a0033304808fe27789cf93e635 F test/index.test fe3c7a1aad82af92623747e9c3f3aa94ccd51238 @@ -862,7 +862,7 @@ F test/join4.test 1a352e4e267114444c29266ce79e941af5885916 F test/join5.test 8a5c0be6f0c260a5c7177c3b8f07c7856141038a F test/join6.test cfe6503791ceb0cbb509966740286ec423cbf10b F test/journal1.test 69abc726c51b4a0409189f9a85191205297c0577 -F test/journal2.test ae06f566c28552c313ded3fee79a6c69e6d049b1 +F test/journal2.test 9dac6b4ba0ca79c3b21446bbae993a462c2397c4 F test/journal3.test ff8af941f9e06161d3db1b46bb9f965ff0e7f307 F test/jrnlmode.test 7864d59cf7f6e552b9b99ba0f38acd167edc10fa F test/jrnlmode2.test 81610545a4e6ed239ea8fa661891893385e23a1d @@ -977,10 +977,10 @@ F test/parser1.test 222b5cbf3e2e659fec1bf7d723488c8b9c94f1d0 F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff -F test/permutations.test cd1fa041074ed08eeaa563e4d1bacb0c69337ec1 +F test/permutations.test 44b5d257ff1e2bf102ffea50bd31f793de0c14f7 F test/pragma.test dd5313eee9c6d9d4726593a68ede8768d3b50ccc F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f -F test/pragma3.test 3f1984a04657331f838df5c519b443c2088df922 +F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed F test/printf.test b3ff34e73d59124140eaf89f7672e21bc2ca5fcc F test/printf2.test 0b61566dd1c0f0b802f59dffa228c5dc5aa6b054 F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb @@ -1092,7 +1092,7 @@ F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 F test/sqldiff1.test 28cd737cf1b0078b1ec1bbf425e674c47785835e F test/sqllimits1.test a74ee2a3740b9f9c2437c246d8fb77354862a142 F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a -F test/stat.test b65bad7120c52583b8f0054d99eff80718119a77 +F test/stat.test 66e95f97b9f724f9ab921d054ee0db3c2689f1ee F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 F test/stmt.test 64844332db69cf1a735fcb3e11548557fc95392f F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f @@ -1102,7 +1102,7 @@ F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8 F test/superlock.test ec94f0556b6488d97f71c79f9061ae08d9ab8f12 F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 -F test/sync.test 2f607e1821aa3af3c5c53b58835c05e511c95899 +F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 F test/syscall.test f59ba4e25f7ba4a4c031026cc2ef8b6e4b4c639c F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 F test/tabfunc01.test f977868fa8bb7beb4b2072883190411653473906 @@ -1113,7 +1113,7 @@ F test/tclsqlite.test e1306001a0ca92250b691ea6d3cecaca5b6342aa F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 -F test/tester.tcl 7b740ee852c55e1e72b6ebe5044acee7aa4e5553 +F test/tester.tcl 30c7a9be8601d1c1c9c93d013545ebcb28d64254 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1129,10 +1129,10 @@ F test/threadtest4.c c1e67136ceb6c7ec8184e56ac61db28f96bd2925 F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660 F test/tkt-2a5629202f.test 0521bd25658428baa26665aa53ffed9367d33af2 -F test/tkt-2d1a5c67d.test d371279946622698ab393ff88cad9f5f6d82960b +F test/tkt-2d1a5c67d.test be1326f3061caec85085f4c9ee4490561ca037c0 F test/tkt-2ea2425d34.test 1cf13e6f75d149b3209a0cb32927a82d3d79fb28 F test/tkt-31338dca7e.test 6fb8807851964da0d24e942f2e19c7c705b9fb58 -F test/tkt-313723c356.test c47f8a9330523e6f35698bf4489bcb29609b53ac +F test/tkt-313723c356.test 4b306ad45c736cedf2f5221f6155b92143244b6d F test/tkt-385a5b56b9.test c0a06ada41d7f06b1686da0e718553f853771d1e F test/tkt-38cb5df375.test f3cc8671f1eb604d4ae9cf886ed4366bec656678 F test/tkt-3998683a16.test 6d1d04d551ed1704eb3396ca87bb9ccc8c5c1eb7 @@ -1143,7 +1143,7 @@ F test/tkt-4c86b126f2.test cbcc611becd0396890169ab23102dd70048bbc9a F test/tkt-4dd95f6943.test 3d0ce415d2ee15d3d564121960016b9c7be79407 F test/tkt-4ef7e3cfca.test 3965ae11cc9cf6e334f9d7d3c1e20bf8d56254b1 F test/tkt-54844eea3f.test a12b851128f46a695e4e378cca67409b9b8f5894 -F test/tkt-5d863f876e.test c9f36ca503fa154a3655f92a69d2c30da1747bfa +F test/tkt-5d863f876e.test 726e76d725f6fe0eb2fc8a522b721b79807380ee F test/tkt-5e10420e8d.test 904d1687b3c06d43e5b3555bbcf6802e7c0ffd84 F test/tkt-5ee23731f.test 9db6e1d7209dc0794948b260d6f82b2b1de83a9f F test/tkt-6bfb98dfc0.test 24780633627b5cfc0635a5500c2389ebfb563336 @@ -1159,7 +1159,7 @@ F test/tkt-8c63ff0ec.test 258b7fc8d7e4e1cb5362c7d65c143528b9c4cbed F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5 F test/tkt-94c04eaadb.test f738c57c7f68ab8be1c054415af7774617cb6223 F test/tkt-9a8b09f8e6.test b2ef151d0984b2ebf237760dbeaa50724e5a0667 -F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67 +F test/tkt-9d68c883.test 16f7cb96781ba579bc2e19bb14b4ad609d9774b6 F test/tkt-9f2eb3abac.test cb6123ac695a08b4454c3792fbe85108f67fabf8 F test/tkt-a7b7803e.test 159ef554234fa1f9fb318c751b284bd1cf858da4 F test/tkt-a8a0d2996a.test eb597379dbcefa24765763d7f682c00cb5924fa9 @@ -1398,7 +1398,7 @@ F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e F test/wordcount.c 2a0a6c0d0e8e8bbbac1f06d72a6791828c37c0cf F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa -F test/zerodamage.test 2d725c214b883e25ae6bb85ef228ecdfa03c6a7b +F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 629d87562e0487c386db630033931d12d62e6372 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1484,7 +1484,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3adfe9f3e6ce7cc09fcb570d9b65e830a96cac15 -R 676347b15924e075b34cabb43dd7e840 -U drh -Z 680dc6a7c6e0d675cd4dc0c16abcab9d +P 0065fe97cb8e5076acae1bf1560fd2f69dab9014 +R 7df43ef0b7e3be4f42f2974bf9ebb1f9 +T *branch * permutations-fix +T *sym-permutations-fix * +T -sym-trunk * +U dan +Z 8c7c480375d878fe85148ba2747a0470 diff --git a/manifest.uuid b/manifest.uuid index a6a5e1cabb..a2dbc6c3ba 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0065fe97cb8e5076acae1bf1560fd2f69dab9014 \ No newline at end of file +2662d8fef791f7b8b3b14f9c27dfedec84620dee \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index 5478a72549..2540f3e804 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5213,7 +5213,9 @@ static int vfs_unregister_all( /* ** tclcmd: vfs_reregister_all ** -** Restore all VFSes that were removed using vfs_unregister_all +** Restore all VFSes that were removed using vfs_unregister_all. Taking +** care to put the linked list back together in the same order as it was +** in before vfs_unregister_all was invoked. */ static int vfs_reregister_all( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ @@ -5222,8 +5224,8 @@ static int vfs_reregister_all( Tcl_Obj *CONST objv[] /* Command arguments */ ){ int i; - for(i=0; i=0; i--){ + sqlite3_vfs_register(apVfs[i], 1); } return TCL_OK; } diff --git a/src/test6.c b/src/test6.c index 306482dcd3..2a09122c6c 100644 --- a/src/test6.c +++ b/src/test6.c @@ -701,6 +701,10 @@ static int cfCurrentTime(sqlite3_vfs *pCfVfs, double *pTimeOut){ sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData; return pVfs->xCurrentTime(pVfs, pTimeOut); } +static int cfGetLastError(sqlite3_vfs *pCfVfs, int n, char *z){ + sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData; + return pVfs->xGetLastError(pVfs, n, z); +} static int processDevSymArgs( Tcl_Interp *interp, @@ -827,7 +831,7 @@ static int crashEnableCmd( cfRandomness, /* xRandomness */ cfSleep, /* xSleep */ cfCurrentTime, /* xCurrentTime */ - 0, /* xGetlastError */ + cfGetLastError, /* xGetLastError */ 0, /* xCurrentTimeInt64 */ }; @@ -940,6 +944,27 @@ static int devSymObjCmd( devsym_register(iDc, iSectorSize); return TCL_OK; + +} + +/* +** tclcmd: unregister_devsim +*/ +static int dsUnregisterObjCmd( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + void devsym_unregister(void); + + if( objc!=1 ){ + Tcl_WrongNumArgs(interp, 1, objv, ""); + return TCL_ERROR; + } + + devsym_unregister(); + return TCL_OK; } /* @@ -1010,6 +1035,7 @@ int Sqlitetest6_Init(Tcl_Interp *interp){ Tcl_CreateObjCommand(interp, "sqlite3_crash_enable", crashEnableCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_crashparams", crashParamsObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_simulate_device", devSymObjCmd, 0, 0); + Tcl_CreateObjCommand(interp, "unregister_devsim", dsUnregisterObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "register_jt_vfs", jtObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "unregister_jt_vfs", jtUnregisterObjCmd, 0, 0); #endif diff --git a/src/test_devsym.c b/src/test_devsym.c index 5fd0935846..9a1ba09d69 100644 --- a/src/test_devsym.c +++ b/src/test_devsym.c @@ -396,4 +396,11 @@ void devsym_register(int iDeviceChar, int iSectorSize){ } } +void devsym_unregister(){ + sqlite3_vfs_unregister(&devsym_vfs); + g.pVfs = 0; + g.iDeviceChar = 0; + g.iSectorSize = 0; +} + #endif diff --git a/src/test_journal.c b/src/test_journal.c index 84c80546a6..4e63bccf76 100644 --- a/src/test_journal.c +++ b/src/test_journal.c @@ -160,6 +160,7 @@ static int jtRandomness(sqlite3_vfs*, int nByte, char *zOut); static int jtSleep(sqlite3_vfs*, int microseconds); static int jtCurrentTime(sqlite3_vfs*, double*); static int jtCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*); +static int jtGetLastError(sqlite3_vfs*, int, char*); static sqlite3_vfs jt_vfs = { 2, /* iVersion */ @@ -179,7 +180,7 @@ static sqlite3_vfs jt_vfs = { jtRandomness, /* xRandomness */ jtSleep, /* xSleep */ jtCurrentTime, /* xCurrentTime */ - 0, /* xGetLastError */ + jtGetLastError, /* xGetLastError */ jtCurrentTimeInt64 /* xCurrentTimeInt64 */ }; @@ -285,9 +286,10 @@ static int jtRead( ** b) The file-name specified when the file was opened matches ** all but the final 8 characters of the journal file name. ** -** c) There is currently a reserved lock on the file. +** c) There is currently a reserved lock on the file. This +** condition is waived if the noLock argument is non-zero. **/ -static jt_file *locateDatabaseHandle(const char *zJournal){ +static jt_file *locateDatabaseHandle(const char *zJournal, int noLock){ jt_file *pMain = 0; enterJtMutex(); for(pMain=g.pList; pMain; pMain=pMain->pNext){ @@ -295,7 +297,7 @@ static jt_file *locateDatabaseHandle(const char *zJournal){ if( (pMain->flags&SQLITE_OPEN_MAIN_DB) && ((int)strlen(pMain->zName)==nName) && 0==memcmp(pMain->zName, zJournal, nName) - && (pMain->eLock>=SQLITE_LOCK_RESERVED) + && ((pMain->eLock>=SQLITE_LOCK_RESERVED) || noLock) ){ break; } @@ -517,7 +519,7 @@ static int jtWrite( jt_file *p = (jt_file *)pFile; if( p->flags&SQLITE_OPEN_MAIN_JOURNAL ){ if( iOfst==0 ){ - jt_file *pMain = locateDatabaseHandle(p->zName); + jt_file *pMain = locateDatabaseHandle(p->zName, 0); assert( pMain ); if( iAmt==28 ){ @@ -562,7 +564,7 @@ static int jtWrite( rc = sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst); if( (p->flags&SQLITE_OPEN_MAIN_JOURNAL) && iAmt==12 ){ - jt_file *pMain = locateDatabaseHandle(p->zName); + jt_file *pMain = locateDatabaseHandle(p->zName, 0); int rc2 = readJournalFile(p, pMain); if( rc==SQLITE_OK ) rc = rc2; } @@ -576,7 +578,7 @@ static int jtTruncate(sqlite3_file *pFile, sqlite_int64 size){ jt_file *p = (jt_file *)pFile; if( p->flags&SQLITE_OPEN_MAIN_JOURNAL && size==0 ){ /* Truncating a journal file. This is the end of a transaction. */ - jt_file *pMain = locateDatabaseHandle(p->zName); + jt_file *pMain = locateDatabaseHandle(p->zName, 0); closeTransaction(pMain); } if( p->flags&SQLITE_OPEN_MAIN_DB && p->pWritable ){ @@ -604,11 +606,10 @@ static int jtSync(sqlite3_file *pFile, int flags){ ** jt_file.pWritable bitvec of the main database file associated with ** this journal file. */ - pMain = locateDatabaseHandle(p->zName); - assert(pMain); + pMain = locateDatabaseHandle(p->zName, 0); /* Set the bitvec values */ - if( pMain->pWritable ){ + if( pMain && pMain->pWritable ){ pMain->nSync++; rc = readJournalFile(p, pMain); if( rc!=SQLITE_OK ){ @@ -730,7 +731,7 @@ static int jtDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ int nPath = (int)strlen(zPath); if( nPath>8 && 0==strcmp("-journal", &zPath[nPath-8]) ){ /* Deleting a journal file. The end of a transaction. */ - jt_file *pMain = locateDatabaseHandle(zPath); + jt_file *pMain = locateDatabaseHandle(zPath, 0); if( pMain ){ closeTransaction(pMain); } @@ -825,6 +826,10 @@ static int jtCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){ return g.pVfs->xCurrentTimeInt64(g.pVfs, pTimeOut); } +static int jtGetLastError(sqlite3_vfs *pVfs, int n, char *z){ + return g.pVfs->xGetLastError(g.pVfs, n, z); +} + /************************************************************************** ** Start of public API. */ diff --git a/src/test_syscall.c b/src/test_syscall.c index f9abc1e46d..f1d5c61bc3 100644 --- a/src/test_syscall.c +++ b/src/test_syscall.c @@ -722,14 +722,20 @@ static int test_syscall( }; int iCmd; int rc; + sqlite3_vfs *pVfs = sqlite3_vfs_find(0); if( objc<2 ){ Tcl_WrongNumArgs(interp, 1, objv, "SUB-COMMAND ..."); return TCL_ERROR; } - rc = Tcl_GetIndexFromObjStruct(interp, - objv[1], aCmd, sizeof(aCmd[0]), "sub-command", 0, &iCmd - ); + if( pVfs->iVersion<3 || pVfs->xSetSystemCall==0 ){ + Tcl_AppendResult(interp, "VFS does not support xSetSystemCall", 0); + rc = TCL_ERROR; + }else{ + rc = Tcl_GetIndexFromObjStruct(interp, + objv[1], aCmd, sizeof(aCmd[0]), "sub-command", 0, &iCmd + ); + } if( rc!=TCL_OK ) return rc; return aCmd[iCmd].xCmd(clientData, interp, objc, objv); } diff --git a/test/dbstatus2.test b/test/dbstatus2.test index 2541a1a823..eff4b0207f 100644 --- a/test/dbstatus2.test +++ b/test/dbstatus2.test @@ -86,7 +86,7 @@ do_test 2.3 { db_write db 1 } {0 4 0} do_test 2.4 { db_write db 0 } {0 0 0} do_test 2.5 { db_write db 1 } {0 0 0} -ifcapable wal { +if {[wal_is_capable]} { do_test 2.6 { execsql { PRAGMA journal_mode = WAL } db_write db 1 diff --git a/test/e_vacuum.test b/test/e_vacuum.test index 1113a1fb6e..c3e517a892 100644 --- a/test/e_vacuum.test +++ b/test/e_vacuum.test @@ -176,7 +176,7 @@ if {![nonzero_reserved_bytes]} { # EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the # auto_vacuum support property can be changed using VACUUM. # - ifcapable wal { + if {[wal_is_capable]} { do_test e_vacuum-1.3.3.1 { execsql { PRAGMA journal_mode = wal } execsql { PRAGMA page_size ; PRAGMA auto_vacuum } diff --git a/test/exists.test b/test/exists.test index fb73797d29..5f9e36eb00 100644 --- a/test/exists.test +++ b/test/exists.test @@ -19,6 +19,7 @@ source $testdir/lock_common.tcl foreach jm {rollback wal} { + if {![wal_is_capable] && $jm=="wal"} continue set testprefix exists-$jm diff --git a/test/hook.test b/test/hook.test index 45e2959591..12e5bc0656 100644 --- a/test/hook.test +++ b/test/hook.test @@ -704,7 +704,7 @@ do_execsql_test 7.5.2.0 { ALTER TABLE t8 ADD COLUMN c DEFAULT 'xxx'; } -ifcapable !session { +if 0 { # At time of writing, these two are broken. They demonstrate that the # sqlite3_preupdate_old() method does not handle the case where ALTER TABLE # has been used to add a column with a default value other than NULL. diff --git a/test/incrvacuum2.test b/test/incrvacuum2.test index 2219d54195..6ec66c9deb 100644 --- a/test/incrvacuum2.test +++ b/test/incrvacuum2.test @@ -134,7 +134,7 @@ do_test incrvacuum2-3.2 { integrity_check incrvacuum2-3.3 -ifcapable wal { +if {[wal_is_capable]} { # 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 diff --git a/test/journal2.test b/test/journal2.test index 8f9b4d0b71..7cbe0ef2c5 100644 --- a/test/journal2.test +++ b/test/journal2.test @@ -204,7 +204,7 @@ db close # delete the journal file when committing the transaction that switches # the system to WAL mode. # -ifcapable wal { +if {[wal_is_capable]} { do_test journal2-2.1 { faultsim_delete_and_reopen set ::oplog [list] diff --git a/test/permutations.test b/test/permutations.test index 308d8bde77..15576e4f9f 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -942,7 +942,9 @@ test_suite "journaltest" -description { unregister_jt_vfs } -files [test_set $::allquicktests -exclude { wal* incrvacuum.test ioerr.test corrupt4.test io.test crash8.test - async4.test bigfile.test backcompat.test + async4.test bigfile.test backcompat.test e_wal* fstat.test mmap2.test + pager1.test syscall.test tkt3457.test *malloc* mmap* multiplex* nolock* + pager2.test *fault* rowal* snapshot* superlock* symlink.test }] if {[info commands register_demovfs] != ""} { @@ -1050,15 +1052,13 @@ proc run_tests {name args} { set ::G(isquick) 1 set ::G(perm:dbconfig) $options(-dbconfig) - uplevel $options(-initialize) - foreach file [lsort $options(-files)] { + uplevel $options(-initialize) if {[file tail $file] == $file} { set file [file join $::testdir $file] } slave_test_file $file + uplevel $options(-shutdown) } - uplevel $options(-shutdown) - unset ::G(perm:name) unset ::G(perm:prefix) unset ::G(perm:presql) diff --git a/test/pragma3.test b/test/pragma3.test index 1a67d72350..8a4f4f9d84 100644 --- a/test/pragma3.test +++ b/test/pragma3.test @@ -221,7 +221,7 @@ ifcapable shared_cache { # This will not work with the in-memory journal permutation, as opening # [db2] switches the journal mode back to "memory" # -ifcapable wal { +if {[wal_is_capable]} { if {[permutation]!="inmemory_journal"} { sqlite3 db test.db diff --git a/test/stat.test b/test/stat.test index 95586e94bc..d106894d71 100644 --- a/test/stat.test +++ b/test/stat.test @@ -37,7 +37,7 @@ do_execsql_test stat-0.0 { SELECT * FROM stat; } {} -ifcapable wal { +if {[wal_is_capable]} { do_execsql_test stat-0.1 { PRAGMA journal_mode = WAL; PRAGMA journal_mode = delete; diff --git a/test/sync.test b/test/sync.test index 2ee636a266..210039acb5 100644 --- a/test/sync.test +++ b/test/sync.test @@ -81,6 +81,7 @@ do_test sync-1.3 { set sqlite_sync_count } 11 ifcapable pager_pragmas { +if {[permutation]!="journaltest"} { do_test sync-1.4 { set sqlite_sync_count 0 execsql { @@ -94,6 +95,7 @@ ifcapable pager_pragmas { set sqlite_sync_count } 0 } +} finish_test diff --git a/test/tester.tcl b/test/tester.tcl index 2fcae7b5a2..23810d09ee 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -1944,6 +1944,12 @@ proc wal_check_journal_mode {testname {db db}} { } } +proc wal_is_capable {} { + ifcapable !wal { return 0 } + if {[permutation]=="journaltest"} { return 0 } + return 1 +} + proc permutation {} { set perm "" catch {set perm $::G(perm:name)} diff --git a/test/tkt-2d1a5c67d.test b/test/tkt-2d1a5c67d.test index 3fef187ecd..0d12a6ec43 100644 --- a/test/tkt-2d1a5c67d.test +++ b/test/tkt-2d1a5c67d.test @@ -19,7 +19,8 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix tkt-2d1a5c67d -ifcapable {!wal || !vtab} {finish_test; return} +ifcapable {!vtab} {finish_test; return} +if {[wal_is_capable]==0} {finish_test; return} for {set ii 1} {$ii<=10} {incr ii} { do_test tkt-2d1a5c67d.1.$ii { diff --git a/test/tkt-313723c356.test b/test/tkt-313723c356.test index 8c08c34976..5325fd2292 100644 --- a/test/tkt-313723c356.test +++ b/test/tkt-313723c356.test @@ -18,7 +18,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/malloc_common.tcl -ifcapable !wal { finish_test ; return } +if {![wal_is_capable]} { finish_test ; return } do_execsql_test tkt-313723c356.1 { PRAGMA page_size = 1024; diff --git a/test/tkt-5d863f876e.test b/test/tkt-5d863f876e.test index 86024e300b..9a2fa3f470 100644 --- a/test/tkt-5d863f876e.test +++ b/test/tkt-5d863f876e.test @@ -18,7 +18,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/lock_common.tcl set ::testprefix tkt-5d863f876e -ifcapable !wal {finish_test ; return } +if {![wal_is_capable]} {finish_test ; return } do_multiclient_test tn { do_test $tn.1 { diff --git a/test/tkt-9d68c883.test b/test/tkt-9d68c883.test index 18dc6ccd67..ba91b39e39 100644 --- a/test/tkt-9d68c883.test +++ b/test/tkt-9d68c883.test @@ -50,4 +50,6 @@ for {set i 0} {$i < 100} {incr i} { } {ok} } +catch { db close } +unregister_devsim finish_test diff --git a/test/zerodamage.test b/test/zerodamage.test index d781ab89a3..a87e50b7b5 100644 --- a/test/zerodamage.test +++ b/test/zerodamage.test @@ -89,7 +89,7 @@ do_test zerodamage-2.1 { concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size] } {0 0 24704} -ifcapable wal { +if {[wal_is_capable]} { # Run a WAL-mode transaction with POWERSAFE_OVERWRITE on to verify that the # WAL file does not get too big. # From 609d5846baf14c8886a690ead6fb3c0172f6ad4f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Apr 2016 00:32:16 +0000 Subject: [PATCH 07/18] Change the sqlite3Atoi64() routine so that it returns failure if not all of the input characters are consumed, even if it consumed all characters up to the first 0x00. This has no impact on external APIs as far as I can tell. FossilOrigin-Name: 46d4ffff3bd33d7e901e76cfac1cbde38d4f61d0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test1.c | 2 +- src/util.c | 11 +++++++---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 7fa7ebedf8..a6ca358f63 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\ssimplification\sof\sthe\ssqlite3AtoF()\sroutine.\s\sAdd\sspecial\scomments\nto\sindicate\sbranches\sthat\sare\sfor\soptimization\spurposes\sonly\sand\sthat\sgive\nthe\scorrect\sanswer\seven\sif\salways\sor\snever\staken. -D 2016-04-27T15:24:13.573 +C Change\sthe\ssqlite3Atoi64()\sroutine\sso\sthat\sit\sreturns\sfailure\sif\snot\sall\sof\nthe\sinput\scharacters\sare\sconsumed,\seven\sif\sit\sconsumed\sall\scharacters\sup\sto\nthe\sfirst\s0x00.\s\sThis\shas\sno\simpact\son\sexternal\sAPIs\sas\sfar\sas\sI\scan\stell. +D 2016-04-28T00:32:16.814 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -387,7 +387,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 9c4c4589d078de37813ded708d8838b338ffb060 -F src/test1.c abc10e3e81258835aeb59616685d7369ba99ad1e +F src/test1.c 922fd57b211e14761ef846cebfd09a1922771960 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -441,7 +441,7 @@ F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373 F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c -F src/util.c d0899604c30b4a9d493980aa7742eeda383fff6d +F src/util.c 1d2f9cc9ea43c5bc9a3b7e29b953001b0e85f5c7 F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 F src/vdbe.c d3843a66d74a7696477ee5141e5eb9a7e5e2401c F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3adfe9f3e6ce7cc09fcb570d9b65e830a96cac15 -R 676347b15924e075b34cabb43dd7e840 +P 0065fe97cb8e5076acae1bf1560fd2f69dab9014 +R 3ff6e84daa3c00c689a29794b4bf7803 U drh -Z 680dc6a7c6e0d675cd4dc0c16abcab9d +Z 1cade5a69af13a9b74de489bf6c2518b diff --git a/manifest.uuid b/manifest.uuid index a6a5e1cabb..fa2b210a37 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0065fe97cb8e5076acae1bf1560fd2f69dab9014 \ No newline at end of file +46d4ffff3bd33d7e901e76cfac1cbde38d4f61d0 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index 5478a72549..98afb03e12 100644 --- a/src/test1.c +++ b/src/test1.c @@ -1271,7 +1271,7 @@ static int sqlite3_mprintf_int64( return TCL_ERROR; } for(i=2; i<5; i++){ - if( sqlite3Atoi64(argv[i], &a[i-2], 1000000, SQLITE_UTF8) ){ + if( sqlite3Atoi64(argv[i], &a[i-2], sqlite3Strlen30(argv[i]), SQLITE_UTF8) ){ Tcl_AppendResult(interp, "argument is not a valid 64-bit integer", 0); return TCL_ERROR; } diff --git a/src/util.c b/src/util.c index 1f59a9f731..e883b1b9eb 100644 --- a/src/util.c +++ b/src/util.c @@ -574,7 +574,7 @@ int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ int neg = 0; /* assume positive */ int i; int c = 0; - int nonNum = 0; + int nonNum = 0; /* True if input contains UTF16 with high byte non-zero */ const char *zStart; const char *zEnd = zNum + length; assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); @@ -585,7 +585,7 @@ int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); for(i=3-enc; i19*incr || nonNum ){ + if( &zNum[i]19*incr /* Too many digits */ + || nonNum /* UTF16 with high-order bytes non-zero */ + ){ /* zNum is empty or contains non-numeric text or is longer ** than 19 digits (thus guaranteeing that it is too large) */ return 1; From 10c0a2a7c9e40ac583d5fb02701c19510110c78f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Apr 2016 03:52:18 +0000 Subject: [PATCH 08/18] Remove an unnecessary conditional from the sqlite3DecOrHexToI64() routine. FossilOrigin-Name: fcf85bfe50b254e825ee63a4cd0aa0b333b06eed --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a6ca358f63..0e64cb6d65 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\ssqlite3Atoi64()\sroutine\sso\sthat\sit\sreturns\sfailure\sif\snot\sall\sof\nthe\sinput\scharacters\sare\sconsumed,\seven\sif\sit\sconsumed\sall\scharacters\sup\sto\nthe\sfirst\s0x00.\s\sThis\shas\sno\simpact\son\sexternal\sAPIs\sas\sfar\sas\sI\scan\stell. -D 2016-04-28T00:32:16.814 +C Remove\san\sunnecessary\sconditional\sfrom\sthe\ssqlite3DecOrHexToI64()\sroutine. +D 2016-04-28T03:52:18.237 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -441,7 +441,7 @@ F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373 F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c -F src/util.c 1d2f9cc9ea43c5bc9a3b7e29b953001b0e85f5c7 +F src/util.c 41cac9db948cd1f746636cc6a0c60d4234d4053f F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 F src/vdbe.c d3843a66d74a7696477ee5141e5eb9a7e5e2401c F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0065fe97cb8e5076acae1bf1560fd2f69dab9014 -R 3ff6e84daa3c00c689a29794b4bf7803 +P 46d4ffff3bd33d7e901e76cfac1cbde38d4f61d0 +R 229317c8b5ac201d05335df0607fe343 U drh -Z 1cade5a69af13a9b74de489bf6c2518b +Z 98856d3d087818ace0a186a1d76b304b diff --git a/manifest.uuid b/manifest.uuid index fa2b210a37..61f1101a9b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -46d4ffff3bd33d7e901e76cfac1cbde38d4f61d0 \ No newline at end of file +fcf85bfe50b254e825ee63a4cd0aa0b333b06eed \ No newline at end of file diff --git a/src/util.c b/src/util.c index e883b1b9eb..748f8e802a 100644 --- a/src/util.c +++ b/src/util.c @@ -658,7 +658,6 @@ int sqlite3DecOrHexToI64(const char *z, i64 *pOut){ #ifndef SQLITE_OMIT_HEX_INTEGER if( z[0]=='0' && (z[1]=='x' || z[1]=='X') - && sqlite3Isxdigit(z[2]) ){ u64 u = 0; int i, k; From 3104c4d6f432335fade4e254580f7019c1d71038 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 28 Apr 2016 09:53:14 +0000 Subject: [PATCH 09/18] Ensure that quota.test deletes the directory named "test.db" that it creates. FossilOrigin-Name: 045edd4b17c6b76079ac90773c035d8c1f8d525d --- manifest | 15 ++++++--------- manifest.uuid | 2 +- test/quota.test | 2 ++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e587ac6205..4851ef79ae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\spermutations.test\sscript\sso\sas\sto\sset\sany\spermutation\sspecific\sconfiguration\svalues\sbefore\srunning\seach\sindividual\stest\sscript. -D 2016-04-27T18:54:49.294 +C Ensure\sthat\squota.test\sdeletes\sthe\sdirectory\snamed\s"test.db"\sthat\sit\screates. +D 2016-04-28T09:53:14.110 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -988,7 +988,7 @@ F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26 -F test/quota.test 36cd78b178c4eb0401d4f25754ef410fbd9df2a7 +F test/quota.test bfb269ce81ea52f593f9648316cd5013d766dd2a F test/quota2.test 7dc12e08b11cbc4c16c9ba2aa2e040ea8d8ab4b8 F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6 F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 @@ -1484,10 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0065fe97cb8e5076acae1bf1560fd2f69dab9014 -R 7df43ef0b7e3be4f42f2974bf9ebb1f9 -T *branch * permutations-fix -T *sym-permutations-fix * -T -sym-trunk * +P 2662d8fef791f7b8b3b14f9c27dfedec84620dee +R c0f9313eefa2a94509287d7302d3c22e U dan -Z 8c7c480375d878fe85148ba2747a0470 +Z e1c90065dd206cf7c15216b8288594e5 diff --git a/manifest.uuid b/manifest.uuid index a2dbc6c3ba..be4490f793 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2662d8fef791f7b8b3b14f9c27dfedec84620dee \ No newline at end of file +045edd4b17c6b76079ac90773c035d8c1f8d525d \ No newline at end of file diff --git a/test/quota.test b/test/quota.test index 7af55a8330..5d0bda3ad3 100644 --- a/test/quota.test +++ b/test/quota.test @@ -527,4 +527,6 @@ do_faultsim_test quota-5.6 -prep { } catch { sqlite3_quota_shutdown } +catch { db close } +forcedelete test.db finish_test From 75ab50ce8ff0821bae0989a86f037024fd6a8711 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Apr 2016 14:15:12 +0000 Subject: [PATCH 10/18] Use comments to mark several branches as optimizations. No changes to code. FossilOrigin-Name: 33e627472780b872716c504f2d585cc057c390a5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/hash.c | 4 ++-- src/util.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 0e64cb6d65..4e86475b14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\sconditional\sfrom\sthe\ssqlite3DecOrHexToI64()\sroutine. -D 2016-04-28T03:52:18.237 +C Use\scomments\sto\smark\sseveral\sbranches\sas\soptimizations.\s\sNo\schanges\sto\scode. +D 2016-04-28T14:15:12.903 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -336,7 +336,7 @@ F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 4c0bd09e602b8ae8d36d81e31e4872d0b53c87bb F src/func.c ef4c18c8a66143413ce41a58d582d2c14ddf78e1 F src/global.c c45ea22aff29334f6a9ec549235ac3357c970015 -F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 +F src/hash.c 55b5fb474100cee0b901edaf203e26c970940f36 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b @@ -441,7 +441,7 @@ F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373 F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c -F src/util.c 41cac9db948cd1f746636cc6a0c60d4234d4053f +F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 F src/vdbe.c d3843a66d74a7696477ee5141e5eb9a7e5e2401c F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 46d4ffff3bd33d7e901e76cfac1cbde38d4f61d0 -R 229317c8b5ac201d05335df0607fe343 +P fcf85bfe50b254e825ee63a4cd0aa0b333b06eed +R 197c644a6cd9b0806f84f77482d9fe15 U drh -Z 98856d3d087818ace0a186a1d76b304b +Z 413f6650964e5d2ab342130728703294 diff --git a/manifest.uuid b/manifest.uuid index 61f1101a9b..abe023c752 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fcf85bfe50b254e825ee63a4cd0aa0b333b06eed \ No newline at end of file +33e627472780b872716c504f2d585cc057c390a5 \ No newline at end of file diff --git a/src/hash.c b/src/hash.c index b5886e0641..eea2dd1ac2 100644 --- a/src/hash.c +++ b/src/hash.c @@ -55,7 +55,7 @@ void sqlite3HashClear(Hash *pH){ static unsigned int strHash(const char *z){ unsigned int h = 0; unsigned char c; - while( (c = (unsigned char)*z++)!=0 ){ + while( (c = (unsigned char)*z++)!=0 ){ /*OPTIMIZATION-IF-TRUE*/ h = (h<<3) ^ h ^ sqlite3UpperToLower[c]; } return h; @@ -148,7 +148,7 @@ static HashElem *findElementWithHash( int count; /* Number of elements left to test */ unsigned int h; /* The computed hash */ - if( pH->ht ){ + if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/ struct _ht *pEntry; h = strHash(pKey) % pH->htsize; pEntry = &pH->ht[h]; diff --git a/src/util.c b/src/util.c index 748f8e802a..db6163c3c7 100644 --- a/src/util.c +++ b/src/util.c @@ -1419,7 +1419,7 @@ LogEst sqlite3LogEst(u64 x){ if( x<2 ) return 0; while( x<8 ){ y -= 10; x <<= 1; } }else{ - while( x>255 ){ y += 40; x >>= 4; } + while( x>255 ){ y += 40; x >>= 4; } /*OPTIMIZATION-IF-TRUE*/ while( x>15 ){ y += 10; x >>= 1; } } return a[x&7] + y - 10; From 14cee38be8249d7d15e07b4a27a3d0e2b98dcac0 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 28 Apr 2016 14:54:54 +0000 Subject: [PATCH 11/18] Avoid running sessionfault.test and sessionfault2.test as part of the "inmemory_journal" permutation. FossilOrigin-Name: 5973d3bf2e5aa979ccc9a4a3a0eb08b67098b499 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/permutations.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4851ef79ae..24ba903e1f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\squota.test\sdeletes\sthe\sdirectory\snamed\s"test.db"\sthat\sit\screates. -D 2016-04-28T09:53:14.110 +C Avoid\srunning\ssessionfault.test\sand\ssessionfault2.test\sas\spart\sof\sthe\s"inmemory_journal"\spermutation. +D 2016-04-28T14:54:54.590 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -977,7 +977,7 @@ F test/parser1.test 222b5cbf3e2e659fec1bf7d723488c8b9c94f1d0 F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff -F test/permutations.test 44b5d257ff1e2bf102ffea50bd31f793de0c14f7 +F test/permutations.test b6b3e165fdc1b8c82a820033646dbfc6a7a01746 F test/pragma.test dd5313eee9c6d9d4726593a68ede8768d3b50ccc F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2662d8fef791f7b8b3b14f9c27dfedec84620dee -R c0f9313eefa2a94509287d7302d3c22e +P 045edd4b17c6b76079ac90773c035d8c1f8d525d +R e73b09d1e2cd9d2d69ece961d0e8362f U dan -Z e1c90065dd206cf7c15216b8288594e5 +Z aff771281cb418c17327081bdcd3c618 diff --git a/manifest.uuid b/manifest.uuid index be4490f793..7a52ce8e55 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -045edd4b17c6b76079ac90773c035d8c1f8d525d \ No newline at end of file +5973d3bf2e5aa979ccc9a4a3a0eb08b67098b499 \ No newline at end of file diff --git a/test/permutations.test b/test/permutations.test index 15576e4f9f..df3f500cda 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -728,7 +728,7 @@ test_suite "inmemory_journal" -description { ioerr.test ioerr2.test ioerr3.test ioerr4.test ioerr5.test vacuum3.test incrblob_err.test diskfull.test backup_ioerr.test e_fts3.test fts3cov.test fts3malloc.test fts3rnd.test - fts3snippet.test mmapfault.test + fts3snippet.test mmapfault.test sessionfault.test sessionfault2.test # Exclude test scripts that use tcl IO to access journal files or count # the number of fsync() calls. From cb6d66becc06dd0ad293779e02b8b9b25dfe3301 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Apr 2016 18:53:08 +0000 Subject: [PATCH 12/18] Rearrange some code in the RowSet logic for clarity of presentation, while adding an /*OPTIMIZATION-IF-TRUE*/ comment. It should operate identically. FossilOrigin-Name: 5748e64376c1c2be5154a632d1527cfebbb9ec74 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/rowset.c | 23 +++++++++++++---------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 4e86475b14..0837962a87 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\scomments\sto\smark\sseveral\sbranches\sas\soptimizations.\s\sNo\schanges\sto\scode. -D 2016-04-28T14:15:12.903 +C Rearrange\ssome\scode\sin\sthe\sRowSet\slogic\sfor\sclarity\sof\spresentation,\swhile\nadding\san\s/*OPTIMIZATION-IF-TRUE*/\scomment.\s\sIt\sshould\soperate\sidentically. +D 2016-04-28T18:53:08.454 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -376,7 +376,7 @@ F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c 63e6fb12bbe702dd664dc3703776c090383a5a26 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c b8f7174e5f8c33c44ded3a25a973d0bb89228c20 -F src/rowset.c 9fe4b3ad7cc00944386bb600233d8f523de07a6e +F src/rowset.c d68d95e167cb234f51d655c9546f46752c9f6d45 F src/select.c fd4a7ce2937497181063cfedb92058ac89491a5d F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fcf85bfe50b254e825ee63a4cd0aa0b333b06eed -R 197c644a6cd9b0806f84f77482d9fe15 +P 33e627472780b872716c504f2d585cc057c390a5 +R a33e3686da943dcb038124577baa15b4 U drh -Z 413f6650964e5d2ab342130728703294 +Z bac1d4beccda46e9aa1657c47d678425 diff --git a/manifest.uuid b/manifest.uuid index abe023c752..976aebefbd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -33e627472780b872716c504f2d585cc057c390a5 \ No newline at end of file +5748e64376c1c2be5154a632d1527cfebbb9ec74 \ No newline at end of file diff --git a/src/rowset.c b/src/rowset.c index c2e73ed72e..65fcdb2318 100644 --- a/src/rowset.c +++ b/src/rowset.c @@ -338,20 +338,23 @@ static struct RowSetEntry *rowSetNDeepTree( if( *ppList==0 ){ return 0; } - if( iDepth==1 ){ + if( iDepth>1 ){ /*OPTIMIZATION-IF-TRUE*/ + /* This branch cases a *balanced* tree to be generated. A valid tree + ** is still generated without this branch, but it is wildly unbalanced + ** and inefficient. */ + pLeft = rowSetNDeepTree(ppList, iDepth-1); + p = *ppList; + if( p==0 ){ + return pLeft; + } + p->pLeft = pLeft; + *ppList = p->pRight; + p->pRight = rowSetNDeepTree(ppList, iDepth-1); + }else{ p = *ppList; *ppList = p->pRight; p->pLeft = p->pRight = 0; - return p; } - pLeft = rowSetNDeepTree(ppList, iDepth-1); - p = *ppList; - if( p==0 ){ - return pLeft; - } - p->pLeft = pLeft; - *ppList = p->pRight; - p->pRight = rowSetNDeepTree(ppList, iDepth-1); return p; } From 2075fb08e66d6b21c471d9bbdd88773007342543 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Apr 2016 19:23:10 +0000 Subject: [PATCH 13/18] Fix typo in comment. No changes to code. FossilOrigin-Name: 9f6f17b5c97c9576c340173d068485fdbfd53253 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/rowset.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 0837962a87..c30368cd24 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rearrange\ssome\scode\sin\sthe\sRowSet\slogic\sfor\sclarity\sof\spresentation,\swhile\nadding\san\s/*OPTIMIZATION-IF-TRUE*/\scomment.\s\sIt\sshould\soperate\sidentically. -D 2016-04-28T18:53:08.454 +C Fix\stypo\sin\scomment.\s\sNo\schanges\sto\scode. +D 2016-04-28T19:23:10.406 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -376,7 +376,7 @@ F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c 63e6fb12bbe702dd664dc3703776c090383a5a26 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c b8f7174e5f8c33c44ded3a25a973d0bb89228c20 -F src/rowset.c d68d95e167cb234f51d655c9546f46752c9f6d45 +F src/rowset.c 156cb68c126b50222f16e7bab4d31ef03866c7e3 F src/select.c fd4a7ce2937497181063cfedb92058ac89491a5d F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 33e627472780b872716c504f2d585cc057c390a5 -R a33e3686da943dcb038124577baa15b4 -U drh -Z bac1d4beccda46e9aa1657c47d678425 +P 5748e64376c1c2be5154a632d1527cfebbb9ec74 +R 14e25db2c4fe1efcd0c8b2319d192798 +U mistachkin +Z 0a6ff0ee2ee8b77d1f440385eb5ab0b6 diff --git a/manifest.uuid b/manifest.uuid index 976aebefbd..a3d1de6609 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5748e64376c1c2be5154a632d1527cfebbb9ec74 \ No newline at end of file +9f6f17b5c97c9576c340173d068485fdbfd53253 \ No newline at end of file diff --git a/src/rowset.c b/src/rowset.c index 65fcdb2318..bf4382ddd8 100644 --- a/src/rowset.c +++ b/src/rowset.c @@ -339,7 +339,7 @@ static struct RowSetEntry *rowSetNDeepTree( return 0; } if( iDepth>1 ){ /*OPTIMIZATION-IF-TRUE*/ - /* This branch cases a *balanced* tree to be generated. A valid tree + /* This branch causes a *balanced* tree to be generated. A valid tree ** is still generated without this branch, but it is wildly unbalanced ** and inefficient. */ pLeft = rowSetNDeepTree(ppList, iDepth-1); From 396794f0ee581d61d213e9bec23ef6b53e0516b5 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Apr 2016 20:11:12 +0000 Subject: [PATCH 14/18] Comment changes only: Add several optimization marks in rowset.c. Add a header comment that explains what the various special comments mean. FossilOrigin-Name: 8cdbe89ac6c22d632f677eb293111b3dbae7d6c1 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/rowset.c | 21 ++++++++++++++------- src/sqliteInt.h | 27 +++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index c30368cd24..4e21e75b83 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\scomment.\s\sNo\schanges\sto\scode. -D 2016-04-28T19:23:10.406 +C Comment\schanges\sonly:\s\sAdd\sseveral\soptimization\smarks\sin\srowset.c.\s\sAdd\na\sheader\scomment\sthat\sexplains\swhat\sthe\svarious\sspecial\scomments\smean. +D 2016-04-28T20:11:12.680 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -376,13 +376,13 @@ F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c 63e6fb12bbe702dd664dc3703776c090383a5a26 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c b8f7174e5f8c33c44ded3a25a973d0bb89228c20 -F src/rowset.c 156cb68c126b50222f16e7bab4d31ef03866c7e3 +F src/rowset.c fb413e336e765481e4d8368377c444904cecdf32 F src/select.c fd4a7ce2937497181063cfedb92058ac89491a5d F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h ec538389481a3d093f07fb344c5a9dc988042304 +F src/sqliteInt.h f4a53f3547dab80dc7db975fa1192d9bad1f38e8 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5748e64376c1c2be5154a632d1527cfebbb9ec74 -R 14e25db2c4fe1efcd0c8b2319d192798 -U mistachkin -Z 0a6ff0ee2ee8b77d1f440385eb5ab0b6 +P 9f6f17b5c97c9576c340173d068485fdbfd53253 +R 868dfe1770715db047dd242154ff598b +U drh +Z b6de1d1adc478f4213336a399ac69fc9 diff --git a/manifest.uuid b/manifest.uuid index a3d1de6609..7cd7864f7b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9f6f17b5c97c9576c340173d068485fdbfd53253 \ No newline at end of file +8cdbe89ac6c22d632f677eb293111b3dbae7d6c1 \ No newline at end of file diff --git a/src/rowset.c b/src/rowset.c index bf4382ddd8..5420ab991c 100644 --- a/src/rowset.c +++ b/src/rowset.c @@ -179,7 +179,9 @@ void sqlite3RowSetClear(RowSet *p){ */ static struct RowSetEntry *rowSetEntryAlloc(RowSet *p){ assert( p!=0 ); - if( p->nFresh==0 ){ + if( p->nFresh==0 ){ /*OPTIMIZATION-IF-FALSE*/ + /* We could allocate a fresh RowSetEntry each time one is needed, but it + ** is more efficient to pull a preallocated entry from the pool */ struct RowSetChunk *pNew; pNew = sqlite3DbMallocRawNN(p->db, sizeof(*pNew)); if( pNew==0 ){ @@ -213,7 +215,9 @@ void sqlite3RowSetInsert(RowSet *p, i64 rowid){ pEntry->pRight = 0; pLast = p->pLast; if( pLast ){ - if( (p->rsFlags & ROWSET_SORTED)!=0 && rowid<=pLast->v ){ + if( rowid<=pLast->v ){ /*OPTIMIZATION-IF-FALSE*/ + /* Avoid unnecessary sorts by preserving the ROWSET_SORTED flags + ** where possible */ p->rsFlags &= ~ROWSET_SORTED; } pLast->pRight = pEntry; @@ -335,16 +339,19 @@ static struct RowSetEntry *rowSetNDeepTree( ){ struct RowSetEntry *p; /* Root of the new tree */ struct RowSetEntry *pLeft; /* Left subtree */ - if( *ppList==0 ){ - return 0; + if( *ppList==0 ){ /*OPTIMIZATION-IF-TRUE*/ + /* Prevent unnecessary deep recursion when we run out of entries */ + return 0; } if( iDepth>1 ){ /*OPTIMIZATION-IF-TRUE*/ /* This branch causes a *balanced* tree to be generated. A valid tree - ** is still generated without this branch, but it is wildly unbalanced - ** and inefficient. */ + ** is still generated without this branch, but the tree is wildly + ** unbalanced and inefficient. */ pLeft = rowSetNDeepTree(ppList, iDepth-1); p = *ppList; - if( p==0 ){ + if( p==0 ){ /*OPTIMIZATION-IF-FALSE*/ + /* It is safe to always return here, but the resulting tree + ** would be unbalanced */ return pLeft; } p->pLeft = pLeft; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 7bb15d0bf5..76bf809624 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -15,6 +15,33 @@ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ +/* Special Comments: +** +** Some comments have special meaning to the tools that measure test +** coverage: +** +** NO_TEST - The branches on this line are not +** measured by branch coverage. This is +** used on lines of code that actually +** implement parts of coverage testing. +** +** OPTIMIZATION-IF-TRUE - This branch is allowed to alway be false +** and the correct answer is still obtained, +** though perhaps more slowly. +** +** OPTIMIZATION-IF-FALSE - This branch is allowed to alway be true +** and the correct answer is still obtained, +** though perhaps more slowly. +** +** PREVENTS-HARMLESS-OVERREAD - This branch prevents a buffer overread +** that would be harmless and undetectable +** if it did occur. +** +** In all cases, the special comment must be enclosed in the usual +** slash-asterisk...asterisk-slash comment marks, with no spaces between the +** asterisks and the comment text. +*/ + /* ** Make sure that rand_s() is available on Windows systems with MSVC 2005 ** or higher. From aa50271a2432fb6a85c1f42b39317500c7cda950 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Apr 2016 22:29:31 +0000 Subject: [PATCH 15/18] Further simplifications and improved commentting on the rowset.c module, including several optimization comments. FossilOrigin-Name: 9f15a520deb9f1d4ecaa3bfff82bd57ef122aadb --- manifest | 12 +++++----- manifest.uuid | 2 +- src/rowset.c | 65 ++++++++++++++++++--------------------------------- 3 files changed, 30 insertions(+), 49 deletions(-) diff --git a/manifest b/manifest index 4e21e75b83..4d312042a1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Comment\schanges\sonly:\s\sAdd\sseveral\soptimization\smarks\sin\srowset.c.\s\sAdd\na\sheader\scomment\sthat\sexplains\swhat\sthe\svarious\sspecial\scomments\smean. -D 2016-04-28T20:11:12.680 +C Further\ssimplifications\sand\simproved\scommentting\son\sthe\srowset.c\smodule,\nincluding\sseveral\soptimization\scomments. +D 2016-04-28T22:29:31.056 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -376,7 +376,7 @@ F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c 63e6fb12bbe702dd664dc3703776c090383a5a26 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c b8f7174e5f8c33c44ded3a25a973d0bb89228c20 -F src/rowset.c fb413e336e765481e4d8368377c444904cecdf32 +F src/rowset.c 49eb91c588a2bab36647368e031dc5b66928149d F src/select.c fd4a7ce2937497181063cfedb92058ac89491a5d F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9f6f17b5c97c9576c340173d068485fdbfd53253 -R 868dfe1770715db047dd242154ff598b +P 8cdbe89ac6c22d632f677eb293111b3dbae7d6c1 +R 9629e5ecfb28b4deca7492eeb801c3d3 U drh -Z b6de1d1adc478f4213336a399ac69fc9 +Z f98c64d26c6e12bfaaf00c7f14039634 diff --git a/manifest.uuid b/manifest.uuid index 7cd7864f7b..fd604e04b3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8cdbe89ac6c22d632f677eb293111b3dbae7d6c1 \ No newline at end of file +9f15a520deb9f1d4ecaa3bfff82bd57ef122aadb \ No newline at end of file diff --git a/src/rowset.c b/src/rowset.c index 5420ab991c..a70264ed1b 100644 --- a/src/rowset.c +++ b/src/rowset.c @@ -57,8 +57,9 @@ ** of the first SMALLEST is O(NlogN). Second and subsequent SMALLEST ** primitives are constant time. The cost of DESTROY is O(N). ** -** There is an added cost of O(N) when switching between TEST and -** SMALLEST primitives. +** TEST and SMALLEST may not be used by the same RowSet. This used to +** be possible, but the feature was not used, so it was removed in order +** to simplify the code. */ #include "sqliteInt.h" @@ -388,59 +389,37 @@ static struct RowSetEntry *rowSetListToTree(struct RowSetEntry *pList){ return p; } -/* -** Take all the entries on p->pEntry and on the trees in p->pForest and -** sort them all together into one big ordered list on p->pEntry. -** -** This routine should only be called once in the life of a RowSet. -*/ -static void rowSetToList(RowSet *p){ - - /* This routine is called only once */ - assert( p!=0 && (p->rsFlags & ROWSET_NEXT)==0 ); - - if( (p->rsFlags & ROWSET_SORTED)==0 ){ - p->pEntry = rowSetEntrySort(p->pEntry); - } - - /* While this module could theoretically support it, sqlite3RowSetNext() - ** is never called after sqlite3RowSetText() for the same RowSet. So - ** there is never a forest to deal with. Should this change, simply - ** remove the assert() and the #if 0. */ - assert( p->pForest==0 ); -#if 0 - while( p->pForest ){ - struct RowSetEntry *pTree = p->pForest->pLeft; - if( pTree ){ - struct RowSetEntry *pHead, *pTail; - rowSetTreeToList(pTree, &pHead, &pTail); - p->pEntry = rowSetEntryMerge(p->pEntry, pHead); - } - p->pForest = p->pForest->pRight; - } -#endif - p->rsFlags |= ROWSET_NEXT; /* Verify this routine is never called again */ -} - /* ** Extract the smallest element from the RowSet. ** Write the element into *pRowid. Return 1 on success. Return ** 0 if the RowSet is already empty. ** ** After this routine has been called, the sqlite3RowSetInsert() -** routine may not be called again. +** routine may not be called again. +** +** This routine may not be called after sqlite3RowSetTest() has +** been used. Older versions of RowSet allowed that, but as the +** capability was not used by the code generator, it was removed +** for code economy. */ int sqlite3RowSetNext(RowSet *p, i64 *pRowid){ assert( p!=0 ); + assert( p->pForest==0 ); /* Cannot be used with sqlite3RowSetText() */ /* Merge the forest into a single sorted list on first call */ - if( (p->rsFlags & ROWSET_NEXT)==0 ) rowSetToList(p); + if( (p->rsFlags & ROWSET_NEXT)==0 ){ /*OPTIMIZATION-IF-FALSE*/ + if( (p->rsFlags & ROWSET_SORTED)==0 ){ /*OPTIMIZATION-IF-FALSE*/ + p->pEntry = rowSetEntrySort(p->pEntry); + } + p->rsFlags |= ROWSET_SORTED|ROWSET_NEXT; + } /* Return the next entry on the list */ if( p->pEntry ){ *pRowid = p->pEntry->v; p->pEntry = p->pEntry->pRight; - if( p->pEntry==0 ){ + if( p->pEntry==0 ){ /*OPTIMIZATION-IF-TRUE*/ + /* Free memory immediately, rather than waiting on sqlite3_finalize() */ sqlite3RowSetClear(p); } return 1; @@ -463,13 +442,15 @@ int sqlite3RowSetTest(RowSet *pRowSet, int iBatch, sqlite3_int64 iRowid){ /* This routine is never called after sqlite3RowSetNext() */ assert( pRowSet!=0 && (pRowSet->rsFlags & ROWSET_NEXT)==0 ); - /* Sort entries into the forest on the first test of a new batch + /* Sort entries into the forest on the first test of a new batch. + ** To save unnecessary work, only do this when the batch number changes. */ - if( iBatch!=pRowSet->iBatch ){ + if( iBatch!=pRowSet->iBatch ){ /*OPTIMIZATION-IF-FALSE*/ p = pRowSet->pEntry; if( p ){ struct RowSetEntry **ppPrevTree = &pRowSet->pForest; - if( (pRowSet->rsFlags & ROWSET_SORTED)==0 ){ + if( (pRowSet->rsFlags & ROWSET_SORTED)==0 ){ /*OPTIMIZATION-IF-FALSE*/ + /* Only sort the current set of entiries if they need it */ p = rowSetEntrySort(p); } for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){ From a3fa140fb46e74cb86cd1b44905842efd03c9c5e Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 29 Apr 2016 02:55:05 +0000 Subject: [PATCH 16/18] Some optimization comments added to vdbe.c. No functional changes to code. FossilOrigin-Name: e7c22e3bffce63f3b47fa3683be8c00c42b2a7d3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 17 ++++++++++------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 4d312042a1..da4cac8196 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\ssimplifications\sand\simproved\scommentting\son\sthe\srowset.c\smodule,\nincluding\sseveral\soptimization\scomments. -D 2016-04-28T22:29:31.056 +C Some\soptimization\scomments\sadded\sto\svdbe.c.\s\sNo\sfunctional\schanges\sto\scode. +D 2016-04-29T02:55:05.603 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -443,7 +443,7 @@ F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c d3843a66d74a7696477ee5141e5eb9a7e5e2401c +F src/vdbe.c 08fbea00a7f7f723973093c5f5bf7c40c025e2b3 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8cdbe89ac6c22d632f677eb293111b3dbae7d6c1 -R 9629e5ecfb28b4deca7492eeb801c3d3 +P 9f15a520deb9f1d4ecaa3bfff82bd57ef122aadb +R 9e8b60c02f680bebef2b9615706e75d6 U drh -Z f98c64d26c6e12bfaaf00c7f14039634 +Z f25847a4d8f7c8c164def037ab0b4e49 diff --git a/manifest.uuid b/manifest.uuid index fd604e04b3..74550e35d8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9f15a520deb9f1d4ecaa3bfff82bd57ef122aadb \ No newline at end of file +e7c22e3bffce63f3b47fa3683be8c00c42b2a7d3 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 244a4ad063..5fba14a5c3 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -215,7 +215,7 @@ static VdbeCursor *allocateCursor( (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0); assert( iCur>=0 && iCurnCursor ); - if( p->apCsr[iCur] ){ + if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/ sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); p->apCsr[iCur] = 0; } @@ -292,7 +292,7 @@ static void applyAffinity( if( affinity>=SQLITE_AFF_NUMERIC ){ assert( affinity==SQLITE_AFF_INTEGER || affinity==SQLITE_AFF_REAL || affinity==SQLITE_AFF_NUMERIC ); - if( (pRec->flags & MEM_Int)==0 ){ + if( (pRec->flags & MEM_Int)==0 ){ /*OPTIMIZATION-IF-FALSE*/ if( (pRec->flags & MEM_Real)==0 ){ if( pRec->flags & MEM_Str ) applyNumericAffinity(pRec,1); }else{ @@ -302,10 +302,13 @@ static void applyAffinity( }else if( affinity==SQLITE_AFF_TEXT ){ /* Only attempt the conversion to TEXT if there is an integer or real ** representation (blob and NULL do not get converted) but no string - ** representation. - */ - if( 0==(pRec->flags&MEM_Str) && (pRec->flags&(MEM_Real|MEM_Int)) ){ - sqlite3VdbeMemStringify(pRec, enc, 1); + ** representation. It would be harmless to repeat the conversion if + ** there is already a string rep, but it is pointless to waste those + ** CPU cycles. */ + if( 0==(pRec->flags&MEM_Str) ){ /*OPTIMIZATION-IF-FALSE*/ + if( (pRec->flags&(MEM_Real|MEM_Int)) ){ + sqlite3VdbeMemStringify(pRec, enc, 1); + } } pRec->flags &= ~(MEM_Real|MEM_Int); } @@ -542,7 +545,7 @@ static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){ assert( pOp->p2<=(p->nMem+1 - p->nCursor) ); pOut = &p->aMem[pOp->p2]; memAboutToChange(p, pOut); - if( VdbeMemDynamic(pOut) ){ + if( VdbeMemDynamic(pOut) ){ /*OPTIMIZATION-IF-FALSE*/ return out2PrereleaseWithClear(pOut); }else{ pOut->flags = MEM_Int; From 14faa061fd4815f6f8f63bc4d00889b676c85c20 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 29 Apr 2016 10:13:22 +0000 Subject: [PATCH 17/18] Fix an almost entirely harmless buffer overread in the sessions module. FossilOrigin-Name: 89b0ee3351381f7bc666cb206f77a56f2e0d4a0e --- ext/session/sqlite3session.c | 17 +++++++++++------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index b058d357e2..e333dffcc7 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -592,14 +592,19 @@ static int sessionChangeEqual( int iCol; /* Used to iterate through table columns */ for(iCol=0; iColnCol; iCol++){ - int n1 = sessionSerialLen(a1); - int n2 = sessionSerialLen(a2); + if( pTab->abPK[iCol] ){ + int n1 = sessionSerialLen(a1); + int n2 = sessionSerialLen(a2); - if( pTab->abPK[iCol] && (n1!=n2 || memcmp(a1, a2, n1)) ){ - return 0; + if( pTab->abPK[iCol] && (n1!=n2 || memcmp(a1, a2, n1)) ){ + return 0; + } + a1 += n1; + a2 += n2; + }else{ + if( bLeftPkOnly==0 ) a1 += sessionSerialLen(a1); + if( bRightPkOnly==0 ) a2 += sessionSerialLen(a2); } - if( pTab->abPK[iCol] || bLeftPkOnly==0 ) a1 += n1; - if( pTab->abPK[iCol] || bRightPkOnly==0 ) a2 += n2; } return 1; diff --git a/manifest b/manifest index 61077e7077..77d5df7f09 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\slatest\schanges\sfrom\strunk\swith\sthis\sbranch. -D 2016-04-28T14:59:05.489 +C Fix\san\salmost\sentirely\sharmless\sbuffer\soverread\sin\sthe\ssessions\smodule. +D 2016-04-29T10:13:22.999 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -293,7 +293,7 @@ F ext/session/sessionG.test 01ef705096a9d3984eebdcca79807a211dee1b60 F ext/session/session_common.tcl a1293167d14774b5e728836720497f40fe4ea596 F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 -F ext/session/sqlite3session.c beb300cd1b5c5054062c8e6e807b10475e363410 +F ext/session/sqlite3session.c beb43b6b888801bb006320bc236baa95f4cc32ae F ext/session/sqlite3session.h 64e9e7f185725ef43b97f4a9a0c0df0669844f1d F ext/session/test_session.c 464f2c8bf502795d95969387eb8e93f68c513c15 F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220 @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5973d3bf2e5aa979ccc9a4a3a0eb08b67098b499 33e627472780b872716c504f2d585cc057c390a5 -R 66281bc4e8738b7ab348496eadeeb2b1 +P 45467ee49872f495d5276cf830f10c3cf4ac8e3c +R 50a6a2b7911c16c6704703bf8b17ce71 U dan -Z 4d2c4cbb1442cfb28a5ae33052756c7a +Z da972510c8d8b75cf481b4f80618fa01 diff --git a/manifest.uuid b/manifest.uuid index b1984ea171..f4d85f9254 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -45467ee49872f495d5276cf830f10c3cf4ac8e3c \ No newline at end of file +89b0ee3351381f7bc666cb206f77a56f2e0d4a0e \ No newline at end of file From afb8cd977d09759a29b6c89d3882e431fb86a480 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 29 Apr 2016 11:28:35 +0000 Subject: [PATCH 18/18] Lemon bug fix: Do not merge action routines unless their destructors are also identical. Problem and suggested fix reported on the mailing list by Kelvin Sherlock. FossilOrigin-Name: 4792d6dbba6857f74d27332dcc1468e39c767c71 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lemon.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index da4cac8196..df4dd75c55 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Some\soptimization\scomments\sadded\sto\svdbe.c.\s\sNo\sfunctional\schanges\sto\scode. -D 2016-04-29T02:55:05.603 +C Lemon\sbug\sfix:\s\sDo\snot\smerge\saction\sroutines\sunless\stheir\sdestructors\sare\nalso\sidentical.\s\sProblem\sand\ssuggested\sfix\sreported\son\sthe\smailing\slist\nby\sKelvin\sSherlock. +D 2016-04-29T11:28:35.306 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -1414,7 +1414,7 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c cfbfe061a4b2766512f6b484882eee2c86a14506 +F tool/lemon.c 83318dff3911e47f2b85e136e56aa1c4674a2d2b F tool/lempar.c 404ea3dc27dbeed343f0e61b1d36e97b9f5f0fb6 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9f15a520deb9f1d4ecaa3bfff82bd57ef122aadb -R 9e8b60c02f680bebef2b9615706e75d6 +P e7c22e3bffce63f3b47fa3683be8c00c42b2a7d3 +R 2a18b1b7e68842336a01e91672c4d16e U drh -Z f25847a4d8f7c8c164def037ab0b4e49 +Z 9e05af624d486885b70c45e730afddce diff --git a/manifest.uuid b/manifest.uuid index 74550e35d8..d7daf8acb8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e7c22e3bffce63f3b47fa3683be8c00c42b2a7d3 \ No newline at end of file +4792d6dbba6857f74d27332dcc1468e39c767c71 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 903fe97cfb..2f76465d89 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4402,7 +4402,8 @@ void ReportTable( writeRuleText(out, rp); fprintf(out, " */\n"); lineno++; for(rp2=rp->next; rp2; rp2=rp2->next){ - if( rp2->code==rp->code ){ + if( rp2->code==rp->code && rp2->codePrefix==rp->codePrefix + && rp2->codeSuffix==rp->codeSuffix ){ fprintf(out," case %d: /* ", rp2->iRule); writeRuleText(out, rp2); fprintf(out," */ yytestcase(yyruleno==%d);\n", rp2->iRule); lineno++;