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

Exception "too few key columns found for index" raises when attempt to create table with PK and immediatelly drop this PK within the same transaction [CORE4783] #5082

Closed
firebird-automations opened this issue May 7, 2015 · 8 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

Test:

set autoddl off;
commit;
create table test(
f01 varchar(2)
,constraint test_pk1 primary key (f01)
);
alter table test drop constraint test_pk1;

STDERR:

Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-too few key columns found for index TEST_PK1 (incorrect column name?)

PS. Reproduced on: WI-T3.0.0.31827, WI-V2.5.5.26861, WI-V2.1.7.18553, WI-V2.0.7.13318

====== Test Details ======

TODO: return to CORE3056 after this ticket will be resolved, see comments in .fbt or its QA Status section

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

PPS. If change code to this one:

set autoddl off;
commit;
create table test(
f01 varchar(2)
,constraint test_pk1 primary key (f01)
);
drop table test;

-- then STDERR differs on 2.5 and 3.0.

On 2.0 .... 2.5:
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-too few key columns found for index TEST_PK1 (incorrect column name?)

(i.e. the same)

On 3.0:
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-cannot create index TEST_PK1

@firebird-automations
Copy link
Collaborator Author

Commented by: @aafemt

DFW must die.

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

Seems that `DROP TABLE` statement tries... to create index ?!

Try this (file = `script.sql`):

set echo on;
set autoddl off;
commit;
create table test(
f01 varchar(2)
);
create index test_f01 on test(f01);
drop table test;

isql localhost/port:path\empty_database.fdb -i script.sql 1>log 2>&1

Content of `log`:

set autoddl off;
commit;
create table test(
f01 varchar(2)
);
create index test_f01 on test(f01);
drop table test;
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-cannot create index TEST_F01
After line 8 in file script.sql

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

Version: 2.1.7 [ 10651 ]

Version: 3.0 Beta 2 [ 10586 ]

Version: 2.5.5 [ 10670 ]

Component: Engine [ 10000 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Pavel, I already said to you... every non-simple interaction of DDL in the same transaction will result in a bug.

IMO it's time lost to fix them. There is a architectural/conceptual problem in DFW.

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

Priority changes to "Minor" as their is a very reasonable workaround -- commit after each DDL operation.

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

priority: Major [ 3 ] => Minor [ 4 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Open [ 1 ] => Open [ 1 ]

QA Status: No test

Test Details: TODO: return to CORE3056 after this ticket will be resolved, see comments in .fbt or its QA Status section

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.
dyemanov added a commit that referenced this issue Oct 20, 2021
Fix #5082: Exception "too few key columns found for index" raises when attempt to create table with PK and immediatelly drop this PK within the same transaction
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.
dyemanov added a commit that referenced this issue Oct 20, 2021
Fix #5082: Exception "too few key columns found for index" raises when attempt to create table with PK and immediatelly drop this PK within the same transaction
dyemanov added a commit that referenced this issue Oct 23, 2021
Fix #5082: Exception "too few key columns found for index" raises when attempt to create table with PK and immediatelly drop this PK within the same transaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment