| From: | Aleksander Alekseev <aleksander(at)tigerdata(dot)com> |
|---|---|
| To: | PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
| Cc: | Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(at)eisentraut(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com> |
| Subject: | Re: [PATCH] Fix null pointer dereference in PG19 |
| Date: | 2026-06-25 10:32:43 |
| Message-ID: | CAJ7c6TN7dekEHU8Vu4jV5+Zq7h2cVZQgwkYFCrU0jrjT26-ANw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Paul,
> > > I definitely don't like checking volatility at parse time, though.
> >
> > So.... the last comment from Tom was that he is not happy :) but I'm
> > not sure about the actionable items. Tom, could you please elaborate a
> > bit?
>
> Here is the thread for moving checks out of analysis:
> https://www.postgresql.org/message-id/CA%2BrenyUte0_UJsJiDJQi82oaBsMJn%3Dcct0Wn%3DvOqXtuDn%3DYYJA%40mail.gmail.com
Thanks for the clarification! So if my understanding is correct this
is out of scope of the fix under question.
> I don't think forbidding INSTEAD OF triggers with FOR PORTION OF is
> the right solution. It seems too heavy-handed. But we *should* skip
> trying to insert temporal leftovers. After all if you did something
> *instead of* the update/delete, we can't know what the leftovers
> should be. Or another way of putting it: the trigger function runs
> instead of the original command, but inserting leftovers is part of
> that original command. Skipping temporal leftovers is implemented in
> my v5 patch on this thread from April 22:
> https://www.postgresql.org/message-id/CA%2BrenyUoTRnn0o4Pnfy2AOdtqMH3%2Bn29_AfD4Aih3ifwMX9vyA%40mail.gmail.com
This patch rotted and needed a rebase (attached as .txt). Also it's
incorrect, it only masks the crash:
```
CREATE TABLE t (id int, valid_at daterange, val int);
INSERT INTO t VALUES (1, '[2024-01-01,2025-01-01)', 100);
CREATE VIEW v AS SELECT * FROM t;
CREATE FUNCTION trig_fn() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
RAISE NOTICE 'UPDATE OLD: %, NEW: %', OLD, NEW;
RETURN NEW;
END;
$$;
CREATE TRIGGER trig INSTEAD OF UPDATE ON v FOR EACH ROW EXECUTE
FUNCTION trig_fn();
UPDATE v FOR PORTION OF valid_at FROM '2024-04-01' TO '2024-08-01' SET
val = 999 WHERE id = 1;
server closed the connection unexpectedly
```
v1-0001 passes the tests successfully:
```
=# UPDATE v FOR PORTION OF valid_at FROM '2024-04-01' TO '2024-08-01'
SET val = 999 WHERE id = 1;
ERROR: views with INSTEAD OF triggers do not support FOR PORTION OF
LINE 1: UPDATE v FOR PORTION OF valid_at FROM '2024-04-01' TO '2024-...
```
IMO it's a little bit late in the PG19 cycle for making this work.
This is an implementation of a new feature which is not present at the
moment which to my knowledge we don't do after the feature freeze. Our
goal is to fix the crash and leave the rest for the PG20 cycle.
Clearly the feature needs more discussion and thorough testing.
--
Best regards,
Aleksander Alekseev
| Attachment | Content-Type | Size |
|---|---|---|
| rebased.txt | text/plain | 6.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrei Lepikhov | 2026-06-25 10:33:14 | Re: RFC: Logging plan of the running query |
| Previous Message | Andrey Borodin | 2026-06-25 10:17:31 | Re: Out-of-Cycle release? (was Re: BUG #19490: Streaming standby on 16.14 stops applying WAL on MultiXactOffsetSLRU when primary is 16.8) |