Correctly check updatability of columns targeted by INSERT...DEFAULT.
authorTom Lane <[email protected]>
Sat, 20 Jul 2024 17:40:15 +0000 (13:40 -0400)
committerTom Lane <[email protected]>
Sat, 20 Jul 2024 17:40:15 +0000 (13:40 -0400)
commitfeca6c688cd99c68ce10caf21f8566b2483ca3f2
tree8369ea122d5c18dfe950beba01956faf6f646e03
parent4f962815871f6ac4eb3b516832b5c95a2f628f1b
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
src/backend/rewrite/rewriteHandler.c
src/test/regress/expected/updatable_views.out
src/test/regress/sql/updatable_views.sql