Skip to content

Domain CHECK-expression can be ignored when we DROP objects that are involved in it #6869

@pavel-zotov

Description

@pavel-zotov

Script:

set bail on;
set list on;
shell del c:\temp\tmp4test.fdb 2>nul;
create database 'localhost:c:\temp\tmp4test.fdb';

create domain dm_int as int;
create table test(i dm_int);

set term ^;
create function fn_test(a_id dm_int) returns dm_int as
begin
    return ( select min(i) from test );
end
^
set term ;^


set echo on;

alter domain dm_int add constraint check ( value = (select fn_test(max(i)) from test) );
commit;

connect 'localhost:c:\temp\tmp4test.fdb';

set term ^;
execute block as
begin
    execute statement 'drop table test'; -- PASSED, despite having two dependent objects (function and domain expr.)
    execute statement 'drop function fn_test'; -- PASSED, despite having dependent object (domain expr.)
end
^
set term ;^
commit;

-- leads to invalid metadata:

SET SQL DIALECT 3;

/* CREATE DATABASE 'localhost:c:\temp\tmp4test.fdb' PAGE_SIZE 8192 DEFAULT CHARACTER SET NONE; */


/* Domain definitions */
CREATE DOMAIN DM_INT AS INTEGER;
COMMIT WORK;

/* Domain constraints */
ALTER DOMAIN DM_INT ADD CONSTRAINT
         check ( value = (select fn_test(max(i)) from test) );

Obviously this metadata script will not be compiled because there neither table 'TEST' nor function 'FN_TEST' exist.
Objects ('test' and 'fn_test') can be dropped only via ES; attept to do this in DSQL will fail.

Checked on: WI-V3.0.8.33476; WI-V4.0.1.2520; WI-T5.0.0.84.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions