mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-15 02:54:07 +08:00
This commit is contained in:
@ -218,7 +218,7 @@ type
|
|||||||
function ReadTextfileChunk(Stream: TFileStream; FileCharset: TFileCharset; ChunkSize: Int64 = 0): String;
|
function ReadTextfileChunk(Stream: TFileStream; FileCharset: TFileCharset; ChunkSize: Int64 = 0): String;
|
||||||
function ReadTextfile(Filename: String): String;
|
function ReadTextfile(Filename: String): String;
|
||||||
function ReadBinaryFile(Filename: String; MaxBytes: Int64): AnsiString;
|
function ReadBinaryFile(Filename: String; MaxBytes: Int64): AnsiString;
|
||||||
procedure StreamToClipboard(Text, HTML: TMemoryStream; CreateHTMLHeader: Boolean);
|
procedure StreamToClipboard(Text, HTML: TStream; CreateHTMLHeader: Boolean);
|
||||||
function WideHexToBin(text: String): AnsiString;
|
function WideHexToBin(text: String): AnsiString;
|
||||||
function BinToWideHex(bin: AnsiString): String;
|
function BinToWideHex(bin: AnsiString): String;
|
||||||
procedure CheckHex(text: String; errorMessage: string);
|
procedure CheckHex(text: String; errorMessage: string);
|
||||||
@ -2447,7 +2447,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure StreamToClipboard(Text, HTML: TMemoryStream; CreateHTMLHeader: Boolean);
|
procedure StreamToClipboard(Text, HTML: TStream; CreateHTMLHeader: Boolean);
|
||||||
var
|
var
|
||||||
TextContent, HTMLContent: AnsiString;
|
TextContent, HTMLContent: AnsiString;
|
||||||
GlobalMem: HGLOBAL;
|
GlobalMem: HGLOBAL;
|
||||||
|
@ -137,6 +137,7 @@ uses main, mysql_structures;
|
|||||||
const
|
const
|
||||||
STRSKIPPED: String = 'Skipped - ';
|
STRSKIPPED: String = 'Skipped - ';
|
||||||
OUTPUT_FILE = 'One big file';
|
OUTPUT_FILE = 'One big file';
|
||||||
|
OUTPUT_CLIPBOARD = 'Clipboard';
|
||||||
OUTPUT_DIR = 'Directory - one file per object in database subdirectories';
|
OUTPUT_DIR = 'Directory - one file per object in database subdirectories';
|
||||||
OUTPUT_DB = 'Database';
|
OUTPUT_DB = 'Database';
|
||||||
OUTPUT_SERVER = 'Server: ';
|
OUTPUT_SERVER = 'Server: ';
|
||||||
@ -181,7 +182,7 @@ begin
|
|||||||
OutputDirs := TStringList.Create;
|
OutputDirs := TStringList.Create;
|
||||||
OutputFiles.Text := GetRegValue(REGNAME_EXP_OUTFILES, '');
|
OutputFiles.Text := GetRegValue(REGNAME_EXP_OUTFILES, '');
|
||||||
OutputDirs.Text := GetRegValue(REGNAME_EXP_OUTDIRS, '');
|
OutputDirs.Text := GetRegValue(REGNAME_EXP_OUTDIRS, '');
|
||||||
comboExportOutputType.Items.Text := OUTPUT_FILE+CRLF +OUTPUT_DIR+CRLF +OUTPUT_DB;
|
comboExportOutputType.Items.Text := OUTPUT_FILE+CRLF +OUTPUT_DIR+CRLF +OUTPUT_CLIPBOARD+CRLF +OUTPUT_DB;
|
||||||
comboExportOutputType.ItemIndex := GetRegValue(REGNAME_EXP_OUTPUT, 0);
|
comboExportOutputType.ItemIndex := GetRegValue(REGNAME_EXP_OUTPUT, 0);
|
||||||
comboExportOutputTarget.Text := '';
|
comboExportOutputTarget.Text := '';
|
||||||
// Add session names from registry
|
// Add session names from registry
|
||||||
@ -334,7 +335,7 @@ begin
|
|||||||
btnExecute.Enabled := SomeChecked and (memoFindText.Text <> '');
|
btnExecute.Enabled := SomeChecked and (memoFindText.Text <> '');
|
||||||
end else if tabsTools.ActivePage = tabSQLExport then begin
|
end else if tabsTools.ActivePage = tabSQLExport then begin
|
||||||
btnExecute.Caption := 'Export';
|
btnExecute.Caption := 'Export';
|
||||||
btnExecute.Enabled := SomeChecked and (comboExportOutputTarget.Text <> '');
|
btnExecute.Enabled := SomeChecked and ((comboExportOutputTarget.Text <> '') or (not comboExportOutputTarget.Enabled));
|
||||||
end else if tabsTools.ActivePage = tabBulkTableEdit then begin
|
end else if tabsTools.ActivePage = tabBulkTableEdit then begin
|
||||||
btnExecute.Caption := 'Update';
|
btnExecute.Caption := 'Update';
|
||||||
chkBulkTableEditCollation.Enabled := Mainform.Connection.IsUnicode;
|
chkBulkTableEditCollation.Enabled := Mainform.Connection.IsUnicode;
|
||||||
@ -486,8 +487,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if Assigned(ExportStream) then begin
|
if Assigned(ExportStream) then begin
|
||||||
if comboExportOutputType.Text = OUTPUT_FILE then
|
if (comboExportOutputType.Text = OUTPUT_FILE) or (comboExportOutputType.Text = OUTPUT_CLIPBOARD) then
|
||||||
StreamWrite(ExportStream, EXPORT_FILE_FOOTER);
|
StreamWrite(ExportStream, EXPORT_FILE_FOOTER);
|
||||||
|
if comboExportOutputType.Text = OUTPUT_CLIPBOARD then
|
||||||
|
StreamToClipboard(ExportStream, nil, false);
|
||||||
FreeAndNil(ExportStream);
|
FreeAndNil(ExportStream);
|
||||||
end;
|
end;
|
||||||
ExportLastDatabase := '';
|
ExportLastDatabase := '';
|
||||||
@ -738,6 +741,12 @@ begin
|
|||||||
lblExportOutputTarget.Caption := 'Directory:';
|
lblExportOutputTarget.Caption := 'Directory:';
|
||||||
btnExportOutputTargetSelect.Enabled := True;
|
btnExportOutputTargetSelect.Enabled := True;
|
||||||
btnExportOutputTargetSelect.ImageIndex := 51;
|
btnExportOutputTargetSelect.ImageIndex := 51;
|
||||||
|
end else if comboExportOutputType.Text = OUTPUT_CLIPBOARD then begin
|
||||||
|
comboExportOutputTarget.Enabled := False;
|
||||||
|
comboExportOutputTarget.Items.Clear;
|
||||||
|
lblExportOutputTarget.Caption := '';
|
||||||
|
btnExportOutputTargetSelect.Enabled := False;
|
||||||
|
btnExportOutputTargetSelect.ImageIndex := 4;
|
||||||
end else if comboExportOutputType.Text = OUTPUT_DB then begin
|
end else if comboExportOutputType.Text = OUTPUT_DB then begin
|
||||||
comboExportOutputTarget.Style := csDropDownList;
|
comboExportOutputTarget.Style := csDropDownList;
|
||||||
lblExportOutputTarget.Caption := 'Database:';
|
lblExportOutputTarget.Caption := 'Database:';
|
||||||
@ -795,6 +804,7 @@ begin
|
|||||||
|
|
||||||
FLastOutputSelectedIndex := comboExportOutputType.ItemIndex;
|
FLastOutputSelectedIndex := comboExportOutputType.ItemIndex;
|
||||||
chkExportDatabasesCreate.Enabled := (comboExportOutputType.Text = OUTPUT_FILE)
|
chkExportDatabasesCreate.Enabled := (comboExportOutputType.Text = OUTPUT_FILE)
|
||||||
|
or (comboExportOutputType.Text = OUTPUT_CLIPBOARD)
|
||||||
or (Copy(comboExportOutputType.Text, 1, Length(OUTPUT_SERVER)) = OUTPUT_SERVER);
|
or (Copy(comboExportOutputType.Text, 1, Length(OUTPUT_SERVER)) = OUTPUT_SERVER);
|
||||||
chkExportDatabasesDrop.Enabled := chkExportDatabasesCreate.Enabled;
|
chkExportDatabasesDrop.Enabled := chkExportDatabasesCreate.Enabled;
|
||||||
NewIdx := comboExportOutputTarget.Items.IndexOf(OldItem);
|
NewIdx := comboExportOutputTarget.Items.IndexOf(OldItem);
|
||||||
@ -901,7 +911,7 @@ end;
|
|||||||
|
|
||||||
procedure TfrmTableTools.DoExport(DBObj: TDBObject);
|
procedure TfrmTableTools.DoExport(DBObj: TDBObject);
|
||||||
var
|
var
|
||||||
ToFile, ToDir, ToDb, ToServer, IsLastRowInChunk, NeedsDBStructure: Boolean;
|
ToFile, ToDir, ToClipboard, ToDb, ToServer, IsLastRowInChunk, NeedsDBStructure: Boolean;
|
||||||
Struc, Header, DbDir, FinalDbName, BaseInsert, Row, TargetDbAndObject, BinContent: String;
|
Struc, Header, DbDir, FinalDbName, BaseInsert, Row, TargetDbAndObject, BinContent: String;
|
||||||
MultiSQL: TStringList;
|
MultiSQL: TStringList;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -924,7 +934,7 @@ const
|
|||||||
SA: AnsiString;
|
SA: AnsiString;
|
||||||
ChunkSize: Integer;
|
ChunkSize: Integer;
|
||||||
begin
|
begin
|
||||||
if (ToFile and ForFile) or (ToDir and ForDir) 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;
|
||||||
StreamWrite(ExportStream, SQL);
|
StreamWrite(ExportStream, SQL);
|
||||||
@ -966,6 +976,7 @@ begin
|
|||||||
);
|
);
|
||||||
ToFile := comboExportOutputType.Text = OUTPUT_FILE;
|
ToFile := comboExportOutputType.Text = OUTPUT_FILE;
|
||||||
ToDir := comboExportOutputType.Text = OUTPUT_DIR;
|
ToDir := comboExportOutputType.Text = OUTPUT_DIR;
|
||||||
|
ToClipboard := comboExportOutputType.Text = OUTPUT_CLIPBOARD;
|
||||||
ToDb := comboExportOutputType.Text = OUTPUT_DB;
|
ToDb := comboExportOutputType.Text = OUTPUT_DB;
|
||||||
ToServer := Copy(comboExportOutputType.Text, 1, Length(OUTPUT_SERVER)) = OUTPUT_SERVER;
|
ToServer := Copy(comboExportOutputType.Text, 1, Length(OUTPUT_SERVER)) = OUTPUT_SERVER;
|
||||||
StartTime := GetTickCount;
|
StartTime := GetTickCount;
|
||||||
@ -981,6 +992,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
if ToFile and (not Assigned(ExportStream)) then
|
if ToFile and (not Assigned(ExportStream)) then
|
||||||
ExportStream := TFileStream.Create(comboExportOutputTarget.Text, fmCreate or fmOpenWrite);
|
ExportStream := TFileStream.Create(comboExportOutputTarget.Text, fmCreate or fmOpenWrite);
|
||||||
|
if ToClipboard and (not Assigned(ExportStream)) then
|
||||||
|
ExportStream := TMemoryStream.Create;
|
||||||
if ToDb or ToServer then
|
if ToDb or ToServer then
|
||||||
ExportStream := TMemoryStream.Create;
|
ExportStream := TMemoryStream.Create;
|
||||||
if (DBObj.Database<>ExportLastDatabase) or ToDir then begin
|
if (DBObj.Database<>ExportLastDatabase) or ToDir then begin
|
||||||
@ -1065,7 +1078,7 @@ begin
|
|||||||
' ON '+m(StrucResult.Col('Table'))+' FOR EACH ROW '+StrucResult.Col('Statement');
|
' ON '+m(StrucResult.Col('Table'))+' FOR EACH ROW '+StrucResult.Col('Statement');
|
||||||
if ToDb then
|
if ToDb then
|
||||||
Insert(m(FinalDbName)+'.', Struc, Pos('TRIGGER', Struc) + 8 );
|
Insert(m(FinalDbName)+'.', Struc, Pos('TRIGGER', Struc) + 8 );
|
||||||
if ToFile or ToDir then begin
|
if ToFile or ToClipboard or ToDir then begin
|
||||||
Struc := 'SET SESSION SQL_MODE=' + esc(StrucResult.Col('sql_mode')) + ';' + CRLF +
|
Struc := 'SET SESSION SQL_MODE=' + esc(StrucResult.Col('sql_mode')) + ';' + CRLF +
|
||||||
'DELIMITER ' + TempDelim + CRLF +
|
'DELIMITER ' + TempDelim + CRLF +
|
||||||
Struc + TempDelim + CRLF +
|
Struc + TempDelim + CRLF +
|
||||||
@ -1086,7 +1099,7 @@ begin
|
|||||||
Insert(m(FinalDbName)+'.', Struc, Pos('FUNCTION', Struc) + 9 );
|
Insert(m(FinalDbName)+'.', Struc, Pos('FUNCTION', Struc) + 9 );
|
||||||
end;
|
end;
|
||||||
// Change delimiter for file output, so readers split queries at the right string position
|
// Change delimiter for file output, so readers split queries at the right string position
|
||||||
if ToFile or ToDir then
|
if ToFile or ToDir or ToClipboard then
|
||||||
Struc := 'DELIMITER ' + TempDelim + CRLF + Struc + TempDelim + CRLF + 'DELIMITER ';
|
Struc := 'DELIMITER ' + TempDelim + CRLF + Struc + TempDelim + CRLF + 'DELIMITER ';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user