From: Viktor Holmberg <v@viktorh.net>
To: pgsql-bugs@lists.postgresql.org
Subject: ISN extension - wrong volatility level for isn_weak() function
Date: Fri, 14 Mar 2025 11:49:06 +0000
Message-ID: <790bc1f9-74dc-4b50-94d2-8147315b1556@Spark> (raw)
In-Reply-To: <ae6ed432-4491-4030-be20-3ea69d03a098@Spark>
References: <ae6ed432-4491-4030-be20-3ea69d03a098@Spark>
Hello. Apologies if this is not the right place to bug report extensions, but I couldn’t find a better place. An at the very least I’d like to save someone a day of debugging this issue.
The isn_weak function in the isn extension reports the wrong value if you look at it inside a transaction:
BEGIN;
-- Prepare a statement for isn_weak():
PREPARE s_1 AS
SELECT isn_weak() AS prepared_check;
-- First check - locks in the isn_weak value
EXECUTE s_1; -- => FALSE
-- Set isn_weak(true):
SELECT isn_weak(true) AS setting_true;
-- Check using normal query:
SELECT isn_weak() AS direct_check; -- => TRUE
EXECUTE s_1; -- => FALSE (!!!!)
This is because by default, that function is marked as immutable:
d6kpcv43m9du6> \df+ isn_weak
List of functions
─[ RECORD 1 ]───────┬──────────────────
Schema │ public
Name │ isn_weak
Result data type │ boolean
Argument data types │
Type │ func
Volatility │ immutable <————— bad
Parallel │ restricted
Owner │ postgres
Security │ invoker
Access privileges │
Language │ c
Internal name │ weak_input_status
I can manually fix this by changing it to STABLE:
ALTER FUNCTION isn_weak() STABLE;
Am I missing something or isn’t this quite weird? Would it at least be possible to change the documentation to explain this?
/Viktor Holmberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: v@viktorh.net, pgsql-bugs@lists.postgresql.org
Subject: Re: ISN extension - wrong volatility level for isn_weak() function
In-Reply-To: <790bc1f9-74dc-4b50-94d2-8147315b1556@Spark>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox