From e3c288f8a7a3dc33219a3d9ec32d3b0ec75f60e8 Mon Sep 17 00:00:00 2001 From: "adri.granger" Date: Thu, 20 Feb 2014 14:36:55 +0000 Subject: [PATCH] Check if all indexes have at least one column when creating or altering table to prevent creation of empty index. Fixes issue #3516. --- out/locale/en/LC_MESSAGES/default.po | 4 ++++ source/table_editor.pas | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/out/locale/en/LC_MESSAGES/default.po b/out/locale/en/LC_MESSAGES/default.po index ea18f6be..a1b0e397 100644 --- a/out/locale/en/LC_MESSAGES/default.po +++ b/out/locale/en/LC_MESSAGES/default.po @@ -5111,6 +5111,10 @@ msgstr "Selected operations cannot be applied to a %s" msgid "Unhandled tree level" msgstr "Unhandled tree level" +#: table_editor.pas:380 +msgid "%s Index \"%s\" does not contain any column. You can add columns using drag''n drop from the columns list." +msgstr "%s Index \"%s\" does not contain any column. You can add columns using drag''n drop from the columns list." + #: table_editor.pas:476 msgid "Composing ALTER statement ..." msgstr "Composing ALTER statement ..." diff --git a/source/table_editor.pas b/source/table_editor.pas index 8f38b722..b8cd5c9b 100644 --- a/source/table_editor.pas +++ b/source/table_editor.pas @@ -373,8 +373,19 @@ var i: Integer; Rename: String; begin + // Check if all indexes have at least one column + // If not, exit early + for i := 0 to FKeys.Count-1 do begin + if FKeys.Items[i].Columns.Count = 0 then begin + ErrorDialog( f_('%s Index "%s" does not contain any column. You can add columns using drag''n drop from the columns list.', [FKeys.Items[i].IndexType, FKeys.Items[i].Name])); + Result := mrAbort; + Exit; + end; + end; + // Create or alter table Result := mrOk; + if DBObject.Name = '' then Batch := ComposeCreateStatement else