Skip to content

Commit

Permalink
Support auto_increment flag on indexes other than primary or unique, …
Browse files Browse the repository at this point in the history
…on copy table dialog. If that still fails, give the user a hint to select the right index. See https://www.heidisql.com/forum.php?t=23383
  • Loading branch information
ansgarbecker committed Feb 28, 2017
1 parent eeda322 commit d4b294f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion out/locale/en/LC_MESSAGES/default.po
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2017-02-23 18:14+0100\n"
"PO-Revision-Date: 2017-02-28 20:21+0100\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/"
"language/en/)\n"
Expand Down Expand Up @@ -520,6 +520,10 @@ msgstr "WHERE clause for data copying:"
msgid "Recent filters"
msgstr "Recent filters"

#. Copy table dialog
msgid "Please select the required index for the %s flag."
msgstr "Please select the required index for the %s flag."

#. CreateDatabaseForm..Caption
#: createdatabase.dfm:5 createdatabase.pas:92
msgid "Create database ..."
Expand Down
10 changes: 7 additions & 3 deletions source/copytable.pas
Expand Up @@ -358,7 +358,7 @@ procedure TCopyTableForm.editNewTablenameChange(Sender: TObject);

procedure TCopyTableForm.btnOKClick(Sender: TObject);
var
CreateCode, InsertCode, TargetTable, DataCols: String;
CreateCode, InsertCode, TargetTable, DataCols, Msg: String;
TableExistence: String;
ParentNode, Node: PVirtualNode;
DoData, AutoIncGetsKey, AutoIncRemoved, TableHasAutoInc: Boolean;
Expand Down Expand Up @@ -425,7 +425,8 @@ procedure TCopyTableForm.btnOKClick(Sender: TObject);
AutoIncRemoved := False;
if Column.DefaultType = cdtAutoInc then begin
for Key in SelectedKeys do begin
if ((Key.IndexType = PKEY) or (Key.IndexType = UKEY)) and (Key.Columns.IndexOf(Column.Name) > -1) then begin
// Don't check index type, MySQL allows auto-increment columns on nearly all indexes
if Key.Columns.IndexOf(Column.Name) > -1 then begin
AutoIncGetsKey := True;
Break;
end;
Expand Down Expand Up @@ -494,7 +495,10 @@ procedure TCopyTableForm.btnOKClick(Sender: TObject);
except
on E:EDatabaseError do begin
Screen.Cursor := crDefault;
ErrorDialog(E.Message);
Msg := E.Message;
if FConnection.LastErrorCode = 1075 then
Msg := Msg + CRLF + CRLF + f_('Please select the required index for the %s flag.', ['auto_increment']);
ErrorDialog(Msg);
ModalResult := mrNone;
end;
end;
Expand Down

0 comments on commit d4b294f

Please sign in to comment.