aboutsummaryrefslogtreecommitdiff
path: root/src/select.c
diff options
context:
space:
mode:
authordrh <>2021-05-20 00:44:04 +0000
committerdrh <>2021-05-20 00:44:04 +0000
commitcd1499f47b1de7c6ca9eb9e68e169218a203c5df (patch)
tree9426f29f5bd89df5876ea8af4aa0535e088cff9a /src/select.c
parent5da5b71435fcb7d4cd8e43a3ce386b5c852e4e2e (diff)
downloadsqlite-cd1499f47b1de7c6ca9eb9e68e169218a203c5df.tar.gz
sqlite-cd1499f47b1de7c6ca9eb9e68e169218a203c5df.zip
Replace [0f0959c6f95046e8] with a new and better solution that also fixes the
CTE name resolution problem described in [forum:/forumpost/8590e3f6dc|forum post 8590e3f6dc]. Test cases for both problems added. FossilOrigin-Name: 5614279daff5007d6e047c5c1b3cc82ba80a5c91c529525b0fe68b79ee82dd2c
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/select.c b/src/select.c
index aeb63d99d..1ac25c5de 100644
--- a/src/select.c
+++ b/src/select.c
@@ -5071,6 +5071,14 @@ static int resolveFromTermToCte(
** it cannot possibly be a CTE reference. */
return 0;
}
+ if( pFrom->fg.notCte ){
+ /* The FROM term is specifically excluded from matching a CTE.
+ ** (1) It is part of a trigger that used to have zDatabase but had
+ ** zDatabase removed by sqlite3FixTriggerStep().
+ ** (2) This is the first term in the FROM clause of an UPDATE.
+ */
+ return 0;
+ }
pCte = searchWith(pParse->pWith, pFrom, &pWith);
if( pCte ){
sqlite3 *db = pParse->db;