Skip to content

Commit

Permalink
Issue #802: filter away not owned databases only on Redshift servers.…
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarbecker committed Nov 12, 2019
1 parent bcd19c3 commit 586b34c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions source/dbconnection.pas
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3621,17 +3621,23 @@ function TAdoDBConnection.GetAllDatabases: TStringList;




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

0 comments on commit 586b34c

Please sign in to comment.