mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 01:56:36 +08:00
Exports to database + server were missing SET FOREIGN_KEY_CHECKS header + footer. Moving critical Output() procedure from local to private scope, so we can call it in Execute(). Fixes issue #1915.
This commit is contained in:
@ -115,7 +115,9 @@ type
|
|||||||
FLastOutputSelectedIndex: Integer;
|
FLastOutputSelectedIndex: Integer;
|
||||||
FModifiedDbs: TStringList;
|
FModifiedDbs: TStringList;
|
||||||
FHeaderCreated: Boolean;
|
FHeaderCreated: Boolean;
|
||||||
|
ToFile, ToDir, ToClipboard, ToDb, ToServer: Boolean;
|
||||||
procedure SetToolMode(Value: TToolMode);
|
procedure SetToolMode(Value: TToolMode);
|
||||||
|
procedure Output(SQL: String; IsEndOfQuery, ForFile, ForDir, ForDb, ForServer: Boolean);
|
||||||
procedure AddResults(SQL: String);
|
procedure AddResults(SQL: String);
|
||||||
procedure AddNotes(Col1, Col2, Col3, Col4: String);
|
procedure AddNotes(Col1, Col2, Col3, Col4: String);
|
||||||
procedure SetupResultGrid(Results: TMySQLQuery=nil);
|
procedure SetupResultGrid(Results: TMySQLQuery=nil);
|
||||||
@ -499,8 +501,8 @@ begin
|
|||||||
end; // End of db item loop
|
end; // End of db item loop
|
||||||
|
|
||||||
if Assigned(ExportStream) then begin
|
if Assigned(ExportStream) then begin
|
||||||
if (comboExportOutputType.Text = OUTPUT_FILE) or (comboExportOutputType.Text = OUTPUT_CLIPBOARD) then
|
Output(EXPORT_FILE_FOOTER, False, True, False, False, False);
|
||||||
StreamWrite(ExportStream, EXPORT_FILE_FOOTER);
|
Output('/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */', True, False, False, True, True);
|
||||||
if comboExportOutputType.Text = OUTPUT_CLIPBOARD then
|
if comboExportOutputType.Text = OUTPUT_CLIPBOARD then
|
||||||
StreamToClipboard(ExportStream, nil, false);
|
StreamToClipboard(ExportStream, nil, false);
|
||||||
FreeAndNil(ExportStream);
|
FreeAndNil(ExportStream);
|
||||||
@ -910,31 +912,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmTableTools.DoExport(DBObj: TDBObject);
|
// Pass output to file or query, and append semicolon if needed
|
||||||
|
procedure TfrmTableTools.Output(SQL: String; IsEndOfQuery, ForFile, ForDir, ForDb, ForServer: Boolean);
|
||||||
var
|
var
|
||||||
ToFile, ToDir, ToClipboard, ToDb, ToServer, IsLastRowInChunk, NeedsDBStructure: Boolean;
|
|
||||||
Struc, Header, DbDir, FinalDbName, BaseInsert, Row, TargetDbAndObject, BinContent: String;
|
|
||||||
MultiSQL: TStringList;
|
|
||||||
i: Integer;
|
|
||||||
RowCount, MaxRowsInChunk, RowsInChunk, Limit, Offset, ResultCount: Int64;
|
|
||||||
StartTime: Cardinal;
|
|
||||||
StrucResult, Data: TMySQLQuery;
|
|
||||||
rx: TRegExpr;
|
|
||||||
const
|
|
||||||
TempDelim = '//';
|
|
||||||
|
|
||||||
// Short version of Mainform.Mask()
|
|
||||||
function m(s: String): String;
|
|
||||||
begin
|
|
||||||
Result := Mainform.mask(s);
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Pass output to file or query, and append semicolon if needed
|
|
||||||
procedure Output(SQL: String; IsEndOfQuery, ForFile, ForDir, ForDb, ForServer: Boolean);
|
|
||||||
var
|
|
||||||
SA: AnsiString;
|
SA: AnsiString;
|
||||||
ChunkSize: Integer;
|
ChunkSize: Integer;
|
||||||
begin
|
begin
|
||||||
if (ToFile and ForFile) or (ToDir and ForDir) or (ToClipboard and ForFile) then begin
|
if (ToFile and ForFile) or (ToDir and ForDir) or (ToClipboard and ForFile) then begin
|
||||||
if IsEndOfQuery then
|
if IsEndOfQuery then
|
||||||
SQL := SQL + ';'+CRLF;
|
SQL := SQL + ';'+CRLF;
|
||||||
@ -954,6 +937,26 @@ const
|
|||||||
SQL := '';
|
SQL := '';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TfrmTableTools.DoExport(DBObj: TDBObject);
|
||||||
|
var
|
||||||
|
IsLastRowInChunk, NeedsDBStructure: Boolean;
|
||||||
|
Struc, Header, DbDir, FinalDbName, BaseInsert, Row, TargetDbAndObject, BinContent: String;
|
||||||
|
MultiSQL: TStringList;
|
||||||
|
i: Integer;
|
||||||
|
RowCount, MaxRowsInChunk, RowsInChunk, Limit, Offset, ResultCount: Int64;
|
||||||
|
StartTime: Cardinal;
|
||||||
|
StrucResult, Data: TMySQLQuery;
|
||||||
|
rx: TRegExpr;
|
||||||
|
const
|
||||||
|
TempDelim = '//';
|
||||||
|
|
||||||
|
// Short version of Mainform.Mask()
|
||||||
|
function m(s: String): String;
|
||||||
|
begin
|
||||||
|
Result := Mainform.mask(s);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure LogStatistic(RowsDone: Int64);
|
procedure LogStatistic(RowsDone: Int64);
|
||||||
@ -1011,6 +1014,7 @@ begin
|
|||||||
'/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;' + CRLF +
|
'/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;' + CRLF +
|
||||||
'/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=''NO_AUTO_VALUE_ON_ZERO'' */;';
|
'/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=''NO_AUTO_VALUE_ON_ZERO'' */;';
|
||||||
Output(Header, False, DBObj.Database<>ExportLastDatabase, True, False, False);
|
Output(Header, False, DBObj.Database<>ExportLastDatabase, True, False, False);
|
||||||
|
Output('/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */', True, False, False, True, True);
|
||||||
FHeaderCreated := True;
|
FHeaderCreated := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user