Skip to content

Commit 2572681

Browse files
committed
fix: EXPLAIN <query> actions either disabled or non-working for PostgreSQL and SQLite
Refs #2540
1 parent bc8f903 commit 2572681

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

source/dbstructures.postgresql.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ function TPostgreSQLProvider.GetSql(AId: TQueryId): string;
728728
' WHERE pg_class.relkind=''r'''+
729729
' AND pg_namespace.nspname=:EscapedDatabase'+
730730
' AND pg_class.relname=:EscapedName';
731+
qExplain: Result := 'EXPLAIN %s';
731732
qGetEnumTypes: Result := IfThen(
732733
FServerVersion >= 90000,
733734
'SELECT ' +

source/dbstructures.sqlite.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ function TSQLiteProvider.GetSql(AId: TQueryId): string;
429429
qGetCharsets: Result := 'SELECT ''UTF-8'' AS "Charset", ''UTF-8'' AS "Description" '+
430430
'UNION SELECT ''UTF-16le'', ''UTF-16 Little Endian'' '+
431431
'UNION SELECT ''UTF-16be'', ''UTF-16 Big Endian''';
432+
qExplain: Result := 'EXPLAIN %s';
432433
qCastAsText: Result := 'CAST(%s AS CHAR)';
433434
else Result := inherited;
434435
end;

source/main.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6766,7 +6766,7 @@ procedure TMainForm.ValidateQueryControls(Sender: TObject);
67666766
actExecuteQuery.Enabled := HasConnection and InQueryTab and NotEmpty and (not Tab.QueryRunning);
67676767
actExecuteSelection.Enabled := HasConnection and InQueryTab and HasSelection and (not Tab.QueryRunning);
67686768
actExecuteCurrentQuery.Enabled := actExecuteQuery.Enabled;
6769-
actExplainCurrentQuery.Enabled := actExecuteQuery.Enabled and (Conn.Parameters.NetTypeGroup in [ngMySQL, ngPgSQL, ngSQLite]);
6769+
actExplainCurrentQuery.Enabled := actExecuteQuery.Enabled and Conn.SqlProvider.Has(qExplain);
67706770
actSaveSQLAs.Enabled := InQueryTab and NotEmpty;
67716771
actSaveSQL.Enabled := (actSaveSQLAs.Enabled and Tab.Memo.Modified) or InEditorTab;
67726772
actSaveSQLselection.Enabled := InQueryTab and HasSelection;
@@ -9140,7 +9140,7 @@ procedure TMainForm.ListProcessesFocusChanged(Sender: TBaseVirtualTree;
91409140

91419141
SynMemoProcessView.Enabled := EnableControls;
91429142
pnlProcessView.Enabled := EnableControls;
9143-
lblExplainProcess.Enabled := EnableControls and ActiveConnection.Parameters.IsAnyMySQL;
9143+
lblExplainProcess.Enabled := EnableControls and ActiveConnection.SqlProvider.Has(qExplain);
91449144
menuExplainProcess.Enabled := lblExplainProcess.Enabled;
91459145
end;
91469146

0 commit comments

Comments
 (0)