mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Add support for indexes using BTREE/RTREE/HASH algorithm. Make that visible in a new, 3rd column in the index tree. Fixes issue #1576.
This commit is contained in:
@ -113,7 +113,7 @@ type
|
|||||||
|
|
||||||
TTableKey = class(TObject)
|
TTableKey = class(TObject)
|
||||||
Name, OldName: String;
|
Name, OldName: String;
|
||||||
IndexType: String;
|
IndexType, Algorithm: String;
|
||||||
Columns, SubParts: TStringList;
|
Columns, SubParts: TStringList;
|
||||||
Modified, Added: Boolean;
|
Modified, Added: Boolean;
|
||||||
constructor Create;
|
constructor Create;
|
||||||
@ -2950,9 +2950,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Detect keys
|
// Detect keys
|
||||||
// PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`), KEY `id_2` (`id`),
|
// PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`), KEY `id_2` (`id`) USING BTREE,
|
||||||
// KEY `Text` (`Text`(100)), FULLTEXT KEY `Email` (`Email`,`Text`)
|
// KEY `Text` (`Text`(100)), FULLTEXT KEY `Email` (`Email`,`Text`)
|
||||||
rx.Expression := '^\s+((\w+)\s+)?KEY\s+([`"]?([^`"]+)[`"]?\s+)?\((.+)\),?$';
|
rx.Expression := '^\s+((\w+)\s+)?KEY\s+([`"]?([^`"]+)[`"]?\s+)?\((.+)\)(\s+USING\s+(\w+))?,?$';
|
||||||
if rx.Exec(CreateTable) then while true do begin
|
if rx.Exec(CreateTable) then while true do begin
|
||||||
if not Assigned(Keys) then
|
if not Assigned(Keys) then
|
||||||
break;
|
break;
|
||||||
@ -2961,6 +2961,7 @@ begin
|
|||||||
Key.Name := rx.Match[4];
|
Key.Name := rx.Match[4];
|
||||||
Key.OldName := Key.Name;
|
Key.OldName := Key.Name;
|
||||||
Key.IndexType := rx.Match[2];
|
Key.IndexType := rx.Match[2];
|
||||||
|
Key.Algorithm := rx.Match[7];
|
||||||
if Key.Name = '' then Key.Name := rx.Match[2]; // PRIMARY
|
if Key.Name = '' then Key.Name := rx.Match[2]; // PRIMARY
|
||||||
if Key.IndexType = '' then Key.IndexType := 'KEY'; // KEY
|
if Key.IndexType = '' then Key.IndexType := 'KEY'; // KEY
|
||||||
Key.Columns := Explode(',', rx.Match[5]);
|
Key.Columns := Explode(',', rx.Match[5]);
|
||||||
|
@ -420,7 +420,7 @@ object frmTableEditor: TfrmTableEditor
|
|||||||
item
|
item
|
||||||
Options = [coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible, coAllowFocus]
|
Options = [coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible, coAllowFocus]
|
||||||
Position = 0
|
Position = 0
|
||||||
Width = 196
|
Width = 116
|
||||||
WideText = 'Name'
|
WideText = 'Name'
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
@ -428,6 +428,11 @@ object frmTableEditor: TfrmTableEditor
|
|||||||
Position = 1
|
Position = 1
|
||||||
Width = 100
|
Width = 100
|
||||||
WideText = 'Type / Length'
|
WideText = 'Type / Length'
|
||||||
|
end
|
||||||
|
item
|
||||||
|
Position = 2
|
||||||
|
Width = 80
|
||||||
|
WideText = 'Algorithm'
|
||||||
end>
|
end>
|
||||||
end
|
end
|
||||||
object tlbIndexes: TToolBar
|
object tlbIndexes: TToolBar
|
||||||
|
@ -697,6 +697,9 @@ begin
|
|||||||
Delete(Result, Length(Result)-1, 2);
|
Delete(Result, Length(Result)-1, 2);
|
||||||
|
|
||||||
Result := Result + ')';
|
Result := Result + ')';
|
||||||
|
|
||||||
|
if FKeys[idx].Algorithm <> '' then
|
||||||
|
Result := Result + ' USING ' + FKeys[idx].Algorithm;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1448,6 +1451,7 @@ begin
|
|||||||
else
|
else
|
||||||
CellText := TblKey.Name;
|
CellText := TblKey.Name;
|
||||||
1: CellText := TblKey.IndexType;
|
1: CellText := TblKey.IndexType;
|
||||||
|
2: CellText := TblKey.Algorithm;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
1: begin
|
1: begin
|
||||||
@ -1455,6 +1459,7 @@ begin
|
|||||||
case Column of
|
case Column of
|
||||||
0: CellText := TblKey.Columns[Node.Index];
|
0: CellText := TblKey.Columns[Node.Index];
|
||||||
1: CellText := TblKey.SubParts[Node.Index];
|
1: CellText := TblKey.SubParts[Node.Index];
|
||||||
|
2: CellText := '';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1567,6 +1572,11 @@ begin
|
|||||||
EnumEditor.ValueList := TStringList.Create;
|
EnumEditor.ValueList := TStringList.Create;
|
||||||
EnumEditor.ValueList.CommaText := PKEY +','+ KEY +','+ UKEY +','+ FKEY +','+ SKEY;
|
EnumEditor.ValueList.CommaText := PKEY +','+ KEY +','+ UKEY +','+ FKEY +','+ SKEY;
|
||||||
EditLink := EnumEditor;
|
EditLink := EnumEditor;
|
||||||
|
end else if (Level = 0) and (Column = 2) then begin
|
||||||
|
// Algorithm pulldown
|
||||||
|
EnumEditor := TEnumEditorLink.Create(VT);
|
||||||
|
EnumEditor.ValueList := Explode(',', ',BTREE,HASH,RTREE');
|
||||||
|
EditLink := EnumEditor;
|
||||||
end else if (Level = 1) and (Column = 0) then begin
|
end else if (Level = 1) and (Column = 0) then begin
|
||||||
// Column names pulldown
|
// Column names pulldown
|
||||||
EnumEditor := TEnumEditorLink.Create(VT);
|
EnumEditor := TEnumEditorLink.Create(VT);
|
||||||
@ -1598,6 +1608,7 @@ begin
|
|||||||
case Column of
|
case Column of
|
||||||
0: TblKey.Name := NewText;
|
0: TblKey.Name := NewText;
|
||||||
1: TblKey.IndexType := NewText;
|
1: TblKey.IndexType := NewText;
|
||||||
|
2: TblKey.Algorithm := NewText;
|
||||||
end;
|
end;
|
||||||
// Needs to be called manually for Name and IndexType properties:
|
// Needs to be called manually for Name and IndexType properties:
|
||||||
TblKey.Modification(Sender);
|
TblKey.Modification(Sender);
|
||||||
|
Reference in New Issue
Block a user