mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-18 10:21:03 +03:00
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
This commit is contained in:
24
src/where.c
24
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user