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:
Ansgar Becker
2010-01-22 10:21:27 +00:00
parent a5a1e138b8
commit 97ce23ee1f
3 changed files with 21 additions and 4 deletions

View File

@ -113,7 +113,7 @@ type
TTableKey = class(TObject)
Name, OldName: String;
IndexType: String;
IndexType, Algorithm: String;
Columns, SubParts: TStringList;
Modified, Added: Boolean;
constructor Create;
@ -2950,9 +2950,9 @@ begin
end;
// 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`)
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 not Assigned(Keys) then
break;
@ -2961,6 +2961,7 @@ begin
Key.Name := rx.Match[4];
Key.OldName := Key.Name;
Key.IndexType := rx.Match[2];
Key.Algorithm := rx.Match[7];
if Key.Name = '' then Key.Name := rx.Match[2]; // PRIMARY
if Key.IndexType = '' then Key.IndexType := 'KEY'; // KEY
Key.Columns := Explode(',', rx.Match[5]);

View File

@ -420,7 +420,7 @@ object frmTableEditor: TfrmTableEditor
item
Options = [coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible, coAllowFocus]
Position = 0
Width = 196
Width = 116
WideText = 'Name'
end
item
@ -428,6 +428,11 @@ object frmTableEditor: TfrmTableEditor
Position = 1
Width = 100
WideText = 'Type / Length'
end
item
Position = 2
Width = 80
WideText = 'Algorithm'
end>
end
object tlbIndexes: TToolBar

View File

@ -697,6 +697,9 @@ begin
Delete(Result, Length(Result)-1, 2);
Result := Result + ')';
if FKeys[idx].Algorithm <> '' then
Result := Result + ' USING ' + FKeys[idx].Algorithm;
end;
@ -1448,6 +1451,7 @@ begin
else
CellText := TblKey.Name;
1: CellText := TblKey.IndexType;
2: CellText := TblKey.Algorithm;
end;
end;
1: begin
@ -1455,6 +1459,7 @@ begin
case Column of
0: CellText := TblKey.Columns[Node.Index];
1: CellText := TblKey.SubParts[Node.Index];
2: CellText := '';
end;
end;
end;
@ -1567,6 +1572,11 @@ begin
EnumEditor.ValueList := TStringList.Create;
EnumEditor.ValueList.CommaText := PKEY +','+ KEY +','+ UKEY +','+ FKEY +','+ SKEY;
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
// Column names pulldown
EnumEditor := TEnumEditorLink.Create(VT);
@ -1598,6 +1608,7 @@ begin
case Column of
0: TblKey.Name := NewText;
1: TblKey.IndexType := NewText;
2: TblKey.Algorithm := NewText;
end;
// Needs to be called manually for Name and IndexType properties:
TblKey.Modification(Sender);