mirror of
https://github.com/postgres/postgres.git
synced 2025-05-15 19:15:29 +03:00
Allow background workers to connect to no particular database.
The documentation claims that this is supported, but it didn't actually work. Fix that. Reported by Pavel Stehule; patch by me.
This commit is contained in:
parent
834aa56ea1
commit
d66b67fe21
@ -779,7 +779,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
|||||||
/* take database name from the caller, just for paranoia */
|
/* take database name from the caller, just for paranoia */
|
||||||
strlcpy(dbname, in_dbname, sizeof(dbname));
|
strlcpy(dbname, in_dbname, sizeof(dbname));
|
||||||
}
|
}
|
||||||
else
|
else if (OidIsValid(dboid))
|
||||||
{
|
{
|
||||||
/* caller specified database by OID */
|
/* caller specified database by OID */
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
@ -799,6 +799,18 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
|||||||
if (out_dbname)
|
if (out_dbname)
|
||||||
strcpy(out_dbname, dbname);
|
strcpy(out_dbname, dbname);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* If this is a background worker not bound to any particular
|
||||||
|
* database, we're done now. Everything that follows only makes
|
||||||
|
* sense if we are bound to a specific database. We do need to
|
||||||
|
* close the transaction we started before returning.
|
||||||
|
*/
|
||||||
|
if (!bootstrap)
|
||||||
|
CommitTransactionCommand();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now, take a writer's lock on the database we are trying to connect to.
|
* Now, take a writer's lock on the database we are trying to connect to.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user