ISN extension - wrong volatility level for isn_weak() function
От | Viktor Holmberg |
---|---|
Тема | ISN extension - wrong volatility level for isn_weak() function |
Дата | |
Msg-id | 790bc1f9-74dc-4b50-94d2-8147315b1556@Spark обсуждение исходный текст |
Ответы |
Re: ISN extension - wrong volatility level for isn_weak() function
|
Список | 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?
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
В списке pgsql-bugs по дате отправления: