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

Commit173a676

Browse files
committed
Don't try to optimize EXISTS subqueries with empty FROM-lists: we need to
form a join and that case doesn't have anything to join to. (We couldprobably make it work if we didn't pull up the subquery, but it seems tome that the case isn't worth extra code.) Per report from Greg Stark.
1 parentaa7f004 commit173a676

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 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.142 2008/10/21 20:42:53 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.143 2008/12/08 00:16:09 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1097,6 +1097,12 @@ convert_EXISTS_sublink_to_join(PlannerInfo *root, SubLink *sublink,
10971097
if (!simplify_EXISTS_query(subselect))
10981098
return false;
10991099

1100+
/*
1101+
* The subquery must have a nonempty jointree, else we won't have a join.
1102+
*/
1103+
if (subselect->jointree->fromlist==NIL)
1104+
return false;
1105+
11001106
/*
11011107
* Separate out the WHERE clause. (We could theoretically also remove
11021108
* top-level plain JOIN/ON clauses, but it's probably not worth the
@@ -1180,6 +1186,7 @@ convert_EXISTS_sublink_to_join(PlannerInfo *root, SubLink *sublink,
11801186
/* Identify all the rels syntactically within the subselect */
11811187
subselect_varnos=get_relids_in_jointree((Node*)subselect->jointree,
11821188
true);
1189+
Assert(!bms_is_empty(subselect_varnos));
11831190
Assert(bms_is_subset(right_varnos,subselect_varnos));
11841191

11851192
/* Now we can attach the modified subquery rtable to the parent */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp