@@ -91,6 +91,7 @@ TTableKey = class(TPersistent)
9191 public
9292 Name , OldName: String;
9393 IndexType, OldIndexType, Algorithm, Comment: String;
94+ Size: Int64;
9495 Columns, SubParts, Collations: TStringList;
9596 Modified, Added, Visible: Boolean;
9697 constructor Create(AOwner: TDBConnection);
@@ -112,6 +113,7 @@ TTableKey = class(TPersistent)
112113 TTableKeyList = class (TObjectList<TTableKey>)
113114 public
114115 procedure Assign (Source: TTableKeyList);
116+ function MaxSize : Int64;
115117 end ;
116118 TKeyCache = TDictionary<String,TTableKeyList>;
117119
@@ -6016,6 +6018,7 @@ function TMySQLConnection.GetTableKeys(Table: TDBObject): TTableKeyList;
60166018var
60176019 KeyQuery, ColQuery: TDBQuery;
60186020 NewKey: TTableKey;
6021+ SizeQuery: String;
60196022begin
60206023 Result := TTableKeyList.Create(True);
60216024
@@ -6094,7 +6097,20 @@ function TMySQLConnection.GetTableKeys(Table: TDBObject): TTableKeyList;
60946097 NewKey.Visible := SameText(KeyQuery.Col(' Visible' ), ' yes' )
60956098 else if KeyQuery.ColumnExists(' Ignored' ) then // mariadb 10.6
60966099 NewKey.Visible := SameText(KeyQuery.Col(' Ignored' ), ' NO' );
6100+
6101+ if FSqlProvider.Has(qIndexSize) then begin
6102+ try
6103+ SizeQuery := FSqlProvider.GetSql(qIndexSize, [
6104+ EscapeString(Table.Database),
6105+ EscapeString(Table.Name ),
6106+ EscapeString(NewKey.Name )
6107+ ]);
6108+ NewKey.Size := StrToInt64Def(GetVar(SizeQuery), NewKey.Size);
6109+ except
6110+ end ;
6111+ end ;
60976112 end ;
6113+
60986114 if KeyQuery.ColumnExists(' Expression' ) and (not KeyQuery.IsNull(' Expression' )) then begin
60996115 // Functional key part: enclose expression within parentheses to distinguish them from columns (issue #1777)
61006116 NewKey.Columns.Add(' (' +KeyQuery.Col(' Expression' )+' )' );
@@ -10966,6 +10982,7 @@ constructor TTableKey.Create(AOwner: TDBConnection);
1096610982 Subparts.OnChange := Modification;
1096710983 Collations.OnChange := Modification;
1096810984 Visible := True;
10985+ Size := -1
1096910986end ;
1097010987
1097110988destructor TTableKey.Destroy;
@@ -10989,6 +11006,7 @@ procedure TTableKey.Assign(Source: TPersistent);
1098911006 Algorithm := s.Algorithm;
1099011007 Comment := s.Comment;
1099111008 Visible := s.Visible;
11009+ Size := s.Size;
1099211010 Columns.Assign(s.Columns);
1099311011 SubParts.Assign(s.SubParts);
1099411012 Collations.Assign(s.Collations);
@@ -11138,6 +11156,15 @@ procedure TTableKeyList.Assign(Source: TTableKeyList);
1113811156 end ;
1113911157end ;
1114011158
11159+ function TTableKeyList.MaxSize : Int64;
11160+ var
11161+ Item: TTableKey;
11162+ begin
11163+ Result := -1 ;
11164+ for Item in Self do begin
11165+ Result := Max(Result, Item.Size);
11166+ end ;
11167+ end ;
1114111168
1114211169
1114311170
0 commit comments