Re: Would a BGW need shmem_access or database_connection to enumerate databases? - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Would a BGW need shmem_access or database_connection to enumerate databases?
Date
Msg-id CAB7nPqTdi=J9HH8PPPiEOohebdd+xkgbbhdY7=VbGnZ3CkZXxA@mail.gmail.com
Whole thread Raw
In response to Would a BGW need shmem_access or database_connection to enumeratedatabases?  (Chapman Flack <chap@anastigmatix.net>)
Responses Re: Would a BGW need shmem_access or database_connection to enumeratedatabases?  (Chapman Flack <chap@anastigmatix.net>)
List pgsql-hackers
On Thu, Nov 30, 2017 at 7:48 AM, Chapman Flack <chap@anastigmatix.net> wrote:
> For the "master" one, what capabilities will it need to simply
> enumerate the current names of known databases? I suppose I could
> have it connect to the null dbname and query pg_database. Would
> that be the civilized way to do it, or am I missing a simpler way?

Yes. That's actually what the autovacuum launcher does. It connects
using InitPostgres(NULL, InvalidOid, NULL, NULL), and then scans
pg_database to fetch a list (see get_database_list).
-- 
Michael


pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] Refactoring identifier checks to consistently use strcmp
Next
From: Chapman Flack
Date:
Subject: Re: Would a BGW need shmem_access or database_connection to enumeratedatabases?