Klint Gore <kg@kgb.une.edu.au> writes:
>> Can you send a test case with table and view definitions, it's hard to
>> generate one from just the information above.
> ok. the last select generates the error.
Hoo, that was a fun one. Here's the patch.
regards, tom lane
*** src/backend/optimizer/plan/subselect.c.orig Tue Nov 25 16:00:54 2003
--- src/backend/optimizer/plan/subselect.c Tue Nov 25 18:25:32 2003
***************
*** 118,123 ****
--- 118,128 ----
* 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,135 ****
if (pvar->varno == var->varno &&
pvar->varattno == var->varattno &&
! pvar->vartype == var->vartype)
break;
}
i++;
--- 134,141 ----
if (pvar->varno == var->varno &&
pvar->varattno == var->varattno &&
! pvar->vartype == var->vartype &&
! pvar->vartypmod == var->vartypmod)
break;
}
i++;