Re: BackgroundWorkerInitializeConnection(NULL, ...) doesn't work

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Tipton <andrew(at)kiwidrew(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: BackgroundWorkerInitializeConnection(NULL, ...) doesn't work
Date: 2013-08-10 14:30:54
Message-ID: 13782.1376145054@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Tipton <andrew(at)kiwidrew(dot)com> writes:
> The documentation for 9.4 says, in the "Background Worker Processes"
> section:
> Once running, the process can connect to a database by calling
> BackgroundWorkerInitializeConnection(char *dbname, char *username). This
> allows the process to run transactions and queries using the SPI interface.
> If dbname is NULL, the session is not connected to any particular database,
> but shared catalogs can be accessed.

> Based on my quick read through InitPostgres() and postinit.c, it's not even
> clear that there's a way to access the shared catalogs without connecting
> to a specific database.

There is not, because you need e.g. pg_class and pg_attribute to be
available in order to open any relation whatsoever. So this documentation
is just wrong. A bg worker that chooses not to connect to a database
is shutting itself out of access to all relations.

There's been occasional talk of trying to refactor system catalogs into
separate shared and local components. The main motivation for that was
to reduce the bloat from having many copies of pg_proc etc, but it could
conceivably also make it practical for processes to run with only a
view of the shared catalogs. The work required seems far out of
proportion to these benefits, unfortunately ...

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-08-10 14:40:08 Re: BackgroundWorkerInitializeConnection(NULL, ...) doesn't work
Previous Message Alvaro Herrera 2013-08-10 14:30:24 Re: BackgroundWorkerInitializeConnection(NULL, ...) doesn't work