pgsql: Correctly check updatability of columns targeted by INSERT...DEF

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Correctly check updatability of columns targeted by INSERT...DEF
Date: 2024-07-20 17:40:42
Message-ID: E1sVE4Y-000Qp3-Dn@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/041a00c4803b982d8433d6e3161ca61e73050658

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

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2024-07-20 20:55:39 pgsql: meson: Add support for detecting gss without pkg-config
Previous Message Noah Misch 2024-07-20 11:24:19 pgsql: Refactor PinBufferForBlock() to remove checks about persistence.