Skip to content

Commit 422935a

Browse files
committed
feat: support full table status option in SQLite, showing "Rows" from COUNT(*) for each table
closes #1803
1 parent 37add0f commit 422935a

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

source/connections.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ procedure Tconnform.ValidateControls;
16361636
lblQueryTimeout.Enabled := True;
16371637
editQueryTimeout.Enabled := lblQueryTimeout.Enabled;
16381638
chkLocalTimeZone.Enabled := Params.NetTypeGroup = ngMySQL;
1639-
chkFullTableStatus.Enabled := (Params.NetTypeGroup in [ngMySQL, ngPgSQL]) and (Params.NetType <> ntMySQL_ProxySQLAdmin);
1639+
chkFullTableStatus.Enabled := (Params.NetTypeGroup in [ngMySQL, ngPgSQL, ngSQLite]) and (Params.NetType <> ntMySQL_ProxySQLAdmin);
16401640
chkCleartextPluginEnabled.Enabled := Params.NetTypeGroup = ngMySQL;
16411641
editLogFilePath.Enabled := Params.LogFileDdl or Params.LogFileDml;
16421642

source/dbconnection.pas

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7563,6 +7563,7 @@ procedure TSQLiteConnection.FetchDbObjects(db: String; var Cache: TDBObjectList)
75637563
obj: TDBObject;
75647564
Results: TDBQuery;
75657565
TypeS: String;
7566+
UnionRowCount: TStringList;
75667567
begin
75677568
// Tables, views and procedures
75687569
Results := nil;
@@ -7593,6 +7594,34 @@ procedure TSQLiteConnection.FetchDbObjects(db: String; var Cache: TDBObjectList)
75937594
Results.Next;
75947595
end;
75957596
FreeAndNil(Results);
7597+
7598+
if FParameters.FullTableStatus then begin
7599+
UnionRowCount := TStringList.Create;
7600+
for obj in Cache do begin
7601+
if obj.NodeType <> lntTable then
7602+
Continue;
7603+
UnionRowCount.Add('SELECT '+EscapeString(obj.Name)+', COUNT(*) FROM '+QuoteIdent(obj.Database)+'.'+QuoteIdent(obj.Name));
7604+
end;
7605+
if UnionRowCount.Count > 0 then
7606+
try
7607+
Results := GetResults(Implode(' UNION ', UnionRowCount));
7608+
while not Results.Eof do begin
7609+
for obj in Cache do begin
7610+
if (obj.NodeType = lntTable) and (obj.Name = Results.Col(0)) then begin
7611+
obj.Rows := StrToInt64Def(Results.Col(1), -1);
7612+
obj.RowsAreExact := True;
7613+
break;
7614+
end;
7615+
end;
7616+
Results.Next;
7617+
end;
7618+
FreeAndNil(Results);
7619+
except
7620+
on E:EDbError do
7621+
Log(lcError, 'Full table status with row count not available in this database');
7622+
end;
7623+
UnionRowCount.Free;
7624+
end;
75967625
end;
75977626
end;
75987627

0 commit comments

Comments
 (0)