Re: FOR PORTION OF should reject GENERATED columns - Mailing list pgsql-hackers

From Paul A Jungwirth
Subject Re: FOR PORTION OF should reject GENERATED columns
Date
Msg-id CA+renyWTtruHZOz4Ef09k2KidGR62cij8_e5QL5mYsX9-GmdEQ@mail.gmail.com
Whole thread
Responses Re: FOR PORTION OF should reject GENERATED columns
List pgsql-hackers
On Thu, Jul 2, 2026 at 12:02 AM Peter Eisentraut <peter@eisentraut.org> wrote:
>
> It seems like this still doesn't fully work in some situations:
>
> -- as before
> CREATE TABLE t (a int, b int4range GENERATED ALWAYS AS (int4range(a, a +
> 1)) STORED);
> CREATE VIEW v AS SELECT * FROM t;
>
> -- now with an INSTEAD OF trigger
> CREATE FUNCTION tfunc() RETURNS trigger LANGUAGE plpgsql AS $$
> BEGIN RETURN OLD; END;
> $$;
>
> CREATE TRIGGER tg1
>    INSTEAD OF DELETE ON v
>    FOR EACH ROW EXECUTE FUNCTION tfunc();
>
> -- This should fail but doesn't.
> DELETE FROM v FOR PORTION OF b FROM 1 TO 2;

In this case the statement with FOR PORTION OF is never executed
(because we do the trigger instead), so I think not failing is good.
It lets people provide an alternative way of doing something that
Postgres can't normally provide (like updating views). But if we
disable FOR PORTION OF with INSTEAD OF triggers (per the other
thread), this goes away, right? So whichever choice we make there
resolves this case.

Yours,

--
Paul              ~{:-)
pj@illuminatedcomputing.com



pgsql-hackers by date:

Previous
From: Henson Choi
Date:
Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Next
From: Paul A Jungwirth
Date:
Subject: Re: [PATCH] Fix null pointer dereference in PG19