Re: variable not found in subplan target list? + test case

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: variable not found in subplan target list? + test case
Date: 2003-11-26 00:02:54
Message-ID: 9637.1069804974@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)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++;

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2003-11-26 00:45:23 Re: SELECT with MANY tables
Previous Message Javier Carlos 2003-11-25 23:05:50 Re: SELECT with MANY tables