1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Fix mishandling of whole-row Vars referencing a view or sub-select.

If such a Var appeared within a nested sub-select, we failed to translate it
correctly during pullup of the view, because the recursive call to
replace_rte_variables_mutator was looking for the wrong sublevels_up value.
Bug was introduced during the addition of the PlaceHolderVar mechanism.
Per bug #5514 from Marcos Castedo.
This commit is contained in:
Tom Lane
2010-06-21 00:14:48 +00:00
parent 31c47e53aa
commit f685cbbac8
3 changed files with 49 additions and 1 deletions

View File

@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.71 2010/02/26 02:00:46 momjian Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.72 2010/06/21 00:14:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1297,6 +1297,7 @@ pullup_replace_vars_callback(Var *var,
List *colnames;
List *fields;
bool save_need_phvs = rcon->need_phvs;
int save_sublevelsup = context->sublevels_up;
/*
* If generating an expansion for a var of a named rowtype (ie, this
@ -1314,9 +1315,12 @@ pullup_replace_vars_callback(Var *var,
&colnames, &fields);
/* Adjust the generated per-field Vars, but don't insert PHVs */
rcon->need_phvs = false;
context->sublevels_up = 0; /* to match the expandRTE output */
fields = (List *) replace_rte_variables_mutator((Node *) fields,
context);
rcon->need_phvs = save_need_phvs;
context->sublevels_up = save_sublevelsup;
rowexpr = makeNode(RowExpr);
rowexpr->args = fields;
rowexpr->row_typeid = var->vartype;