diff --git a/source/helpers.pas b/source/helpers.pas index bb36a658..67f094da 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -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]); diff --git a/source/table_editor.dfm b/source/table_editor.dfm index 559f2b42..76744e54 100644 --- a/source/table_editor.dfm +++ b/source/table_editor.dfm @@ -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 diff --git a/source/table_editor.pas b/source/table_editor.pas index a6244e55..6809a8bc 100644 --- a/source/table_editor.pas +++ b/source/table_editor.pas @@ -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);