Skip to content
Browse files

Expect COMMENT 'xxx' clause in index creation code, and store that co…

…mment in a new TTableKey.Comment field. Not yet visible per GUI, but at least such indexes are displayed now. Closes #732
  • Loading branch information...
ansgarbecker committed Aug 11, 2019
1 parent 9d732a0 commit f4443066a863602f945ad0dd8831d00df8a1eea8
Showing with 15 additions and 3 deletions.
  1. +15 −3 source/dbconnection.pas
@@ -123,7 +123,7 @@ TTableKey = class(TObject)
function GetImageIndex: Integer;
Name, OldName: String;
IndexType, OldIndexType, Algorithm: String;
IndexType, OldIndexType, Algorithm, Comment: String;
Columns, SubParts: TStringList;
Modified, Added: Boolean;
constructor Create(AOwner: TDBConnection);
@@ -5085,7 +5085,7 @@ function TPgConnection.ConnectionInfo: TStringList;

procedure TDBConnection.ParseTableStructure(CreateTable: String; Columns: TTableColumnList; Keys: TTableKeyList; ForeignKeys: TForeignKeyList);
ColSpec, Quotes: String;
ColSpec, Quotes, Tail: String;
rx, rxCol: TRegExpr;
i: Integer;
InLiteral: Boolean;
@@ -5271,7 +5271,15 @@ procedure TDBConnection.ParseTableStructure(CreateTable: String; Columns: TTable
// Detect keys
// 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+(['+Quotes+']?([^'+Quotes+']+)['+Quotes+']?\s+)?((USING|TYPE)\s+(\w+)\s+)?\((.+)\)(\s+USING\s+(\w+))?(\s+KEY_BLOCK_SIZE(\s|\=)+\d+)?,?$';
// KEY `idx_str` TYPE HASH (`str`) -- pre 5.0 syntax
// KEY `idx_str` (`str`) USING HASH COMMENT 'xxxxxxx'
rx.Expression := '^\s+((\w+)\s+)?KEY\s+(['+Quotes+']?([^'+Quotes+']+)['+Quotes+']?\s+)?'+
if rx.Exec(CreateTable) then while true do begin
if not Assigned(Keys) then
@@ -5301,6 +5309,10 @@ procedure TDBConnection.ParseTableStructure(CreateTable: String; Columns: TTable
Key.Columns[i] := StringReplace(Key.Columns[i], QuoteReplacement, FQuoteChar, [rfReplaceAll]);

Tail := rx.Match[13];
Key.Comment := ExtractLiteral(Tail, 'COMMENT');

if not rx.ExecNext then

0 comments on commit f444306

Please sign in to comment.
You can’t perform that action at this time.