firebird icon indicating copy to clipboard operation
firebird copied to clipboard

When dropping a function and a dependent table in the same transaction, error may or may not occurs.

Open hvlad opened this issue 1 year ago • 0 comments

  1. create metadata and disconnect
set autoddl off;
set term ^;

create function f(x int)
  returns int
as
begin
  return x;
end
^
create table t_fn (x int, fx computed by (f(x)))
^
commit
^
set term ;^
exit;
  1. connect and try to drop objects
set autoddl off;
drop function f;
drop table t_fn;
commit;

Error raised:

SQL> set autoddl off;
SQL> drop function f;
SQL> drop table t_fn;
Statement failed, SQLSTATE = 39000
unsuccessful metadata update
-DROP TABLE T_FN failed
-invalid request BLR at offset 2
-function F is not defined
SQL> commit;
Statement failed, SQLSTATE = 38000
unsuccessful metadata update
-cannot delete
-Function F
-there are 1 dependencies
SQL> rollback;
  1. connect, use function and then try to drop objects - no error happens
set autoddl off;
select f(1) from rdb$database;
commit;
drop function f;
drop table t_fn;
commit;

The behaviour should be consistent and not dependent on previous state of metadata cache.

hvlad avatar Feb 27 '24 19:02 hvlad