Skip to content

Commit a434066

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

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
@@ -726,6 +726,7 @@ function TPostgreSQLProvider.GetSql(AId: TQueryId): string;
726726
' WHERE pg_class.relkind=''r'''+
727727
' AND pg_namespace.nspname=:EscapedDatabase'+
728728
' AND pg_class.relname=:EscapedName';
729+
qExplain: Result := 'EXPLAIN %s';
729730
qGetEnumTypes: Result := IfThen(
730731
FServerVersion >= 90000,
731732
'SELECT ' +

source/dbstructures.sqlite.pas

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

source/main.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6736,7 +6736,7 @@ procedure TMainForm.ValidateQueryControls(Sender: TObject);
67366736
actExecuteQuery.Enabled := HasConnection and InQueryTab and NotEmpty and (not Tab.QueryRunning);
67376737
actExecuteSelection.Enabled := HasConnection and InQueryTab and HasSelection and (not Tab.QueryRunning);
67386738
actExecuteCurrentQuery.Enabled := actExecuteQuery.Enabled;
6739-
actExplainCurrentQuery.Enabled := actExecuteQuery.Enabled and (Conn.Parameters.NetTypeGroup in [ngMySQL, ngPgSQL, ngSQLite]);
6739+
actExplainCurrentQuery.Enabled := actExecuteQuery.Enabled and Conn.SqlProvider.Has(qExplain);
67406740
actSaveSQLAs.Enabled := InQueryTab and NotEmpty;
67416741
actSaveSQL.Enabled := (actSaveSQLAs.Enabled and Tab.Memo.Modified) or InEditorTab;
67426742
actSaveSQLselection.Enabled := InQueryTab and HasSelection;
@@ -9303,7 +9303,7 @@ procedure TMainForm.ListProcessesFocusChanged(Sender: TBaseVirtualTree;
93039303

93049304
SynMemoProcessView.Enabled := EnableControls;
93059305
pnlProcessView.Enabled := EnableControls;
9306-
lblExplainProcess.Enabled := EnableControls and ActiveConnection.Parameters.IsAnyMySQL;
9306+
lblExplainProcess.Enabled := EnableControls and ActiveConnection.SqlProvider.Has(qExplain);
93079307
menuExplainProcess.Enabled := lblExplainProcess.Enabled;
93089308
end;
93099309

0 commit comments

Comments
 (0)