FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.26k stars 217 forks source link

Alter function DETERMINISTIC #7427

Closed livius2 closed 1 year ago

livius2 commented 1 year ago

Please add extension to current syntax of Alter Function to be able to change DETERMINISTIC only without specification of whole function body as e.g.:

ALTER FUNCTION funcname {SET | DROP} DETERMINISTIC

pavel-zotov commented 1 year ago

REconnect required to see changed behaviour after 'ALTER FUNCTION' statement. Is it expected ?

Consider script:

set list on;
set echo on;
shell del g:\temp\tmp4test.fdb 2>nul;
create database 'localhost:g:\temp\tmp4test.fdb' user sysdba password 'masterkey';

set list on;
create sequence g;
commit;
set term ^;
create function fn_test returns int deterministic
as
begin
    return gen_id(g,1);
end
^
commit
^

create procedure sp_test returns(curr_gen int) as
    declare n int = 10;
    declare i int;
begin
    while (n > 0) do
    begin
        i = fn_test();
        n = n - 1;
    end
    curr_gen = gen_id(g,0);
    suspend;
end
^
show sequ g
^
select p.curr_gen as gen_for_deterministic1 from sp_test p
^
commit
^
show sequ g
^
alter function fn_test not deterministic
^
alter sequence g restart with 1
^
commit
^
CONNECT 'localhost:g:\temp\tmp4test.fdb' user sysdba password 'masterkey' ------- [ !!! ]
^
select p.curr_gen as gen_for_non_deterministic from sp_test p
^
show sequ g
^

Last line of output will be:

Generator G, current value: 10, initial value: 1, increment: 1

Now make 'CONNECT' statement (which is marked as " [ !!! ] ") commented out and repeat.

Similar line will be:

Generator G, current value: 1, initial value: 1, increment: 1