From bf24403596e35028408a44adbcdc12158b2e547d Mon Sep 17 00:00:00 2001 From: "rosenfield.albert" Date: Thu, 7 Aug 2008 23:17:28 +0000 Subject: [PATCH] * Crashed tables were mistaken for views. Fixes issue #650. * Add separate node type for crashed tables, so that some sort of a graphic can be associated with those. --- components/heidisql/include/const.inc | 4 ++++ source/childwin.pas | 22 ++++++++++++++++------ source/helpers.pas | 20 ++++++++++++++------ source/main.pas | 2 ++ source/selectdbobject.pas | 1 + 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/components/heidisql/include/const.inc b/components/heidisql/include/const.inc index 8d299301..72f605bf 100644 --- a/components/heidisql/include/const.inc +++ b/components/heidisql/include/const.inc @@ -201,6 +201,8 @@ const ICONINDEX_TABLE_HIGHLIGHT = 71; ICONINDEX_VIEW = 81; ICONINDEX_VIEW_HIGHLIGHT = 82; + ICONINDEX_CRASHED_TABLE_HIGHLIGHT = -1; + ICONINDEX_CRASHED_TABLE = -1; // Size of byte units {KiloByte} SIZE_KB = 1024; @@ -238,3 +240,5 @@ const NODETYPE_VIEW = 2; NODETYPE_DB = 3; NODETYPE_COLUMN = 4; + NODETYPE_CRASHED_TABLE = 5; + diff --git a/source/childwin.pas b/source/childwin.pas index 758fef5c..82366323 100644 --- a/source/childwin.pas +++ b/source/childwin.pas @@ -1612,10 +1612,15 @@ begin // Treat tables slightly different than views case GetDBObjectType( ds.Fields) of - NODETYPE_TABLE: // A normal table + NODETYPE_TABLE, NODETYPE_CRASHED_TABLE: // A normal table begin - VTRowDataListTables[i-1].ImageIndex := ICONINDEX_TABLE; - VTRowDataListTables[i-1].NodeType := NODETYPE_TABLE; + if GetDBObjectType(ds.Fields) = NODETYPE_CRASHED_TABLE then begin + VTRowDataListTables[i-1].ImageIndex := ICONINDEX_CRASHED_TABLE; + VTRowDataListTables[i-1].NodeType := NODETYPE_CRASHED_TABLE; + end else begin + VTRowDataListTables[i-1].ImageIndex := ICONINDEX_TABLE; + VTRowDataListTables[i-1].NodeType := NODETYPE_TABLE; + end; // Rows if ds.FindField('Rows') <> nil then ListCaptions.Add( FormatNumber( FieldContent(ds, 'Rows') ) ) @@ -1969,7 +1974,7 @@ begin // Check type of first selected node, to en-/disable certain menu items if DBObjectSelected then begin NodeData := ListTables.GetNodeData( SelectedNodes[0] ); - TableSelected := NodeData.NodeType = NODETYPE_TABLE; + TableSelected := (NodeData.NodeType = NODETYPE_TABLE) or (NodeData.NodeType = NODETYPE_CRASHED_TABLE); ViewSelected := NodeData.NodeType = NODETYPE_VIEW; end; @@ -2521,6 +2526,7 @@ var begin ObjName := Fields[0].AsString; case GetDBObjectType(Fields) of + NODETYPE_CRASHED_TABLE: ObjType := 'table'; NODETYPE_TABLE: ObjType := 'table'; NODETYPE_VIEW: ObjType := 'view'; else ObjType := 'unknown'; @@ -3146,7 +3152,7 @@ begin L := DBtree.GetNodeLevel(DBtree.GetFirstSelected); Mainform.actCreateTable.Enabled := L in [1,2]; Mainform.actCreateView.Enabled := (L in [1,2]) and (mysql_version >= 50001); - Mainform.actEditTableProperties.Enabled := (L = 2) and (GetSelectedNodeType = NODETYPE_TABLE); + Mainform.actEditTableProperties.Enabled := (L = 2) and ((GetSelectedNodeType = NODETYPE_TABLE) or (GetSelectedNodeType = NODETYPE_CRASHED_TABLE)); Mainform.actEditView.Enabled := (L = 2) and (GetSelectedNodeType = NODETYPE_VIEW); MainForm.actDropTablesAndViews.Enabled := (L = 2); end; @@ -5010,7 +5016,7 @@ begin Bytes := GetTableSize(ds); CellText := FormatByteNumber(Bytes); end - else CellText := ''; // Applies for views + else CellText := ''; // Applies for views and crashed tables end; end; end; @@ -5044,6 +5050,10 @@ begin if Kind = ikSelected then ImageIndex := ICONINDEX_VIEW_HIGHLIGHT else ImageIndex := ICONINDEX_VIEW; + NODETYPE_CRASHED_TABLE: + if Kind = ikSelected then + ImageIndex := ICONINDEX_CRASHED_TABLE_HIGHLIGHT + else ImageIndex := ICONINDEX_CRASHED_TABLE; end; end; end; diff --git a/source/helpers.pas b/source/helpers.pas index 4c5a6ab6..77a2ca75 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -2092,12 +2092,20 @@ begin "Views bla references invalid..." } Result := NODETYPE_TABLE; - if (TableStatus.Count>=3) // Result from SHOW TABLE STATUS - and TableStatus[1].IsNull // Engine column is NULL for views - and TableStatus[2].IsNull then - Result := NODETYPE_VIEW - else if (TableStatus.Count=2) // Result from SHOW FULL TABLES - and (UpperCase(TableStatus[1].AsString) = 'VIEW') then + if (TableStatus.Count>=3) then begin + // Result from SHOW TABLE STATUS + if + TableStatus[1].IsNull and // Engine column is NULL for views + TableStatus[2].IsNull and + (Pos('VIEW', UpperCase(TableStatus.FieldByName('Comment').AsWideString)) > 0) + then Result := NODETYPE_VIEW; + if + TableStatus[1].IsNull and + TableStatus[2].IsNull and + (Pos('MARKED AS CRASHED', UpperCase(TableStatus.FieldByName('Comment').AsWideString)) > 0) + then Result := NODETYPE_CRASHED_TABLE; + end else if (TableStatus.Count=2) // Result from SHOW FULL TABLES + and (UpperCase(TableStatus[1].AsWideString) = 'VIEW') then Result := NODETYPE_VIEW; end; diff --git a/source/main.pas b/source/main.pas index 8f5ab86f..4bfc1251 100644 --- a/source/main.pas +++ b/source/main.pas @@ -1194,11 +1194,13 @@ begin if Childwin.PageControlMain.ActivePage = Childwin.tabDatabase then begin // Invoked from one of the various buttons, SheetDatabase is the active page, drop highlighted table(s). Tables := GetVTCaptions(Childwin.ListTables, True, 0, NODETYPE_TABLE); + Tables.AddStrings(GetVTCaptions(Childwin.ListTables, True, 0, NODETYPE_CRASHED_TABLE)); Views := GetVTCaptions(Childwin.ListTables, True, 0, NODETYPE_VIEW); end else begin // Invoked from one of the various buttons, drop table selected in tree view. case Childwin.GetSelectedNodeType of NODETYPE_TABLE: Tables.Add(Childwin.SelectedTable); + NODETYPE_CRASHED_TABLE: Tables.Add(Childwin.SelectedTable); NODETYPE_VIEW: Views.Add(Childwin.SelectedTable) end; end; diff --git a/source/selectdbobject.pas b/source/selectdbobject.pas index 43213e67..31b888da 100644 --- a/source/selectdbobject.pas +++ b/source/selectdbobject.pas @@ -180,6 +180,7 @@ begin ds := CWin.FetchDbTableList(CWin.Databases[Node.Parent.Index]); ds.RecNo := Node.Index+1; case GetDBObjectType(ds.Fields) of + NODETYPE_CRASHED_TABLE: ImageIndex := ICONINDEX_CRASHED_TABLE; NODETYPE_TABLE: ImageIndex := ICONINDEX_TABLE; NODETYPE_VIEW: ImageIndex := ICONINDEX_VIEW; end;