From: drh Date: Wed, 12 Oct 2016 18:55:53 +0000 (+0000) Subject: Avoid reading the -1-th element of an array in the query planner. Fix to a X-Git-Tag: version-3.15.0~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c436a03d027f27d33f6ba5a95724b0a9c4e814e9;p=thirdparty%2Fsqlite.git Avoid reading the -1-th element of an array in the query planner. Fix to a bug introduced by check-in [8e2b25f9b8a7] from earlier today. Curiously, the problem only appeared on 32-bit systems. FossilOrigin-Name: 443913d582bcd953d85159047541592e2f68ade3 --- diff --git a/manifest b/manifest index 241e0db8a7..9719134aaa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sto\ssqlite3_analyzer\scommand-line\soptions\s--version\sand\s--tclsh,\sand\salso\nthe\sundocumented\s--debug\soption. -D 2016-10-12T18:26:26.364 +C Avoid\sreading\sthe\s-1-th\selement\sof\san\sarray\sin\sthe\squery\splanner.\s\sFix\sto\sa\nbug\sintroduced\sby\scheck-in\s[8e2b25f9b8a7]\sfrom\searlier\stoday.\s\sCuriously,\nthe\sproblem\sonly\sappeared\son\s32-bit\ssystems. +D 2016-10-12T18:55:53.185 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f @@ -467,7 +467,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 91a6df7435827e41cff6bb7df50ea00934ee78b0 -F src/where.c 7e454887a70a8263f663eab8c9d0f6ecc8ec7ac7 +F src/where.c 5f846d94bb3d35b3146d9915eb301ee362957b0a F src/whereInt.h 2bcc3d176e6091cb8f50a30b65c006e88a73614d F src/wherecode.c 717a65294df46f30e9b9933d2a63a4bcbca5a9a8 F src/whereexpr.c 379d0017fb7bc9e5a4d8cd4b056c747de946430e @@ -1525,7 +1525,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 61f0526978af667781c57bcc87510e4524efd0d8 -R 939be1793993bb5a0733cfe788e02f4d +P e87d02d289a2016ea3ee074e914b07a8ac22b21f +R 347ceac05d5e830be9b0b453b9055752 U drh -Z 3046f41ed5ee9baf8f6c825aaff1459e +Z f6a48b076f4d91846fe2072e2532d39d diff --git a/manifest.uuid b/manifest.uuid index ceae9890fc..f1cc7550cb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e87d02d289a2016ea3ee074e914b07a8ac22b21f \ No newline at end of file +443913d582bcd953d85159047541592e2f68ade3 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 443e9ea82d..c75eb943f3 100644 --- a/src/where.c +++ b/src/where.c @@ -4123,19 +4123,21 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ pWInfo->nOBSat = pFrom->isOrdered; pWInfo->revMask = pFrom->revLoop; if( pWInfo->nOBSat<=0 ){ - u32 wsFlags = pFrom->aLoop[nLoop-1]->wsFlags; pWInfo->nOBSat = 0; - if( nLoop>0 && (wsFlags & WHERE_ONEROW)==0 - && (wsFlags & (WHERE_IPK|WHERE_COLUMN_IN))!=(WHERE_IPK|WHERE_COLUMN_IN) - ){ - Bitmask m = 0; - int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom, + if( nLoop>0 ){ + u32 wsFlags = pFrom->aLoop[nLoop-1]->wsFlags; + if( (wsFlags & WHERE_ONEROW)==0 + && (wsFlags&(WHERE_IPK|WHERE_COLUMN_IN))!=(WHERE_IPK|WHERE_COLUMN_IN) + ){ + Bitmask m = 0; + int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom, WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m); - testcase( wsFlags & WHERE_IPK ); - testcase( wsFlags & WHERE_COLUMN_IN ); - if( rc==pWInfo->pOrderBy->nExpr ){ - pWInfo->bOrderedInnerLoop = 1; - pWInfo->revMask = m; + testcase( wsFlags & WHERE_IPK ); + testcase( wsFlags & WHERE_COLUMN_IN ); + if( rc==pWInfo->pOrderBy->nExpr ){ + pWInfo->bOrderedInnerLoop = 1; + pWInfo->revMask = m; + } } } }