bug: UPDATE FOR PORTION OF interact with updatable view

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: bug: UPDATE FOR PORTION OF interact with updatable view
Date: 2026-04-12 15:11:19
Message-ID: CACJufxFRqg8=gbZ-Q6ZS_UQ+YdwfZpk+9rf7jgWrk8m4RMUm=A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

CREATE TABLE base_tbl (a int, b int, c int);
INSERT INTO base_tbl values(1,2);
CREATE VIEW rw_view15 AS SELECT a, ('[' || abs(b) ||
',20]')::int4range as b FROM base_tbl;

UPDATE rw_view15 for portion of b from 1 to 10 set a = 2;
DELETE FROM rw_view15 for portion of b from 1 to 10;

The UPDATE will result
ERROR: attribute number 2 not found in view targetlist

\errverbose
ERROR: XX000: attribute number 2 not found in view targetlist
LOCATION: rewriteTargetView, rewriteHandler.c:3779

The DELETE will crash the server.

Both should result in an error in rewriteTargetView.
for UPDATE, the error message:
ERROR: cannot update column "b" of view "rw_view15"
DETAIL: View columns that are not columns of their base relation are
not updatable.

for DELETE, the error message:
ERROR: DELETE ... FOR PORTION OF is not supported for column "b" on
view "rw_view15"
DETAIL: View columns that are not columns of their base relation are
not updatable.

Later, I will add this to
https://wiki.postgresql.org/wiki/PostgreSQL_19_Open_Items

--
jian
https://www.enterprisedb.com/

Attachment Content-Type Size
v1-0001-UPDATE-FOR-PORTION-OF-interact-with-updatable-view.patch text/x-patch 5.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Lukas Fittl 2026-04-12 16:38:15 Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?
Previous Message Alvaro Herrera 2026-04-12 15:06:20 Re: Extract numeric filed in JSONB more effectively