pgsql: Ensure that whole-row junk Vars are always of composite type.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Ensure that whole-row junk Vars are always of composite type.
Дата
Msg-id E1RUrsy-0000Xp-DT@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/0702c86a13e6c644c32cf773af0a3a76e425ec50

Modified Files
--------------
src/backend/nodes/makefuncs.c          |   45 ++++++++++++++++---------------
src/backend/optimizer/prep/preptlist.c |    3 +-
src/backend/parser/parse_expr.c        |   11 ++++++-
src/backend/rewrite/rewriteHandler.c   |    3 +-
src/include/nodes/makefuncs.h          |    3 +-
5 files changed, 38 insertions(+), 27 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: pgsql: Make pg_dumpall build with the right object files under MSVC.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Ensure that whole-row junk Vars are always of composite type.