mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
* 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.
This commit is contained in:
@ -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;
|
||||
|
||||
|
@ -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
|
||||
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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user