Re: FOR PORTION OF should reject GENERATED columns

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: FOR PORTION OF should reject GENERATED columns
Date: 2026-07-02 14:27:40
Message-ID: CA+renyWTtruHZOz4Ef09k2KidGR62cij8_e5QL5mYsX9-GmdEQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 2, 2026 at 12:02 AM Peter Eisentraut <peter(at)eisentraut(dot)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(at)illuminatedcomputing(dot)com

In response to

Browse pgsql-hackers by date

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