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

Fix whole-row Var evaluation to cope with resjunk columns (again).

When a whole-row Var is reading the result of a subquery, we need it to
ignore any "resjunk" columns that the subquery might have evaluated for
GROUP BY or ORDER BY purposes.  We've hacked this area before, in commit
68e40998d0, but that fix only covered
whole-row Vars of named composite types, not those of RECORD type; and it
was mighty klugy anyway, since it just assumed without checking that any
extra columns in the result must be resjunk.  A proper fix requires getting
hold of the subquery's targetlist so we can actually see which columns are
resjunk (whereupon we can use a JunkFilter to get rid of them).  So bite
the bullet and add some infrastructure to make that possible.

Per report from Andrew Dunstan and additional testing by Merlin Moncure.
Back-patch to all supported branches.  In 8.3, also back-patch commit
292176a118, which for some reason I had
not done at the time, but it's a prerequisite for this change.
This commit is contained in:
Tom Lane
2012-07-20 13:09:00 -04:00
parent 3a0e4d36eb
commit 8e617e29aa
6 changed files with 335 additions and 181 deletions

View File

@ -560,6 +560,17 @@ typedef struct GenericExprState
ExprState *arg; /* state of my child node */
} GenericExprState;
/* ----------------
* WholeRowVarExprState node
* ----------------
*/
typedef struct WholeRowVarExprState
{
ExprState xprstate;
struct PlanState *parent; /* parent PlanState, or NULL if none */
JunkFilter *wrv_junkFilter; /* JunkFilter to remove resjunk cols */
} WholeRowVarExprState;
/* ----------------
* AggrefExprState node
* ----------------