summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-11-25 23:59:32 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-11-25 23:59:32 +0000
commitd6dd992b4c855f826455783a05891612459d47ff (patch)
treec4db67f865cd10f9be9ddbd10fa0bb46db72933c /src
parent1230343332ef814bac5312942360bbcdfff88e6d (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/plan/subselect.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
index 11612f408c9..5da291835ad 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.83 2003/10/18 16:52:15 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.83.2.1 2003/11/25 23:59:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -118,6 +118,11 @@ replace_outer_var(Var *var)
* well, I believe that this sort of aliasing will cause no trouble.
* The correct field should get stored into the Param slot at
* 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;
foreach(ppl, PlannerParamList)
@@ -129,7 +134,8 @@ replace_outer_var(Var *var)
if (pvar->varno == var->varno &&
pvar->varattno == var->varattno &&
- pvar->vartype == var->vartype)
+ pvar->vartype == var->vartype &&
+ pvar->vartypmod == var->vartypmod)
break;
}
i++;