-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: cherry-pick f62f983b56623f0e from sqlite.
- Loading branch information
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fix_a_problem_handling_sub-queries_with_both_a_correlated_where.patch |
22 changes: 22 additions & 0 deletions
22
patches/sqlite/fix_a_problem_handling_sub-queries_with_both_a_correlated_where.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Pedro Pontes <pepontes@microsoft.com> | ||
Date: Wed, 20 Jan 2021 23:31:45 +0100 | ||
Subject: Fix a problem handling sub-queries with both a correlated WHERE clause and a "HAVING 0" clause where the parent query is itself an aggregate. The problem was apparently introduced by check-in [6e6b3729e0549de0]. | ||
SHA3-256: f62f983b56623f0ec34f9a54ce1c21b013a20399162f5ee6ee43b23f10c2ecd5 | ||
User & Date: dan on 2020-12-22 16:23:29 | ||
|
||
diff --git a/src/select.c b/src/select.c | ||
index 8b1fae75a510e0ec8f9fb5c5732ca7426662f801..0bc3792dce6ba1f9db7f5cc65a4c5981f74bbd19 100644 | ||
--- a/src/select.c | ||
+++ b/src/select.c | ||
@@ -5585,7 +5585,9 @@ static void explainSimpleCount( | ||
static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){ | ||
if( pExpr->op!=TK_AND ){ | ||
Select *pS = pWalker->u.pSelect; | ||
- if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy) ){ | ||
+ if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy) | ||
+ && ExprAlwaysFalse(pExpr)==0 | ||
+ ){ | ||
sqlite3 *db = pWalker->pParse->db; | ||
Expr *pNew = sqlite3Expr(db, TK_INTEGER, "1"); | ||
if( pNew ){ |