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

Fix incorrect generation of whole-row variables in planner.

A couple of places in the planner need to generate whole-row Vars, and were
cutting corners by setting vartype = RECORDOID in the Vars, even in cases
where there's an identifiable named composite type for the RTE being
referenced.  While we mostly got away with this, it failed when there was
also a parser-generated whole-row reference to the same RTE, because the
two Vars weren't equal() due to the difference in vartype.  Fix by
providing a subroutine the planner can call to generate whole-row Vars
the same way the parser does.

Per bug #5716 from Andrew Tipton.  Back-patch to 9.0 where one of the bogus
calls was introduced (the other one is new in HEAD).
This commit is contained in:
Tom Lane
2010-10-19 15:08:37 -04:00
parent 722d5beeb2
commit 6e74a91b2b
7 changed files with 183 additions and 88 deletions

View File

@ -139,11 +139,9 @@ preprocess_targetlist(PlannerInfo *root, List *tlist)
else
{
/* Not a table, so we need the whole row as a junk var */
var = makeVar(rc->rti,
InvalidAttrNumber,
RECORDOID,
-1,
0);
var = makeWholeRowVar(rt_fetch(rc->rti, range_table),
rc->rti,
0);
snprintf(resname, sizeof(resname), "wholerow%u", rc->rti);
tle = makeTargetEntry((Expr *) var,
list_length(tlist) + 1,