pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Make new expression eval code reject references to dropped colum
Date: Tue, 28 Mar 2017 22:05:25 +0000
Message-ID: <E1cszEz-0000iS-C5@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1cszEz-0000iS-C5@gemulon.postgresql.org>
Permalink:  ../E1cszEz-0000iS-C5@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1cszEz-0000iS-C5@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Make new expression eval code reject references to dropped colum
  In-Reply-To: <E1cszEz-0000iS-C5@gemulon.postgresql.org>
  References: <E1cszEz-0000iS-C5@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox