From: | Viktor Holmberg <v(at)viktorh(dot)net> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | ISN extension - wrong volatility level for isn_weak() function |
Date: | 2025-03-14 11:49:06 |
Message-ID: | 790bc1f9-74dc-4b50-94d2-8147315b1556@Spark |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2025-03-14 13:29:55 | Re: ISN extension - wrong volatility level for isn_weak() function |
Previous Message | PG Bug reporting form | 2025-03-14 09:16:06 | BUG #18850: REDUNDANT_COMPARISON.ALWAYS_FALSE Redundant comparison |