postgresql/src
Tom Lane b35617de37 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
2022-07-25 10:27:43 -04:00
..
backend Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
bin Remove dead handling for pre-POSIX sigwait(). 2022-07-24 09:32:34 +12:00
common Add output directory argument to generate-unicode_norm_table.pl 2022-07-18 12:24:39 -07:00
fe_utils Fix minor memory leaks in psql's tab completion. 2022-07-22 10:53:26 -04:00
include Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
interfaces Fix [install]check in interfaces/libpq/Makefile 2022-07-22 20:15:11 +02:00
makefiles Default to hidden visibility for extension libraries where possible 2022-07-17 17:49:51 -07:00
pl Add PGDLLEXPORTS to some plpgsql function declarations 2022-07-20 10:24:50 +02:00
port Remove dead getpwuid_r replacement code. 2022-07-24 09:44:29 +12:00
template Remove HP-UX port. 2022-07-08 14:05:05 +12:00
test Doc: update recovery/README. 2022-07-23 16:10:14 -04:00
timezone Update time zone data files to tzdata release 2022a. 2022-05-05 14:54:53 -04:00
tools Remove dead getpwuid_r replacement code. 2022-07-24 09:44:29 +12:00
tutorial Update copyright for 2022 2022-01-07 19:04:57 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Increase minimum supported GNU make version to 3.81. 2022-07-23 12:12:42 -04:00
Makefile.shlib Default to hidden visibility for extension libraries where possible 2022-07-17 17:49:51 -07:00
nls-global.mk Fix for make unportability 2022-07-13 09:15:01 +02:00