aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2025-05-16 17:30:20 +0000
committerdrh <>2025-05-16 17:30:20 +0000
commitcd64392301b921015a9381f2747248b31c0fe606 (patch)
treecf363eee346fa907208482fd2bd3a73ea6cef02c /src
parentcecf833325535a91edc9b4ceb57ffe6a438c4b53 (diff)
downloadsqlite-cd64392301b921015a9381f2747248b31c0fe606.tar.gz
sqlite-cd64392301b921015a9381f2747248b31c0fe606.zip
Fix the optimization of check-in [663f5dd32d9db832] that strives to avoid
duplicate compuations in the GROUP BY clause so that it works even if the GROUP BY term is a subquery on the RHS of a LEFT JOIN. Problem found by dbsqlfuzz. Test cases in TH3. FossilOrigin-Name: 955a026996b93e530ca5b566689cc646b31d3b9b5a5837897a58452d70f6d942
Diffstat (limited to 'src')
-rw-r--r--src/select.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/select.c b/src/select.c
index 6e8ee58bc..cf535dc79 100644
--- a/src/select.c
+++ b/src/select.c
@@ -8499,6 +8499,11 @@ int sqlite3Select(
Expr *pX = p->pEList->a[iOrderByCol-1].pExpr;
Expr *pBase = sqlite3ExprSkipCollateAndLikely(pX);
if( ALWAYS(pBase!=0)
+ && pBase->op==TK_IF_NULL_ROW
+ ){
+ pBase = pX = pBase->pLeft;
+ }
+ if( ALWAYS(pBase!=0)
&& pBase->op!=TK_AGG_COLUMN
&& pBase->op!=TK_REGISTER
){