mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Copy table dialog:
* Clear db cache only once in btnOKclick * Clear db cache of target db when done, instead of refreshing active db * Remove unused variables * Remove empty comment clause from CREATE TABLE code
This commit is contained in:
@ -359,8 +359,6 @@ procedure TCopyTableForm.btnOKClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
CreateCode, InsertCode, TargetTable, DataCols: String;
|
CreateCode, InsertCode, TargetTable, DataCols: String;
|
||||||
TableExists: Boolean;
|
TableExists: Boolean;
|
||||||
Objects: TDBObjectList;
|
|
||||||
o: TDBObject;
|
|
||||||
ParentNode, Node: PVirtualNode;
|
ParentNode, Node: PVirtualNode;
|
||||||
DoData, AutoIncGetsPrimaryKey, AutoIncRemoved, TableHasAutoInc: Boolean;
|
DoData, AutoIncGetsPrimaryKey, AutoIncRemoved, TableHasAutoInc: Boolean;
|
||||||
SelectedColumns: TTableColumnList;
|
SelectedColumns: TTableColumnList;
|
||||||
@ -373,10 +371,12 @@ const
|
|||||||
ClausePattern: String = #9 + '%s,' + CRLF;
|
ClausePattern: String = #9 + '%s,' + CRLF;
|
||||||
begin
|
begin
|
||||||
// Compose and run CREATE query
|
// Compose and run CREATE query
|
||||||
|
|
||||||
|
// Refresh db cache for getting fresh results in QuotedDbAndTableName + FindObject
|
||||||
|
FDBObj.Connection.ClearDbObjects(comboDatabase.Text);
|
||||||
TargetTable := FDBObj.Connection.QuotedDbAndTableName(comboDatabase.Text, editNewTablename.Text);
|
TargetTable := FDBObj.Connection.QuotedDbAndTableName(comboDatabase.Text, editNewTablename.Text);
|
||||||
|
|
||||||
// Refresh db cache and watch out if target table exists
|
// Watch out if target table exists
|
||||||
FDBObj.Connection.ClearDbObjects(comboDatabase.Text);
|
|
||||||
TableExists := FDBObj.Connection.FindObject(comboDatabase.Text, editNewTablename.Text) <> nil;
|
TableExists := FDBObj.Connection.FindObject(comboDatabase.Text, editNewTablename.Text) <> nil;
|
||||||
if TableExists then begin
|
if TableExists then begin
|
||||||
if MessageDialog(_('Target table exists. Drop it and overwrite?'), mtConfirmation, [mbYes, mbCancel]) = mrCancel then begin
|
if MessageDialog(_('Target table exists. Drop it and overwrite?'), mtConfirmation, [mbYes, mbCancel]) = mrCancel then begin
|
||||||
@ -464,7 +464,8 @@ begin
|
|||||||
CreateCode := CreateCode + ' ROW_FORMAT=' + FDBObj.RowFormat;
|
CreateCode := CreateCode + ' ROW_FORMAT=' + FDBObj.RowFormat;
|
||||||
if (FDBObj.AutoInc > -1) and TableHasAutoInc then
|
if (FDBObj.AutoInc > -1) and TableHasAutoInc then
|
||||||
CreateCode := CreateCode + ' AUTO_INCREMENT=' + IntToStr(FDBObj.AutoInc);
|
CreateCode := CreateCode + ' AUTO_INCREMENT=' + IntToStr(FDBObj.AutoInc);
|
||||||
CreateCode := CreateCode + ' COMMENT=' + esc(FDBObj.Comment);
|
if FDBObj.Comment <> '' then
|
||||||
|
CreateCode := CreateCode + ' COMMENT=' + esc(FDBObj.Comment);
|
||||||
|
|
||||||
// Add INSERT .. SELECT .. FROM OrgTable clause
|
// Add INSERT .. SELECT .. FROM OrgTable clause
|
||||||
InsertCode := '';
|
InsertCode := '';
|
||||||
@ -482,7 +483,7 @@ begin
|
|||||||
MainForm.ActiveConnection.Query(CreateCode);
|
MainForm.ActiveConnection.Query(CreateCode);
|
||||||
if InsertCode <> '' then
|
if InsertCode <> '' then
|
||||||
MainForm.ActiveConnection.Query(InsertCode);
|
MainForm.ActiveConnection.Query(InsertCode);
|
||||||
MainForm.actRefresh.Execute;
|
FDBObj.Connection.ClearDbObjects(comboDatabase.Text);
|
||||||
except
|
except
|
||||||
on E:EDatabaseError do begin
|
on E:EDatabaseError do begin
|
||||||
Screen.Cursor := crDefault;
|
Screen.Cursor := crDefault;
|
||||||
|
Reference in New Issue
Block a user