Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita49147a

Browse files
committed
Fix an oversight in convert_EXISTS_sublink_to_join: we can't convert an
EXISTS that contains a WITH clause. This would usually lead to a"could not find CTE" error later in planning, because the WITH wouldn'tget processed at all. Noted while playing with an example from Ken Marshall.
1 parenta0a7e63 commita49147a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎src/backend/optimizer/plan/subselect.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.157 2010/01/02 16:57:47 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.158 2010/01/18 18:17:45 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1114,6 +1114,17 @@ convert_EXISTS_sublink_to_join(PlannerInfo *root, SubLink *sublink,
11141114

11151115
Assert(sublink->subLinkType==EXISTS_SUBLINK);
11161116

1117+
/*
1118+
* Can't flatten if it contains WITH. (We could arrange to pull up the
1119+
* WITH into the parent query's cteList, but that risks changing the
1120+
* semantics, since a WITH ought to be executed once per associated query
1121+
* call.) Note that convert_ANY_sublink_to_join doesn't have to reject
1122+
* this case, since it just produces a subquery RTE that doesn't have to
1123+
* get flattened into the parent query.
1124+
*/
1125+
if (subselect->cteList)
1126+
returnNULL;
1127+
11171128
/*
11181129
* Copy the subquery so we can modify it safely (see comments in
11191130
* make_subplan).

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp