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:
Ansgar Becker
2010-05-12 19:14:45 +00:00
parent 1ab975b0d5
commit 4e49324d03

View File

@ -115,7 +115,9 @@ type
FLastOutputSelectedIndex: Integer;
FModifiedDbs: TStringList;
FHeaderCreated: Boolean;
ToFile, ToDir, ToClipboard, ToDb, ToServer: Boolean;
procedure SetToolMode(Value: TToolMode);
procedure Output(SQL: String; IsEndOfQuery, ForFile, ForDir, ForDb, ForServer: Boolean);
procedure AddResults(SQL: String);
procedure AddNotes(Col1, Col2, Col3, Col4: String);
procedure SetupResultGrid(Results: TMySQLQuery=nil);
@ -499,8 +501,8 @@ begin
end; // End of db item loop
if Assigned(ExportStream) then begin
if (comboExportOutputType.Text = OUTPUT_FILE) or (comboExportOutputType.Text = OUTPUT_CLIPBOARD) then
StreamWrite(ExportStream, EXPORT_FILE_FOOTER);
Output(EXPORT_FILE_FOOTER, False, True, False, False, False);
Output('/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */', True, False, False, True, True);
if comboExportOutputType.Text = OUTPUT_CLIPBOARD then
StreamToClipboard(ExportStream, nil, false);
FreeAndNil(ExportStream);
@ -910,27 +912,8 @@ begin
end;
procedure TfrmTableTools.DoExport(DBObj: TDBObject);
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);
procedure TfrmTableTools.Output(SQL: String; IsEndOfQuery, ForFile, ForDir, ForDb, ForServer: Boolean);
var
SA: AnsiString;
ChunkSize: Integer;
@ -956,6 +939,26 @@ const
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;
procedure LogStatistic(RowsDone: Int64);
var
LogRow: TStringlist;
@ -1011,6 +1014,7 @@ begin
'/*!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'' */;';
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;
end;