aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <>2022-10-15 12:01:40 +0000
committerdrh <>2022-10-15 12:01:40 +0000
commitf3adb7c43092d6af97a71e32e3cb4f714afe63ea (patch)
tree8747a7507dfd6fd261754921e5afe01612f32096 /src/expr.c
parent7a98937db2414e60a75991e637c0da6b87dd6336 (diff)
downloadsqlite-f3adb7c43092d6af97a71e32e3cb4f714afe63ea.tar.gz
sqlite-f3adb7c43092d6af97a71e32e3cb4f714afe63ea.zip
Enable the index-on-expression optimization even when the expression is
used as an argument to an aggregate function. FossilOrigin-Name: 462b3c7f39724dc814f55e7a225e7d0c48f81c524cdda797a66e9e198c35ce58
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/expr.c b/src/expr.c
index 0ff364ddc..4bff00411 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -5618,7 +5618,13 @@ int sqlite3ExprCompare(
if( pB->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA,pB->pLeft,iTab)<2 ){
return 1;
}
- return 2;
+ if( pA->op==TK_AGG_COLUMN && pB->op==TK_COLUMN
+ && pB->iTable<0 && pA->iTable==iTab
+ ){
+ /* fall through */
+ }else{
+ return 2;
+ }
}
assert( !ExprHasProperty(pA, EP_IntValue) );
assert( !ExprHasProperty(pB, EP_IntValue) );