Commit e7a45c78 authored by Tom Lane's avatar Tom Lane

Repair subselect.c's occasional assignment of the wrong vartypmod to

Vars created to fill subplan args lists.  This is an ancient error, going
back at least to 7.0, but is more easily triggered in 7.4 than before
because we no longer compare varlevelsup when deciding whether a Param
slot can be re-used.  Fixes bug reported by Klint Gore.
parent a64846f3
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,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/optimizer/plan/subselect.c,v 1.84 2003/11/25 21:00:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.85 2003/11/25 23:59:12 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -118,6 +118,11 @@ replace_outer_var(Var *var) ...@@ -118,6 +118,11 @@ replace_outer_var(Var *var)
* well, I believe that this sort of aliasing will cause no trouble. * well, I believe that this sort of aliasing will cause no trouble.
* The correct field should get stored into the Param slot at * The correct field should get stored into the Param slot at
* execution in each part of the tree. * execution in each part of the tree.
*
* We also need to demand a match on vartypmod. This does not matter
* for the Param itself, since those are not typmod-dependent, but it
* does matter when make_subplan() instantiates a modified copy of the
* Var for a subplan's args list.
*/ */
i = 0; i = 0;
foreach(ppl, PlannerParamList) foreach(ppl, PlannerParamList)
...@@ -129,7 +134,8 @@ replace_outer_var(Var *var) ...@@ -129,7 +134,8 @@ replace_outer_var(Var *var)
if (pvar->varno == var->varno && if (pvar->varno == var->varno &&
pvar->varattno == var->varattno && pvar->varattno == var->varattno &&
pvar->vartype == var->vartype) pvar->vartype == var->vartype &&
pvar->vartypmod == var->vartypmod)
break; break;
} }
i++; i++;
......
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