Commit 53e2b794 authored by Tom Lane's avatar Tom Lane

Repair oversight in recent change of dependency extraction code: when

recursing to handle a join alias var, the context had better be set to
be appropriate to the join var's query level.  Per report from Hristo Neshev.
parent 20f28724
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.13 2002/11/30 21:25:04 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.14 2002/12/04 20:00:37 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -789,6 +789,11 @@ find_expr_references_walker(Node *node, ...@@ -789,6 +789,11 @@ find_expr_references_walker(Node *node,
else if (rte->rtekind == RTE_JOIN) else if (rte->rtekind == RTE_JOIN)
{ {
/* Scan join output column to add references to join inputs */ /* Scan join output column to add references to join inputs */
List *save_rtables;
/* We must make the context appropriate for join's level */
save_rtables = context->rtables;
context->rtables = rtables;
if (var->varattno <= 0 || if (var->varattno <= 0 ||
var->varattno > length(rte->joinaliasvars)) var->varattno > length(rte->joinaliasvars))
elog(ERROR, "find_expr_references_walker: bogus varattno %d", elog(ERROR, "find_expr_references_walker: bogus varattno %d",
...@@ -796,6 +801,7 @@ find_expr_references_walker(Node *node, ...@@ -796,6 +801,7 @@ find_expr_references_walker(Node *node,
find_expr_references_walker((Node *) nth(var->varattno - 1, find_expr_references_walker((Node *) nth(var->varattno - 1,
rte->joinaliasvars), rte->joinaliasvars),
context); context);
context->rtables = save_rtables;
} }
return false; return false;
} }
......
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