| From: | Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Subject: | Improve error message for multiple assignment via view with FOR PORTION OF |
| Date: | 2026-09-04 21:40:07 |
| Message-ID: | CA+renyVicBxNnL5QKOug_HLif-xdHk23X=xiBHbqd6qnCKL4BQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Hackers,
Here is a fix for finding D14 from [0].
Suppose a view exposes an application-time column twice, like this:
CREATE VIEW v AS SELECT id, valid_at AS a, valid_at AS b, name FROM t;
Then if you say `UPDATE v FOR PORTION OF a ... SET b = ...`, you hit a
multiple-assignment error, but it complains about "valid_at", when you
are trying to use columns named "a" and "b". Also it is a generic
multiple-assignment error, whereas with a regular table we can be more
specific and blame the FOR PORTION OF. This commit adds a check in the
rewriter so that the error message for views matches the message for
tables. It also has an errdetail pointing out that "a" and "b" are
really the same column.
Note that I'm only fixing FOR PORTION OF. Other multiple-assignment
errors still refer to the base table's column, not the view columns.
Maybe that even suggests this is not a bug in the first place. But I
think it is nice to call out FOR PORTION OF (as we do for tables) when
we can.
Yours,
--
Paul ~{:-)
pj(at)illuminatedcomputing(dot)com
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Improve-error-message-for-multiple-assignment-via.patch | text/x-patch | 6.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-09-04 21:48:59 | Re: Introducing find_all_inheritors_ordered() |
| Previous Message | Bharath Rupireddy | 2026-09-04 21:15:00 | Re: [PATCH] Release replication slot on error in SQL-callable slot functions |