diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-03-12 00:52:10 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-03-12 00:52:10 +0000 |
commit | 6eeb95f0f56bb5e8a0a9328aeec04c9e6de87272 (patch) | |
tree | 5f209c5926768472f9d4fd7210065c18831dbd9c /src/backend/optimizer/prep/prepunion.c | |
parent | 66b6bf67a197db73a880d2a4d9dab05168cde8e0 (diff) |
Restructure representation of join alias variables. An explicit JOIN
now has an RTE of its own, and references to its outputs now are Vars
referencing the JOIN RTE, rather than CASE-expressions. This allows
reverse-listing in ruleutils.c to use the correct alias easily, rather
than painfully reverse-engineering the alias namespace as it used to do.
Also, nested FULL JOINs work correctly, because the result of the inner
joins are simple Vars that the planner can cope with. This fixes a bug
reported a couple times now, notably by Tatsuo on 18-Nov-01. The alias
Vars are expanded into COALESCE expressions where needed at the very end
of planning, rather than during parsing.
Also, beginnings of support for showing plan qualifier expressions in
EXPLAIN. There are probably still cases that need work.
initdb forced due to change of stored-rule representation.
Diffstat (limited to 'src/backend/optimizer/prep/prepunion.c')
-rw-r--r-- | src/backend/optimizer/prep/prepunion.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 64d8b78f066..b2f18780fcc 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.71 2002/03/05 05:10:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.72 2002/03/12 00:51:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -673,7 +673,7 @@ List * expand_inherted_rtentry(Query *parse, Index rti, bool dup_parent) { RangeTblEntry *rte = rt_fetch(rti, parse->rtable); - Oid parentOID = rte->relid; + Oid parentOID; List *inhOIDs; List *inhRTIs; List *l; @@ -681,10 +681,11 @@ expand_inherted_rtentry(Query *parse, Index rti, bool dup_parent) /* Does RT entry allow inheritance? */ if (!rte->inh) return NIL; - Assert(parentOID != InvalidOid && rte->subquery == NULL); + Assert(rte->rtekind == RTE_RELATION); /* Always clear the parent's inh flag, see above comments */ rte->inh = false; /* Fast path for common case of childless table */ + parentOID = rte->relid; if (!has_subclass(parentOID)) return NIL; /* Scan for all members of inheritance set */ @@ -811,6 +812,19 @@ adjust_inherited_attrs_mutator(Node *node, rtr->rtindex = context->new_rt_index; return (Node *) rtr; } + if (IsA(node, JoinExpr)) + { + /* Copy the JoinExpr node with correct mutation of subnodes */ + JoinExpr *j; + + j = (JoinExpr *) expression_tree_mutator(node, + adjust_inherited_attrs_mutator, + (void *) context); + /* now fix JoinExpr's rtindex */ + if (j->rtindex == context->old_rt_index) + j->rtindex = context->new_rt_index; + return (Node *) j; + } /* * We have to process RestrictInfo nodes specially: we do NOT want to |