mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Add new function BackgroundWorkerInitializeConnectionByOid.
Sometimes it's useful for a background worker to be able to initialize its database connection by OID rather than by name, so provide a way to do that.
This commit is contained in:
@@ -146,14 +146,17 @@ typedef struct BackgroundWorker
|
||||
</para>
|
||||
|
||||
<para>Once running, the process can connect to a database by calling
|
||||
<function>BackgroundWorkerInitializeConnection(<parameter>char *dbname</parameter>, <parameter>char *username</parameter>)</function>.
|
||||
<function>BackgroundWorkerInitializeConnection(<parameter>char *dbname</parameter>, <parameter>char *username</parameter>)</function> or
|
||||
<function>BackgroundWorkerInitializeConnectionByOid(<parameter>Oid dboid</parameter>, <parameter>Oid useroid</parameter>)</function>.
|
||||
This allows the process to run transactions and queries using the
|
||||
<literal>SPI</literal> interface. If <varname>dbname</> is NULL,
|
||||
the session is not connected to any particular database, but shared catalogs
|
||||
can be accessed. If <varname>username</> is NULL, the process will run as
|
||||
the superuser created during <command>initdb</>.
|
||||
BackgroundWorkerInitializeConnection can only be called once per background
|
||||
process, it is not possible to switch databases.
|
||||
<literal>SPI</literal> interface. If <varname>dbname</> is NULL or
|
||||
<varname>dboid</> is <literal>InvalidOid</>, the session is not connected
|
||||
to any particular database, but shared catalogs can be accessed.
|
||||
If <varname>username</> is NULL or <varname>useroid</> is
|
||||
<literal>InvalidOid</>, the process will run as the superuser created
|
||||
during <command>initdb</>.
|
||||
A background worker can only call one of these two functions, and only
|
||||
once. It is not possible to switch databases.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
Reference in New Issue
Block a user