@@ -89,6 +89,7 @@ TTableKey = class(TPersistent)
8989 public
9090 Name , OldName: String;
9191 IndexType, OldIndexType, Algorithm, Comment: String;
92+ Size: Int64;
9293 Columns, SubParts, Collations: TStringList;
9394 Modified, Added, Visible: Boolean;
9495 constructor Create(AOwner: TDBConnection);
@@ -110,6 +111,7 @@ TTableKey = class(TPersistent)
110111 TTableKeyList = class (TObjectList<TTableKey>)
111112 public
112113 procedure Assign (Source: TTableKeyList);
114+ function MaxSize : Int64;
113115 end ;
114116 TKeyCache = TDictionary<String,TTableKeyList>;
115117
@@ -6174,6 +6176,7 @@ function TMySQLConnection.GetTableKeys(Table: TDBObject): TTableKeyList;
61746176var
61756177 KeyQuery, ColQuery: TDBQuery;
61766178 NewKey: TTableKey;
6179+ SizeQuery: String;
61776180begin
61786181 Result := TTableKeyList.Create(True);
61796182
@@ -6252,7 +6255,20 @@ function TMySQLConnection.GetTableKeys(Table: TDBObject): TTableKeyList;
62526255 NewKey.Visible := SameText(KeyQuery.Col(' Visible' ), ' yes' )
62536256 else if KeyQuery.ColumnExists(' Ignored' ) then // mariadb 10.6
62546257 NewKey.Visible := SameText(KeyQuery.Col(' Ignored' ), ' NO' );
6258+
6259+ if FSqlProvider.Has(qIndexSize) then begin
6260+ try
6261+ SizeQuery := FSqlProvider.GetSql(qIndexSize, [
6262+ EscapeString(Table.Database),
6263+ EscapeString(Table.Name ),
6264+ EscapeString(NewKey.Name )
6265+ ]);
6266+ NewKey.Size := StrToInt64Def(GetVar(SizeQuery), NewKey.Size);
6267+ except
6268+ end ;
6269+ end ;
62556270 end ;
6271+
62566272 if KeyQuery.ColumnExists(' Expression' ) and (not KeyQuery.IsNull(' Expression' )) then begin
62576273 // Functional key part: enclose expression within parentheses to distinguish them from columns (issue #1777)
62586274 NewKey.Columns.Add(' (' +KeyQuery.Col(' Expression' )+' )' );
@@ -11092,6 +11108,7 @@ constructor TTableKey.Create(AOwner: TDBConnection);
1109211108 Subparts.OnChange := Modification;
1109311109 Collations.OnChange := Modification;
1109411110 Visible := True;
11111+ Size := -1
1109511112end ;
1109611113
1109711114destructor TTableKey.Destroy;
@@ -11115,6 +11132,7 @@ procedure TTableKey.Assign(Source: TPersistent);
1111511132 Algorithm := s.Algorithm;
1111611133 Comment := s.Comment;
1111711134 Visible := s.Visible;
11135+ Size := s.Size;
1111811136 Columns.Assign(s.Columns);
1111911137 SubParts.Assign(s.SubParts);
1112011138 Collations.Assign(s.Collations);
@@ -11264,6 +11282,15 @@ procedure TTableKeyList.Assign(Source: TTableKeyList);
1126411282 end ;
1126511283end ;
1126611284
11285+ function TTableKeyList.MaxSize : Int64;
11286+ var
11287+ Item: TTableKey;
11288+ begin
11289+ Result := -1 ;
11290+ for Item in Self do begin
11291+ Result := Max(Result, Item.Size);
11292+ end ;
11293+ end ;
1126711294
1126811295
1126911296
0 commit comments