From 194b78cd9a24e4371403eadb7abe943be68b17b2 Mon Sep 17 00:00:00 2001 From: Ilya Eremin Date: Tue, 19 Oct 2021 15:34:28 +0300 Subject: [PATCH] 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 This commit also fixes #5173 and #3886. The situation when the record is not found in RDB$INDICES was not handled correctly in create_index DFW. --- src/jrd/dfw.epp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/jrd/dfw.epp b/src/jrd/dfw.epp index 0fab82ce414..be0361a8af0 100644 --- a/src/jrd/dfw.epp +++ b/src/jrd/dfw.epp @@ -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