aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-04-22 19:56:12 +0000
committerdrh <drh@noemail.net>2013-04-22 19:56:12 +0000
commitd99aaf10df79c5cec4f8993f2936a476d3a265a9 (patch)
treefcfc851233122a4c73ef760cbde18b02af51aa82 /src
parent4d648c777bc9ab75f4f25e31a4f206f469775189 (diff)
downloadsqlite-d99aaf10df79c5cec4f8993f2936a476d3a265a9.tar.gz
sqlite-d99aaf10df79c5cec4f8993f2936a476d3a265a9.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/where.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/where.c b/src/where.c
index 24b059e2d..d70205205 100644
--- a/src/where.c
+++ b/src/where.c
@@ -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