1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-21 09:00:59 +03:00

Do not allow a virtual table to cancel the ORDER BY clause unless all

outer loops are guaranteed to return no more than one row result.
Candidate fix for ticket [ba82a4a41eac1].

FossilOrigin-Name: 49cfa14fceeef2d55b449eb927c283ce6f650c07
This commit is contained in:
drh
2013-04-22 19:56:12 +00:00
parent 4d648c777b
commit d99aaf10df
3 changed files with 18 additions and 7 deletions

View File

@@ -2400,6 +2400,17 @@ static void bestVirtualIndex(WhereBestIdx *p){
}
if( i>=pIdxInfo->nConstraint ) break;
}
/* The orderByConsumed signal is only valid if all outer loops collectively
** generate just a single row of output.
*/
if( pIdxInfo->orderByConsumed ){
for(i=0; i<p->i; i++){
if( (p->aLevel[i].plan.wsFlags & WHERE_UNIQUE)==0 ){
pIdxInfo->orderByConsumed = 0;
}
}
}
/* If there is an ORDER BY clause, and the selected virtual table index
** does not satisfy it, increase the cost of the scan accordingly. This