Add notification on BEGIN ATOMIC SQL functions using temp relations

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Add notification on BEGIN ATOMIC SQL functions using temp relations
Date: 2025-09-21 13:52:45
Message-ID: CAKFQuwa_Q47_iEonqR7+P-5BB+YVN5daQ0vo1N2p+9TUXvw0Hw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sunday, September 21, 2025, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:

> Hi Pavel
>
> On 9/21/25 14:33, Pavel Stehule wrote:
> > i understand your motivation, but with this warning temp tables cannot
> > be used in SQL function due log overhead.
>
> My intention was not to warn on every function call. The WARNING is only
> emitted once at CREATE FUNCTION time, similar to how CREATE VIEW warns
> if a view depends on a temporary relation. After creation, the function
> can still be used normally without additional log overhead. Is there a
> side effect I might be overlooking here?
>

I’m surprised that this is how the system works and I agree that either we
should add this notice or remove the one for create view. Even more
because there is no syntax for directly creating a temporary function -
this is basically executing drop…cascade on the temporary relation. Which
then leads me to wonder whether selecting from a temporary view is is
detected here.

One argument for leaving the status quote, which is a decent one, is that
one can prevent the create view from emitting the notice via adding
temporary to the SQL command - there is no such ability for create function.

If added this should be a notice, not a warning, so least min messages can
be used to ignore it reasonably.

I’d rather we take this one step further and add “temp” to “create
function” and make this behave exactly identical to “create [temp] view”
than put in this half-measure where you get a notice without any way to
suppress it specifically.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vik Fearing 2025-09-21 14:43:51 Re: Add notification on BEGIN ATOMIC SQL functions using temp relations
Previous Message Jim Jones 2025-09-21 13:10:22 Re: Add notification on BEGIN ATOMIC SQL functions using temp relations