Skip to content

Compound ALTER TABLE statement with ADD and DROP the same constraint failed if this constraint involves index creation (PK/UNQ/FK) [CORE4878] #5173

@firebird-automations

Description

@firebird-automations

Submitted by: @pavel-zotov

Is related to CORE4947

All following is done with SET AUTODDL ON (default setting).

Test-1:

recreate table t(x int not null);
alter table t add constraint cx check(x>0), drop constraint cx; -- i.e. NO index will be created for this constraint

Result: OK, no errors.

Test-2:

recreate table t(x int not null);
alter table t add constraint t_unq unique(x), drop constraint t_unq;

Result:
2.1) in 2.1.7:
Statement failed, SQLCODE = -607
unsuccessful metadata update
-too few key columns found for index T_UNQ (incorrect column name?)

2.2) in 2.5.5:
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-cannot create index T_UNQ

2.3) in 3.0:
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-ALTER TABLE T failed
-CONSTRAINT T_UNQ does not exist.

Similar results will be for

recreate table t(x int not null);
alter table t add constraint t_pk primary key(x), drop constraint t_pk;

and

recreate table t(x int not null);
alter table t add constraint t_pk primary key(x), add constraint t_fk foreign key(x) references t(x), drop constraint t_fk;

PS. Yes, all these statements can be done separately and w/o any errors. I've made this ticket only to illustrate minor problem that exists when ALTER TABLE consists of several statements and some of them cancels previous which are issued in the same statement.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions