Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
firebird-automations opened this issue Jul 16, 2015 · 1 comment

Comments

@firebird-automations
Copy link
Collaborator

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.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Link: This issue is related to CORE4947 [ CORE4947 ]

ilya071294 added a commit to red-soft-ru/firebird that referenced this issue Oct 19, 2021
… raises when attempt to create table with PK and immediatelly drop this PK within the same transaction

This commit also fixes FirebirdSQL#5173 and FirebirdSQL#3886.
The situation when the record is not found in RDB$INDICES was not handled correctly in create_index DFW.
ilya071294 added a commit to red-soft-ru/firebird that referenced this issue Oct 20, 2021
… raises when attempt to create table with PK and immediatelly drop this PK within the same transaction

This commit also fixes FirebirdSQL#5173 and FirebirdSQL#3886.
The situation when the record is not found in RDB$INDICES was not handled correctly in create_index DFW.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment