Skip to content

Commit f4abd02

Browse files
committed
Support flattening of empty-FROM subqueries and one-row VALUES tables.
We can't handle this in the general case due to limitations of the planner's data representations; but we can allow it in many useful cases, by being careful to flatten only when we are pulling a single-row subquery up into a FROM (or, equivalently, inner JOIN) node that will still have at least one remaining relation child. Per discussion of an example from Kyotaro Horiguchi.
1 parent b746d0c commit f4abd02

File tree

9 files changed

+466
-71
lines changed

9 files changed

+466
-71
lines changed

src/backend/nodes/outfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,7 @@ _outPlannerInfo(StringInfo str, const PlannerInfo *node)
17621762
WRITE_BOOL_FIELD(hasInheritedTarget);
17631763
WRITE_BOOL_FIELD(hasJoinRTEs);
17641764
WRITE_BOOL_FIELD(hasLateralRTEs);
1765+
WRITE_BOOL_FIELD(hasDeletedRTEs);
17651766
WRITE_BOOL_FIELD(hasHavingQual);
17661767
WRITE_BOOL_FIELD(hasPseudoConstantQuals);
17671768
WRITE_BOOL_FIELD(hasRecursion);

src/backend/optimizer/plan/planner.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
352352
* Check to see if any subqueries in the jointree can be merged into this
353353
* query.
354354
*/
355-
parse->jointree = (FromExpr *)
356-
pull_up_subqueries(root, (Node *) parse->jointree);
355+
pull_up_subqueries(root);
357356

358357
/*
359358
* If this is a simple UNION ALL query, flatten it into an appendrel. We

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy