mirror of
https://github.com/postgres/postgres.git
synced 2025-08-22 21:53:06 +03:00
Second try at fixing join alias variables. Instead of attaching miscellaneous
lists to join RTEs, attach a list of Vars and COALESCE expressions that will replace the join's alias variables during planning. This simplifies flatten_join_alias_vars while still making it easy to fix up varno references when transforming the query tree. Add regression test cases for interactions of subqueries with outer joins.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.181 2002/04/24 02:48:54 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.182 2002/04/28 19:54:28 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -323,7 +323,6 @@ CopyJoinFields(Join *from, Join *newnode)
|
||||
{
|
||||
newnode->jointype = from->jointype;
|
||||
Node_Copy(from, newnode, joinqual);
|
||||
newnode->joinrti = from->joinrti;
|
||||
/* subPlan list must point to subplans in the new subtree, not the old */
|
||||
if (from->plan.subPlan != NIL)
|
||||
newnode->plan.subPlan = nconc(newnode->plan.subPlan,
|
||||
@@ -1475,10 +1474,7 @@ _copyRangeTblEntry(RangeTblEntry *from)
|
||||
newnode->relid = from->relid;
|
||||
Node_Copy(from, newnode, subquery);
|
||||
newnode->jointype = from->jointype;
|
||||
newnode->joincoltypes = listCopy(from->joincoltypes);
|
||||
newnode->joincoltypmods = listCopy(from->joincoltypmods);
|
||||
newnode->joinleftcols = listCopy(from->joinleftcols);
|
||||
newnode->joinrightcols = listCopy(from->joinrightcols);
|
||||
Node_Copy(from, newnode, joinaliasvars);
|
||||
Node_Copy(from, newnode, alias);
|
||||
Node_Copy(from, newnode, eref);
|
||||
newnode->inh = from->inh;
|
||||
|
@@ -20,7 +20,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.129 2002/04/24 02:48:54 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.130 2002/04/28 19:54:28 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1680,13 +1680,7 @@ _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
|
||||
return false;
|
||||
if (a->jointype != b->jointype)
|
||||
return false;
|
||||
if (!equali(a->joincoltypes, b->joincoltypes))
|
||||
return false;
|
||||
if (!equali(a->joincoltypmods, b->joincoltypmods))
|
||||
return false;
|
||||
if (!equali(a->joinleftcols, b->joinleftcols))
|
||||
return false;
|
||||
if (!equali(a->joinrightcols, b->joinrightcols))
|
||||
if (!equal(a->joinaliasvars, b->joinaliasvars))
|
||||
return false;
|
||||
if (!equal(a->alias, b->alias))
|
||||
return false;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.156 2002/04/17 20:57:56 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.157 2002/04/28 19:54:28 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||
@@ -408,8 +408,6 @@ _outJoin(StringInfo str, Join *node)
|
||||
appendStringInfo(str, " :jointype %d :joinqual ",
|
||||
(int) node->jointype);
|
||||
_outNode(str, node->joinqual);
|
||||
appendStringInfo(str, " :joinrti %d ",
|
||||
node->joinrti);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -423,8 +421,6 @@ _outNestLoop(StringInfo str, NestLoop *node)
|
||||
appendStringInfo(str, " :jointype %d :joinqual ",
|
||||
(int) node->join.jointype);
|
||||
_outNode(str, node->join.joinqual);
|
||||
appendStringInfo(str, " :joinrti %d ",
|
||||
node->join.joinrti);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -438,8 +434,6 @@ _outMergeJoin(StringInfo str, MergeJoin *node)
|
||||
appendStringInfo(str, " :jointype %d :joinqual ",
|
||||
(int) node->join.jointype);
|
||||
_outNode(str, node->join.joinqual);
|
||||
appendStringInfo(str, " :joinrti %d ",
|
||||
node->join.joinrti);
|
||||
|
||||
appendStringInfo(str, " :mergeclauses ");
|
||||
_outNode(str, node->mergeclauses);
|
||||
@@ -456,8 +450,6 @@ _outHashJoin(StringInfo str, HashJoin *node)
|
||||
appendStringInfo(str, " :jointype %d :joinqual ",
|
||||
(int) node->join.jointype);
|
||||
_outNode(str, node->join.joinqual);
|
||||
appendStringInfo(str, " :joinrti %d ",
|
||||
node->join.joinrti);
|
||||
|
||||
appendStringInfo(str, " :hashclauses ");
|
||||
_outNode(str, node->hashclauses);
|
||||
@@ -982,22 +974,16 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
|
||||
{
|
||||
case RTE_RELATION:
|
||||
case RTE_SPECIAL:
|
||||
appendStringInfo(str, ":relid %u ", node->relid);
|
||||
appendStringInfo(str, ":relid %u", node->relid);
|
||||
break;
|
||||
case RTE_SUBQUERY:
|
||||
appendStringInfo(str, ":subquery ");
|
||||
_outNode(str, node->subquery);
|
||||
break;
|
||||
case RTE_JOIN:
|
||||
appendStringInfo(str, ":jointype %d :joincoltypes ",
|
||||
appendStringInfo(str, ":jointype %d :joinaliasvars ",
|
||||
(int) node->jointype);
|
||||
_outOidList(str, node->joincoltypes);
|
||||
appendStringInfo(str, " :joincoltypmods ");
|
||||
_outIntList(str, node->joincoltypmods);
|
||||
appendStringInfo(str, " :joinleftcols ");
|
||||
_outIntList(str, node->joinleftcols);
|
||||
appendStringInfo(str, " :joinrightcols ");
|
||||
_outIntList(str, node->joinrightcols);
|
||||
_outNode(str, node->joinaliasvars);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "bogus rte kind %d", (int) node->rtekind);
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.119 2002/04/11 20:00:00 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.120 2002/04/28 19:54:28 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Most of the read functions for plan nodes are tested. (In fact, they
|
||||
@@ -421,10 +421,6 @@ _getJoin(Join *node)
|
||||
|
||||
token = pg_strtok(&length); /* skip the :joinqual */
|
||||
node->joinqual = nodeRead(true); /* get the joinqual */
|
||||
|
||||
token = pg_strtok(&length); /* skip the :joinrti */
|
||||
token = pg_strtok(&length); /* get the joinrti */
|
||||
node->joinrti = atoi(token);
|
||||
}
|
||||
|
||||
|
||||
@@ -1523,17 +1519,8 @@ _readRangeTblEntry(void)
|
||||
token = pg_strtok(&length); /* get jointype */
|
||||
local_node->jointype = (JoinType) atoi(token);
|
||||
|
||||
token = pg_strtok(&length); /* eat :joincoltypes */
|
||||
local_node->joincoltypes = toOidList(nodeRead(true));
|
||||
|
||||
token = pg_strtok(&length); /* eat :joincoltypmods */
|
||||
local_node->joincoltypmods = toIntList(nodeRead(true));
|
||||
|
||||
token = pg_strtok(&length); /* eat :joinleftcols */
|
||||
local_node->joinleftcols = toIntList(nodeRead(true));
|
||||
|
||||
token = pg_strtok(&length); /* eat :joinrightcols */
|
||||
local_node->joinrightcols = toIntList(nodeRead(true));
|
||||
token = pg_strtok(&length); /* eat :joinaliasvars */
|
||||
local_node->joinaliasvars = nodeRead(true); /* now read it */
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Reference in New Issue
Block a user