| 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-02 07:02:35 |
| Message-ID: | 5e259199-0100-4795-b0ed-90443bb090a9@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 29.06.26 08:29, Paul A Jungwirth wrote:
> On Sat, Jun 27, 2026 at 12:05 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>>
>>> The test about BEGIN ATOMIC functions now shows that the analysis-time
>>> check prevents you from defining the function.
>>
>> Hmm, I think doing it in the parser won't actually work if you are
>> writing through a view. For example, with the v4 patch, the following
>> does not error:
>>
>> CREATE TABLE t (a int, b int4range GENERATED ALWAYS AS (int4range(a, a +
>> 1)) STORED);
>> CREATE VIEW v AS SELECT * FROM t;
>> DELETE FROM v FOR PORTION OF b FROM 1 TO 2;
>>
>> So we need to push it later after all.
>>
>> But maybe it would fit in the planner, near where the volatility check
>> is being moved to?
>
> That's a good catch. Here is a version that checks in the planner,
> with your example added to the test cases. This is a little nicer than
> the executor, since rangeVar hasn't been converted to an expression
> yet (for VIRTUAL columns).
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;
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Yilin Zhang | 2026-07-02 07:02:37 | Re:Re: Bypassing cursors in postgres_fdw to enable parallel plans |
| Previous Message | Michael Paquier | 2026-07-02 06:53:50 | Re: Prevent crash when calling pgstat functions with unregistered stats kind |