Skip to content

Commit cbf943b

Browse files
author
D. Richard Hipp
committed
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.
1 parent 27c892f commit cbf943b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/select.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8498,6 +8498,11 @@ int sqlite3Select(
84988498
if( iOrderByCol ){
84998499
Expr *pX = p->pEList->a[iOrderByCol-1].pExpr;
85008500
Expr *pBase = sqlite3ExprSkipCollateAndLikely(pX);
8501+
if( ALWAYS(pBase!=0)
8502+
&& pBase->op==TK_IF_NULL_ROW
8503+
){
8504+
pBase = pX = pBase->pLeft;
8505+
}
85018506
if( ALWAYS(pBase!=0)
85028507
&& pBase->op!=TK_AGG_COLUMN
85038508
&& pBase->op!=TK_REGISTER

0 commit comments

Comments
 (0)