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@lists.postgresql.org
Subject: pgsql: Correctly check updatability of columns targeted by INSERT...DEF
Date: Sat, 20 Jul 2024 17:40:42 +0000
Message-ID: <E1sVE4Y-000QpI-Gf@gemulon.postgresql.org> (raw)

Correctly check updatability of columns targeted by INSERT...DEFAULT.

If a view has some updatable and some non-updatable columns, we failed
to verify updatability of any columns for which an INSERT or UPDATE
on the view explicitly specifies a DEFAULT item (unless the view has
a declared default for that column, which is rare anyway, and one
would almost certainly not write one for a non-updatable column).
This would lead to an unexpected "attribute number N not found in
view targetlist" error rather than the intended error.

Per bug #18546 from Alexander Lakhin.  This bug is old, so back-patch
to all supported branches.

Discussion: https://postgr.es/m/18546-84a292e759a9361d@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/feca6c688cd99c68ce10caf21f8566b2483ca3f2

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c          | 29 ++++++++++++++++++---------
src/test/regress/expected/updatable_views.out |  3 +++
src/test/regress/sql/updatable_views.sql      |  1 +
3 files changed, 23 insertions(+), 10 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1sVE4Y-000QpI-Gf@gemulon.postgresql.org>
Permalink:  ../E1sVE4Y-000QpI-Gf@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sVE4Y-000QpI-Gf@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Correctly check updatability of columns targeted by INSERT...DEF
  In-Reply-To: <E1sVE4Y-000QpI-Gf@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