From 4800a5dfb4c46d22b5d05f16c615bea6ff24a2bb Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 11 Oct 2023 12:31:49 +0900 Subject: Refactor InitPostgres() to use bitwise option flags InitPostgres() has been using a set of boolean arguments to control its behavior, and a patch under discussion was aiming at expanding it with a third one. In preparation for expanding this area, this commit switches all the current boolean arguments of this routine to a single bits32 argument instead. Two values are currently supported for the flags: - INIT_PG_LOAD_SESSION_LIBS to load [session|local]_preload_libraries at startup. - INIT_PG_OVERRIDE_ALLOW_CONNS to allow connection to a database even if it has !datallowconn. This is used by bgworkers. Reviewed-by: Bertrand Drouvot Discussion: https://postgr.es/m/ZSTn66_BXRZCeaqS@paquier.xyz --- src/backend/tcop/postgres.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 21b9763183e..f3c9f1f9bab 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4206,11 +4206,12 @@ PostgresMain(const char *dbname, const char *username) * NOTE: if you are tempted to add code in this vicinity, consider putting * it inside InitPostgres() instead. In particular, anything that * involves database access should be there, not here. + * + * Honor session_preload_libraries if not dealing with a WAL sender. */ InitPostgres(dbname, InvalidOid, /* database to connect to */ username, InvalidOid, /* role to connect as */ - !am_walsender, /* honor session_preload_libraries? */ - false, /* don't ignore datallowconn */ + (!am_walsender) ? INIT_PG_LOAD_SESSION_LIBS : 0, NULL); /* no out_dbname */ /* -- cgit v1.2.3