From 2cff5732fc5f7f7a735f7e4f39b26b34d5b00683 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 26 Aug 2008 09:09:41 +0000 Subject: [PATCH] Remove no longer needed routine for autocalculating row limit: GetCalculatedLimit. The Export SQL dialog now uses a constant number of 5000 rows fetched per step. Also removes the option in the preferences screen for limiting the data amount, which was misleading the user before and only used to limit the export stuff. --- components/heidisql/include/const.inc | 2 -- source/childwin.pas | 44 +-------------------------- source/exportsql.pas | 10 +++--- source/options.dfm | 27 ---------------- source/options.pas | 6 ---- 5 files changed, 5 insertions(+), 84 deletions(-) diff --git a/components/heidisql/include/const.inc b/components/heidisql/include/const.inc index 56949e26..2fb66268 100644 --- a/components/heidisql/include/const.inc +++ b/components/heidisql/include/const.inc @@ -58,8 +58,6 @@ const DEFAULT_DATALIMITEND = 5000; // how much memory we're aiming to use for the // data grid and it's automatic limit function - REGNAME_LOADSIZE = 'DataLoadSize'; - DEFAULT_LOADSIZE = 5*1024*1024; REGNAME_LOGSQLNUM = 'logsqlnum'; DEFAULT_LOGSQLNUM = 300; REGNAME_LOGSQLWIDTH = 'logsqlwidth'; diff --git a/source/childwin.pas b/source/childwin.pas index c9339c21..ed7f1b17 100644 --- a/source/childwin.pas +++ b/source/childwin.pas @@ -377,7 +377,6 @@ type procedure GridPaintText(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType); procedure menuDeleteSnippetClick(Sender: TObject); - procedure GetCalculatedLimit(Table: String; out Limit, AllRows: Int64); procedure menuExploreClick(Sender: TObject); procedure menuInsertSnippetAtCursorClick(Sender: TObject); procedure menuLoadSnippetClick(Sender: TObject); @@ -505,8 +504,7 @@ type prefConvertHTMLEntities : Boolean; prefLogsqlnum, prefLogSqlWidth, - prefDefaultColWidth, - prefLoadSize : Integer; + prefDefaultColWidth : Integer; prefCSVSeparator, prefCSVEncloser, prefCSVTerminator : String[10]; @@ -868,7 +866,6 @@ begin prefCSVTerminator := Mainform.GetRegValue(REGNAME_CSV_TERMINATOR, DEFAULT_CSV_TERMINATOR); prefRememberFilters := Mainform.GetRegValue(REGNAME_REMEMBERFILTERS, DEFAULT_REMEMBERFILTERS); prefPreferShowTables := Mainform.GetRegValue(REGNAME_PREFER_SHOWTABLES, DEFAULT_PREFER_SHOWTABLES); - prefLoadSize := Mainform.GetRegValue(REGNAME_LOADSIZE, DEFAULT_LOADSIZE); // SQL-Font: fontname := Mainform.GetRegValue(REGNAME_FONTNAME, DEFAULT_FONTNAME); @@ -3739,45 +3736,6 @@ begin end; -{*** - Detect average row size and limit the number of rows fetched at - once if more than ~ 5 MB of data -} -procedure TMDIChild.GetCalculatedLimit(Table: String; out Limit, AllRows: Int64); -var - AvgRowSize : Int64; - ds: TDataSet; -const - // how much overhead this application has per row - ROW_SIZE_OVERHEAD : Integer = 1150; - // average row size guess for mysql server < 5.0 - ROW_SIZE_GUESS: Integer = 2048; -begin - Limit := -1; - try - ds := GetResults('SHOW TABLE STATUS LIKE ' + esc(Table)); - if ds = nil then exit; - if ds.FieldByName('Avg_row_length').IsNull or ds.FieldByName('Rows').IsNull then begin - // Guessing row size and count for views, fixes bug #346 - AvgRowSize := ROW_SIZE_GUESS + ROW_SIZE_OVERHEAD; - AllRows := MaxInt; - end else begin - AvgRowSize := MakeInt( ds.FieldByName( 'Avg_row_length' ).AsString ) + ROW_SIZE_OVERHEAD; - AllRows := MakeInt( ds.FieldByName( 'Rows' ).AsString ); - end; - if AvgRowSize * AllRows > prefLoadSize then - begin - Limit := Trunc( prefLoadSize / AvgRowSize ); - if Limit >= AllRows then Limit := -1; - end; - ds.Close; - FreeAndNil(ds); - finally - debug( 'GetCalculatedLimit: ' + formatnumber(Limit) ); - end; -end; - - {** Column selection for datagrid } diff --git a/source/exportsql.pas b/source/exportsql.pas index 2fbdaa75..d65f4605 100644 --- a/source/exportsql.pas +++ b/source/exportsql.pas @@ -973,12 +973,10 @@ begin end; end; - {*** - Detect average row size and limit the number of rows fetched at - once if more than ~ 5 MB of data - Be sure to do this step before the table is locked! - } - cwin.GetCalculatedLimit( checkListTables.Items[i], limit, RecordCount_all); + // Set rows per step limit and detect total row count + // Be sure to do this step before the table is locked! + limit := 5000; + RecordCount_all := MakeInt(cwin.GetNamedVar('SHOW TABLE STATUS LIKE '+esc(checkListTables.Items[i]), 'Rows')); if RecordCount_all = 0 then begin if tofile then diff --git a/source/options.dfm b/source/options.dfm index 9d62cf65..56671424 100644 --- a/source/options.dfm +++ b/source/options.dfm @@ -445,13 +445,6 @@ object optionsform: Toptionsform Height = 13 Caption = 'Maximum column-width in data-grids:' end - object lblLoadSize: TLabel - Left = 8 - Top = 58 - Width = 196 - Height = 13 - Caption = 'Data size for auto calculating LIMIT [KB]:' - end object GroupBox2: TGroupBox Left = 0 Top = 80 @@ -561,26 +554,6 @@ object optionsform: Toptionsform TabOrder = 0 OnClick = Modified end - object editLoadSize: TEdit - Left = 219 - Top = 55 - Width = 42 - Height = 21 - TabOrder = 4 - Text = '1' - end - object updownLoadSize: TUpDown - Left = 261 - Top = 55 - Width = 17 - Height = 21 - Associate = editLoadSize - Min = 1 - Max = 32767 - Position = 1 - TabOrder = 5 - Wrap = True - end end object TabSheet5: TTabSheet BorderWidth = 5 diff --git a/source/options.pas b/source/options.pas index 474101c3..641ba45c 100644 --- a/source/options.pas +++ b/source/options.pas @@ -92,9 +92,6 @@ type updownUpdatecheckInterval: TUpDown; chkPreferShowTables: TCheckBox; chkUpdateCheckBuilds: TCheckBox; - lblLoadSize: TLabel; - editLoadSize: TEdit; - updownLoadSize: TUpDown; procedure ButtonCancelClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure Modified(Sender: TObject); @@ -176,7 +173,6 @@ begin reg.WriteBool(REGNAME_DO_UPDATECHECK_BUILDS, chkUpdatecheckBuilds.Checked); reg.WriteInteger(REGNAME_UPDATECHECK_INTERVAL, updownUpdatecheckInterval.Position); reg.WriteBool(REGNAME_PREFER_SHOWTABLES, chkPreferShowTables.Checked); - reg.WriteInteger(REGNAME_LOADSIZE, updownLoadSize.Position*SIZE_KB); // Clean registry from unwanted WHERE clauses if "Remember WHERE filters" was unchecked if not chkRememberFilters.Checked then begin @@ -235,7 +231,6 @@ begin cwin.prefCSVTerminator := self.Edit3.text; cwin.prefConvertHTMLEntities := self.CheckBoxConvertHTMLEntities.Checked; cwin.prefPreferShowTables := chkPreferShowTables.Checked; - cwin.prefLoadSize := updownLoadSize.Position * SIZE_KB; end; // Settings have been applied, send a signal to the user @@ -284,7 +279,6 @@ begin updownUpdatecheckInterval.Position := Mainform.GetRegValue(REGNAME_UPDATECHECK_INTERVAL, DEFAULT_UPDATECHECK_INTERVAL); chkUpdatecheckClick(Sender); chkPreferShowTables.Checked := Mainform.GetRegValue(REGNAME_PREFER_SHOWTABLES, DEFAULT_PREFER_SHOWTABLES); - updownLoadSize.Position := Mainform.GetRegValue(REGNAME_LOADSIZE, DEFAULT_LOADSIZE) div SIZE_KB; // Default Column-Width in DBGrids: updownDefaultColWidth.Position := Mainform.GetRegValue(REGNAME_DEFAULTCOLWIDTH, DEFAULT_DEFAULTCOLWIDTH);