diff --git a/components/heidisql/include/const.inc b/components/heidisql/include/const.inc
index a817cb10..9eb3bd91 100644
--- a/components/heidisql/include/const.inc
+++ b/components/heidisql/include/const.inc
@@ -170,6 +170,8 @@ const
REGNAME_CSV_LOWPRIO = 'CSVImportLowPriority';
REGNAME_CSV_REPLACE = 'CSVImportReplace';
REGNAME_CSV_IGNORE = 'CSVImportIgnore';
+ REGNAME_COPYMAXSIZE = 'CopyDataMaxSize';
+ DEFAULT_COPYMAXSIZE = 5;
REGNAME_DO_UPDATECHECK = 'Updatecheck';
DEFAULT_DO_UPDATECHECK = False;
REGNAME_DO_UPDATECHECK_BUILDS = 'UpdatecheckBuilds';
@@ -294,3 +296,7 @@ const
VTREE_NOTLOADED = 0;
VTREE_LOADED = 1;
+
+ MSG_COPYMAXSIZE = 'Copying data is limited to %s but more data is available. '
+ + 'Only %s out of %s rows were copied.' + CRLF + CRLF
+ + 'Increase the value in Tools > Preferences > Export if you need more.';
diff --git a/source/helpers.pas b/source/helpers.pas
index 40d5df74..b18d700e 100644
--- a/source/helpers.pas
+++ b/source/helpers.pas
@@ -784,10 +784,11 @@ end;
}
procedure GridToHtml(Grid: TVirtualStringTree; GridData: PGridResult; Title: WideString; S: TStream);
var
- i: Integer;
+ i, MaxSize: Integer;
tmp, Data, Generator: WideString;
Node: PVirtualNode;
begin
+ MaxSize := GetRegValue(REGNAME_COPYMAXSIZE, DEFAULT_COPYMAXSIZE) * SIZE_MB;
Generator := APPNAME+' '+FullAppVersion;
tmp :=
' 0) and Assigned(Node) and (S is TMemoryStream) and (S.Size >= MaxSize) then begin
+ MessageDlg(
+ Format(MSG_COPYMAXSIZE, [FormatByteNumber(MaxSize), FormatNumber(Node.Index), FormatNumber(Grid.RootNodeCount)]),
+ mtWarning, [mbOK], 0);
+ break;
+ end;
end;
Grid.Visible := true;
Mainform.showstatus(STATUS_MSG_READY);
@@ -965,10 +979,11 @@ end;
}
procedure GridToXml(Grid: TVirtualStringTree; GridData: PGridResult; root: WideString; S: TStream);
var
- i: Integer;
+ i, MaxSize: Integer;
tmp, Data: WideString;
Node: PVirtualNode;
begin
+ MaxSize := GetRegValue(REGNAME_COPYMAXSIZE, DEFAULT_COPYMAXSIZE) * SIZE_MB;
tmp := '' + CRLF + CRLF +
'
' + CRLF;
StreamWrite(S, tmp);
@@ -1011,6 +1026,12 @@ begin
// Release some memory.
Mainform.DiscardNodeData(Grid, Node);
Node := Grid.GetNext(Node);
+ if (MaxSize > 0) and Assigned(Node) and (S is TMemoryStream) and (S.Size >= MaxSize) then begin
+ MessageDlg(
+ Format(MSG_COPYMAXSIZE, [FormatByteNumber(MaxSize), FormatNumber(Node.Index), FormatNumber(Grid.RootNodeCount)]),
+ mtWarning, [mbOK], 0);
+ break;
+ end;
end;
// footer:
tmp := '
' + CRLF;
@@ -1027,10 +1048,11 @@ end;
}
procedure GridToSql(Grid: TVirtualStringTree; GridData: PGridResult; Tablename: WideString; S: TStream);
var
- i: Integer;
+ i, MaxSize: Integer;
tmp, Data: WideString;
Node: PVirtualNode;
begin
+ MaxSize := GetRegValue(REGNAME_COPYMAXSIZE, DEFAULT_COPYMAXSIZE) * SIZE_MB;
// Avoid reloading discarded data before the end.
Grid.Visible := false;
Node := Grid.GetFirst;
@@ -1074,6 +1096,12 @@ begin
// Release some memory.
Mainform.DiscardNodeData(Grid, Node);
Node := Grid.GetNext(Node);
+ if (MaxSize > 0) and Assigned(Node) and (S is TMemoryStream) and (S.Size >= MaxSize) then begin
+ MessageDlg(
+ Format(MSG_COPYMAXSIZE, [FormatByteNumber(MaxSize), FormatNumber(Node.Index), FormatNumber(Grid.RootNodeCount)]),
+ mtWarning, [mbOK], 0);
+ break;
+ end;
end;
// footer:
tmp := CRLF;
diff --git a/source/options.dfm b/source/options.dfm
index 54442e9e..db882025 100644
--- a/source/options.dfm
+++ b/source/options.dfm
@@ -587,14 +587,21 @@ object optionsform: Toptionsform
end
object tabCSV: TTabSheet
BorderWidth = 5
- Caption = 'CSV'
+ Caption = 'Export'
ImageIndex = 2
+ object lblCopyDataMaxSize: TLabel
+ Left = 8
+ Top = 200
+ Width = 244
+ Height = 13
+ Caption = 'Limit "Copy as CSV/HTML/XML/SQL" actions to [MB]'
+ end
object grpCSV: TGroupBox
Left = 0
Top = 0
Width = 399
- Height = 288
- Align = alClient
+ Height = 177
+ Align = alTop
Caption = 'CSV-Strings for copying/saving CSV-data'
TabOrder = 0
object lblCSVSeparator: TLabel
@@ -678,6 +685,28 @@ object optionsform: Toptionsform
OnChange = Modified
end
end
+ object editCopyDataMaxSize: TEdit
+ Left = 314
+ Top = 197
+ Width = 65
+ Height = 21
+ Anchors = [akTop, akRight]
+ TabOrder = 1
+ Text = '0'
+ OnChange = Modified
+ end
+ object updownCopyDataMaxSize: TUpDown
+ Left = 377
+ Top = 197
+ Width = 17
+ Height = 21
+ Anchors = [akTop, akRight]
+ Associate = editCopyDataMaxSize
+ Max = 999
+ TabOrder = 2
+ Wrap = True
+ OnChanging = anyUpDownLimitChanging
+ end
end
end
object btnCancel: TButton
diff --git a/source/options.pas b/source/options.pas
index 407a99d5..5946878b 100644
--- a/source/options.pas
+++ b/source/options.pas
@@ -91,6 +91,9 @@ type
grpSQLSample: TGroupBox;
SynMemoSQLSample: TSynMemo;
SynSQLSynSQLSample: TSynSQLSyn;
+ lblCopyDataMaxSize: TLabel;
+ editCopyDataMaxSize: TEdit;
+ updownCopyDataMaxSize: TUpDown;
procedure FormShow(Sender: TObject);
procedure Modified(Sender: TObject);
procedure Apply(Sender: TObject);
@@ -192,6 +195,8 @@ begin
MainReg.WriteString(REGNAME_CSV_SEPARATOR, editCSVSeparator.Text);
MainReg.WriteString(REGNAME_CSV_ENCLOSER, editCSVEncloser.Text);
MainReg.WriteString(REGNAME_CSV_TERMINATOR, editCSVTerminator.Text);
+ MainReg.WriteInteger(REGNAME_COPYMAXSIZE, updownCopyDataMaxSize.Position);
+
MainReg.WriteInteger(REGNAME_MAXCOLWIDTH, updownMaxColWidth.Position);
MainReg.WriteString(REGNAME_DATAFONTNAME, comboDataFontName.Text);
MainReg.WriteInteger(REGNAME_DATAFONTSIZE, updownDataFontSize.Position);
@@ -322,10 +327,13 @@ begin
// Default Column-Width in DBGrids:
updownMaxColWidth.Position := GetRegValue(REGNAME_MAXCOLWIDTH, DEFAULT_MAXCOLWIDTH);
- // CSV-Options:
+
+ // Export-Options:
editCSVSeparator.Text := GetRegValue(REGNAME_CSV_SEPARATOR, DEFAULT_CSV_SEPARATOR);
editCSVEncloser.Text := GetRegValue(REGNAME_CSV_ENCLOSER, DEFAULT_CSV_ENCLOSER);
editCSVTerminator.Text := GetRegValue(REGNAME_CSV_TERMINATOR, DEFAULT_CSV_TERMINATOR);
+ updownCopyDataMaxSize.Position := GetRegValue(REGNAME_COPYMAXSIZE, DEFAULT_COPYMAXSIZE);
+
// Log to file
chkLogToFile.Checked := GetRegValue(REGNAME_LOGTOFILE, DEFAULT_LOGTOFILE);
btnOpenLogFolder.Enabled := DirectoryExists(DirnameSessionLogs);