Re: Unexpected results from CALL and AUTOCOMMIT=off

2024-06-03 Thread Tom Lane
Victor Yegorov writes: > пн, 3 июн. 2024 г. в 20:40, Pierre Forstmann : >> If you remove stable from function declaration, it works as expected: > ... therefore I assume STABLE should work in this case. Well, it seems not > to. I agree that this looks like a bug, since your example shows that th

Re: Unexpected results from CALL and AUTOCOMMIT=off

2024-06-03 Thread Victor Yegorov
пн, 3 июн. 2024 г. в 20:40, Pierre Forstmann : > You declared function f_get_x as stable which means: > > … > > If you remove stable from function declaration, it works as expected: > Well, I checked https://www.postgresql.org/docs/current/xfunc-volatility.html There's a paragraph describing why

Re: Unexpected results from CALL and AUTOCOMMIT=off

2024-06-03 Thread Pierre Forstmann
You declared function f_get_x as stable which means: https://www.postgresql.org/docs/15/sql-createfunction.html STABLE indicates that the function cannot modify the database, and that within a single table scan it will consistently return the same result for the same argument values, but that its

Unexpected results from CALL and AUTOCOMMIT=off

2024-06-03 Thread Victor Yegorov
Greetings. I am observing the following results on PostgreSQL 15.7 First, setup: create table t_test(x bigint); insert into t_test values(0); create or replace function f_get_x() returns bigint language plpgsql stable as $function$ declare l_result bigint; begin select x into l_result fr