Re: proposal: schema variables - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal: schema variables
Date
Msg-id CAFj8pRBozszOrD+5c21TucP-VLG_ra+erXh3OgBy0c0dYsR6KQ@mail.gmail.com
Whole thread
In response to Re: proposal: schema variables  (Haritabh Gupta <haritabh1992@gmail.com>)
Responses Re: proposal: schema variables
List pgsql-hackers
Hi

st 4. 3. 2026 v 11:03 odesílatel Haritabh Gupta <haritabh1992@gmail.com> napsal:
Hi,

While reviewing I came across this behaviour and wanted to
check whether it's intended:

    CREATE TEMP VARIABLE y AS int;
    LET y = 42;

    BEGIN;
    SAVEPOINT s1;
    LET y = generate_series(1,2);  -- ERROR: too many rows
    ROLLBACK TO s1;
    SELECT VARIABLE(y);            -- returns 1, not 42

It looks like svariableReceiveSlot writes the first row to the
variable (pfree'ing the old datum) before the second row triggers the
error, so the old value is lost even though LET failed.

I understand variable values are intentionally non-transactional, but
is it expected that a failed LET has this side effect?

please, check attached patch

Regards

Pavel
 

---
Haritabh Gupta
Supabase
Attachment

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Improve checks for GUC recovery_target_xid
Next
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: [PATCH] Support automatic sequence replication