Check if all indexes have at least one column when creating or altering table to prevent creation of empty index. Fixes issue #3516.

This commit is contained in:
adri.granger
2014-02-20 14:36:55 +00:00
parent 61e3642851
commit e3c288f8a7
2 changed files with 15 additions and 0 deletions

View File

@@ -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 ..."

View File

@@ -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