Skip to content

Commit

Permalink
Fix FirebirdSQL#5082: Exception "too few key columns found for index"…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
ilya071294 committed Oct 19, 2021
1 parent 6c303fa commit 194b78c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/jrd/dfw.epp
Original file line number Diff line number Diff line change
Expand Up @@ -3437,18 +3437,18 @@ static bool create_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
}
END_FOR

if (key_count != idx.idx_count)
if (!relation)
{
ERR_post(Arg::Gds(isc_no_meta_update) <<
Arg::Gds(isc_key_field_err) << Arg::Str(work->dfw_name));
// Msg352: too few key columns found for index %s (incorrect column name?)
// The record was not found in RDB$INDICES.
// Apparently the index was dropped in the same transaction.
return false;
}

if (!relation)
if (key_count != idx.idx_count)
{
ERR_post(Arg::Gds(isc_no_meta_update) <<
Arg::Gds(isc_idx_create_err) << Arg::Str(work->dfw_name));
// Msg308: can't create index %s
Arg::Gds(isc_key_field_err) << Arg::Str(work->dfw_name));
// Msg352: too few key columns found for index %s (incorrect column name?)
}

// Make sure the relation info is all current
Expand Down

0 comments on commit 194b78c

Please # to comment.