Commit e2004dfc authored by Tom Lane's avatar Tom Lane

Suppress pull-up of subqueries that are in the nullable side of an outer

join.  This is needed to avoid improper evaluation of expressions that
should be nulled out, as in Victor Wagner's bug report of 4/27/01.
Pretty ugly solution, but no time to do anything better for 7.1.1.
parent 60ba30d1
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.104 2001/04/18 20:42:55 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.105 2001/04/30 19:24:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -363,8 +363,41 @@ pull_up_subqueries(Query *parse, Node *jtnode)
{
JoinExpr *j = (JoinExpr *) jtnode;
j->larg = pull_up_subqueries(parse, j->larg);
j->rarg = pull_up_subqueries(parse, j->rarg);
/*
* At the moment, we can't pull up subqueries that are inside the
* nullable side of an outer join, because substituting their target
* list entries for upper Var references wouldn't do the right thing
* (the entries wouldn't go to NULL when they're supposed to).
* Suppressing the pullup is an ugly, performance-losing hack, but
* I see no alternative for now. Find a better way to handle this
* when we redesign query trees --- tgl 4/30/01.
*/
switch (j->jointype)
{
case JOIN_INNER:
j->larg = pull_up_subqueries(parse, j->larg);
j->rarg = pull_up_subqueries(parse, j->rarg);
break;
case JOIN_LEFT:
j->larg = pull_up_subqueries(parse, j->larg);
break;
case JOIN_FULL:
break;
case JOIN_RIGHT:
j->rarg = pull_up_subqueries(parse, j->rarg);
break;
case JOIN_UNION:
/*
* This is where we fail if upper levels of planner
* haven't rewritten UNION JOIN as an Append ...
*/
elog(ERROR, "UNION JOIN is not implemented yet");
break;
default:
elog(ERROR, "pull_up_subqueries: unexpected join type %d",
j->jointype);
break;
}
}
else
elog(ERROR, "pull_up_subqueries: unexpected node type %d",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment