diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-11-27 22:27:39 -0500 | 
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-11-27 22:27:39 -0500 | 
| commit | b09fc7c39dd69c2eda17c7a3f532cf38ea22a9e9 (patch) | |
| tree | e7d0a32e07334871a2ef962a34e39beaee5f6fd0 /src/backend/optimizer/prep/preptlist.c | |
| parent | 87b0dcf490ffe2930940488b89ff94c62dd7153b (diff) | |
Ensure that whole-row junk Vars are always of composite type.
The EvalPlanQual machinery assumes that whole-row Vars generated for the
outputs of non-table RTEs will be of composite types.  However, for the
case where the RTE is a function call returning a scalar type, we were
doing the wrong thing, as a result of sharing code with a parser case
where the function's scalar output is wanted.  (Or at least, that's what
that case has done historically; it does seem a bit inconsistent.)
To fix, extend makeWholeRowVar's API so that it can support both use-cases.
This fixes Belinda Cussen's report of crashes during concurrent execution
of UPDATEs involving joins to the result of UNNEST() --- in READ COMMITTED
mode, we'd run the EvalPlanQual machinery after a conflicting row update
commits, and it was expecting to get a HeapTuple not a scalar datum from
the "wholerowN" variable referencing the function RTE.
Back-patch to 9.0 where the current EvalPlanQual implementation appeared.
In 9.1 and up, this patch also fixes failure to attach the correct
collation to the Var generated for a scalar-result case.  An example:
regression=# select upper(x.*) from textcat('ab', 'cd') x;
ERROR:  could not determine which collation to use for upper() function
Diffstat (limited to 'src/backend/optimizer/prep/preptlist.c')
| -rw-r--r-- | src/backend/optimizer/prep/preptlist.c | 3 | 
1 files changed, 2 insertions, 1 deletions
| diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index 425d80c6244..ebe581cbe08 100644 --- a/src/backend/optimizer/prep/preptlist.c +++ b/src/backend/optimizer/prep/preptlist.c @@ -160,7 +160,8 @@ preprocess_targetlist(PlannerInfo *root, List *tlist)  			/* Not a table, so we need the whole row as a junk var */  			var = makeWholeRowVar(rt_fetch(rc->rti, range_table),  								  rc->rti, -								  0); +								  0, +								  false);  			snprintf(resname, sizeof(resname), "wholerow%u", rc->rowmarkId);  			tle = makeTargetEntry((Expr *) var,  								  list_length(tlist) + 1, | 
