Re: Add notification on BEGIN ATOMIC SQL functions using temp relations - Mailing list pgsql-hackers

From Jim Jones
Subject Re: Add notification on BEGIN ATOMIC SQL functions using temp relations
Date
Msg-id 235e008c-2b86-4227-997c-1994ba6ea0cf@uni-muenster.de
Whole thread Raw
In response to Re: Add notification on BEGIN ATOMIC SQL functions using temp relations  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers

On 9/21/25 19:34, Tom Lane wrote:
> Jim Jones <jim.jones@uni-muenster.de> writes:
>> That's indeed a much larger problem. Calling it from a session silently
>> delivers a "wrong" result --- I was expecting an error.
> 
> Yeah, me too.  See
> 
> https://www.postgresql.org/message-id/2736425.1758475979%40sss.pgh.pa.us
> 

The attached PoC now raises an ERROR instead of a WARNING.

A boolean is now computed in fmgr_sql_validator(), set to true if the
function has a prosqlbody (BEGIN ATOMIC) and is defined in a
non-temporary schema. This flag is then used to call
check_sql_fn_statements().

In check_sql_fn_statements(): if the new flag is true, it scans the
function body and raises an error if any temporary relations are found;
if it's false, it skips that check.

In returning.sql there was a query that creates a BEGIN ATOMIC function
using on a temporary table. I changed the table to permanent.

Best regards, Jim
Attachment

pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: ABI Compliance Checker GSoC Project
Next
From: Michael Paquier
Date:
Subject: Re: GNU/Hurd portability patches