aboutsummaryrefslogtreecommitdiff
path: root/src/include/miscadmin.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-07-25 10:27:43 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-07-25 10:27:43 -0400
commit31ed3cf746a61538876c66a778ec8a372a3b4ffb (patch)
tree49ac7ab26ac88b9eca6408e7d231bd80875026d1 /src/include/miscadmin.h
parent19f82323db6312e0f2c4483dab95189c7f110648 (diff)
downloadpostgresql-31ed3cf746a61538876c66a778ec8a372a3b4ffb.tar.gz
postgresql-31ed3cf746a61538876c66a778ec8a372a3b4ffb.zip
Process session_preload_libraries within InitPostgres's transaction.
Previously we did this after InitPostgres, at a somewhat randomly chosen place within PostgresMain. However, since commit a0ffa885e doing this outside a transaction can cause a crash, if we need to check permissions while replacing a placeholder GUC. (Besides which, a preloaded library could itself want to do database access within _PG_init.) To avoid needing an additional transaction start/end in every session, move the process_session_preload_libraries call to within InitPostgres's transaction. That requires teaching the code not to call it when InitPostgres is called from somewhere other than PostgresMain, since we don't want session_preload_libraries to affect background workers. The most future-proof solution here seems to be to add an additional flag parameter to InitPostgres; fortunately, we're not yet very worried about API stability for v15. Doing this also exposed the fact that we're currently honoring session_preload_libraries in walsenders, even those not connected to any database. This seems, at minimum, a POLA violation: walsenders are not interactive sessions. Let's stop doing that. (All these comments also apply to local_preload_libraries, of course.) Per report from Gurjeet Singh (thanks also to Nathan Bossart and Kyotaro Horiguchi for review). Backpatch to v15 where a0ffa885e came in. Discussion: https://postgr.es/m/CABwTF4VEpwTHhRQ+q5MiC5ucngN-whN-PdcKeufX7eLSoAfbZA@mail.gmail.com
Diffstat (limited to 'src/include/miscadmin.h')
-rw-r--r--src/include/miscadmin.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 0af130fbc5d..3233278b340 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -457,8 +457,11 @@ extern PGDLLIMPORT AuxProcType MyAuxProcType;
/* in utils/init/postinit.c */
extern void pg_split_opts(char **argv, int *argcp, const char *optstr);
extern void InitializeMaxBackends(void);
-extern void InitPostgres(const char *in_dbname, Oid dboid, const char *username,
- Oid useroid, char *out_dbname, bool override_allow_connections);
+extern void InitPostgres(const char *in_dbname, Oid dboid,
+ const char *username, Oid useroid,
+ bool load_session_libraries,
+ bool override_allow_connections,
+ char *out_dbname);
extern void BaseInit(void);
/* in utils/init/miscinit.c */