Re: Add notification on BEGIN ATOMIC SQL functions using temp relations

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add notification on BEGIN ATOMIC SQL functions using temp relations
Date: 2025-11-22 23:09:03
Message-ID: 3372eebc-24d3-4786-b313-b829b3002b30@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 22/11/2025 19:37, Tom Lane wrote:
> After sleeping on it, I'm inclined to word the notice like
>
> NOTICE: function "f" will be effectively temporary
> DETAIL: It depends on temporary <object descriptor>.

I changed the error level to NOTICE:

postgres=# CREATE TEMPORARY TABLE temp_table AS SELECT 1 AS val;
SELECT 1
postgres=# CREATE FUNCTION temp_func() RETURNS int LANGUAGE sql
BEGIN ATOMIC;
SELECT val FROM temp_table;
END;
NOTICE: function "temp_func" will be effectively temporary
DETAIL: It depends on temporary table temp_table.
CREATE FUNCTION

I reverted the changes in the other test cases, with the exception of
this change in returning.sql (although unrelated to this patch):

diff --git a/src/test/regress/sql/returning.sql
b/src/test/regress/sql/returning.sql
index cc99cb53f6..f1c85a9731 100644
--- a/src/test/regress/sql/returning.sql
+++ b/src/test/regress/sql/returning.sql
@@ -2,6 +2,11 @@
-- Test INSERT/UPDATE/DELETE RETURNING
--

+-- This script is full of poorly-chosen object names.
+-- Put them in a separate schema to avoid collisions with concurrent
scripts.
+CREATE SCHEMA returning_test;
+SET search_path = returning_test, public;
+
-- Simple cases

CREATE TEMP TABLE foo (f1 serial, f2 text, f3 int default 42);
@@ -407,4 +412,7 @@ BEGIN ATOMIC
END;

\sf foo_update
-DROP FUNCTION foo_update;
+
+-- Clean up
+RESET search_path;
+DROP SCHEMA returning_test CASCADE;
--

I also significantly reduced the tests I previously added to
create_function_sql.sql, leaving only tests for temporary views,
sequences, temporary functions (in pg_temp schema), and domains.

v8 attached.

Thanks!

Best, Jim

Attachment Content-Type Size
v8-0002-Disallow-dependencies-from-non-temporary-function.patch text/x-patch 21.9 KB
v8-0001-Refactor-dependency-recording-to-enable-dependenc.patch text/x-patch 4.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-11-22 23:17:20 Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY
Previous Message Sami Imseih 2025-11-22 22:51:42 Re: POC: Parallel processing of indexes in autovacuum