pgsql: Make new expression eval code reject references to droppedcolum

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Make new expression eval code reject references to droppedcolum
Дата
Msg-id E1cszEz-0000iS-C5@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Make new expression eval code reject references to dropped columns.

Formerly, a Var referencing an already-dropped column was allowed and would
always produce a NULL value.  However, that behavior was implemented in
slot_getattr which the new expression code doesn't use; thus there is now a
risk of returning theoretically-deleted data.  We had regression test cases
that purported to exercise this, but they failed to expose any problem,
apparently because plpgsql filters the dropped column and produces an
output tuple that has a NULL there already.

Ideally the DROP or ALTER attempt in these test cases would get rejected
due to dependency checks; but until that happens, let's modify the behavior
so that we fail the query during executor start.  This was already true for
the related case of a column having changed type underneath us, and there's
no obvious reason why we need to be laxer for dropped columns.

In passing, adjust the error messages in CheckVarSlotCompatibility to
include the composite type name.  In the cases shown in the regression
tests this is always just "record", but it should be more useful in
actual stale-plan cases, where the slot tupdesc would be a table's
tupdesc directly.

Discussion: https://postgr.es/m/16803.1490723570@sss.pgh.pa.us

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/2c4debbd0f018aa7322b622c88424a7f68d3081d

Modified Files
--------------
src/backend/executor/execExprInterp.c     | 45 ++++++++++++++---------------
src/test/regress/expected/create_view.out | 47 +++++++++++++++++++++++++------
src/test/regress/expected/rangefuncs.out  | 19 ++++++-------
src/test/regress/sql/create_view.sql      | 25 ++++++++++++++--
src/test/regress/sql/rangefuncs.sql       |  6 ++--
5 files changed, 95 insertions(+), 47 deletions(-)


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: pgsql: Remove direct uses of ItemPointer.{ip_blkid,ip_posid}
Следующее
От: Alvaro Herrera
Дата:
Сообщение: pgsql: Allow DSM segments to be created as pinned