Skip to content
Permalink
Browse files

Issue #802: filter away not owned databases only on Redshift servers.…

  • Loading branch information
ansgarbecker committed Nov 12, 2019
1 parent bcd19c3 commit 586b34cd08304520c94823f8cee49720627ac670
Showing with 10 additions and 4 deletions.
  1. +10 −4 source/dbconnection.pas
@@ -3621,17 +3621,23 @@ function TAdoDBConnection.GetAllDatabases: TStringList;


function TPGConnection.GetAllDatabases: TStringList;
var
DbQuery: String;
begin
// In PostgreSQL, we display schemata, not databases.
// The AllDatabasesStr is used to set the single database name
if not Assigned(FAllDatabases) then begin
try
// Query is.schemata when using schemata, for databases use pg_database
//FAllDatabases := GetCol('SELECT datname FROM pg_database WHERE datistemplate=FALSE');
FAllDatabases := GetCol('SELECT '+QuoteIdent('nspname')+
' FROM '+QuoteIdent('pg_catalog')+'.'+QuoteIdent('pg_namespace')+
' WHERE '+QuoteIdent('nspowner')+' != 1 OR '+QuoteIdent('nspname')+' IN ('+EscapeString('pg_catalog')+', '+EscapeString('information_schema')+')'+
' ORDER BY '+QuoteIdent('nspname'));
DbQuery := 'SELECT '+QuoteIdent('nspname')+
' FROM '+QuoteIdent('pg_catalog')+'.'+QuoteIdent('pg_namespace');
if Parameters.IsRedshift then begin
DbQuery := DbQuery + ' WHERE '+QuoteIdent('nspowner')+' != 1'+
' OR '+QuoteIdent('nspname')+' IN ('+EscapeString('pg_catalog')+', '+EscapeString('information_schema')+')';
end;
DbQuery := DbQuery + ' ORDER BY '+QuoteIdent('nspname');
FAllDatabases := GetCol(DbQuery);
except on E:EDbError do
FAllDatabases := TStringList.Create;
end;

0 comments on commit 586b34c

Please sign in to comment.
You can’t perform that action at this time.