Re: FOR PORTION OF should reject GENERATED columns

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: FOR PORTION OF should reject GENERATED columns
Date: 2026-07-06 07:42:51
Message-ID: b3124709-9641-4341-b4ba-e29a2cbfc5cf@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 02.07.26 16:27, Paul A Jungwirth wrote:
> 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.

Ok, committed.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2026-07-06 07:44:27 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Richard Guo 2026-07-06 07:32:37 Re: Fix HAVING-to-WHERE pushdown with mismatched operator families