pgsql: Allow adjusting session_authorization and role in parallel worke

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow adjusting session_authorization and role in parallel worke
Date: 2024-08-10 19:52:16
Message-ID: E1scs8O-003c0h-CP@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow adjusting session_authorization and role in parallel workers.

The code intends to allow GUCs to be set within parallel workers
via function SET clauses, but not otherwise. However, doing so fails
for "session_authorization" and "role", because the assign hooks for
those attempt to set the subsidiary "is_superuser" GUC, and that call
falls foul of the "not otherwise" prohibition. We can't switch to
using GUC_ACTION_SAVE for this, so instead add a new GUC variable
flag GUC_ALLOW_IN_PARALLEL to mark is_superuser as being safe to set
anyway. (This is okay because is_superuser has context PGC_INTERNAL
and thus only hard-wired calls can change it. We'd need more thought
before applying the flag to other GUCs; but maybe there are other
use-cases.) This isn't the prettiest fix perhaps, but other
alternatives we thought of would be much more invasive.

While here, correct a thinko in commit 059de3ca4: when rejecting
a GUC setting within a parallel worker, we should return 0 not -1
if the ereport doesn't longjmp. (This seems to have no consequences
right now because no caller cares, but it's inconsistent.) Improve
the comments to try to forestall future confusion of the same kind.

Despite the lack of field complaints, this seems worth back-patching.
Thanks to Nathan Bossart for the idea to invent a new flag,
and for review.

Discussion: https://postgr.es/m/2833457.1723229039@sss.pgh.pa.us

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b8d33f66c134b5f1b0a94a7e40af2fbb6a086b7

Modified Files
--------------
src/backend/utils/misc/guc.c | 45 ++++++++++++++++-----------
src/backend/utils/misc/guc_tables.c | 2 +-
src/include/utils/guc.h | 1 +
src/test/regress/expected/select_parallel.out | 33 ++++++++++++++++++++
src/test/regress/sql/select_parallel.sql | 23 ++++++++++++++
5 files changed, 85 insertions(+), 19 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-08-11 16:25:07 pgsql: Suppress Coverity warnings about Asserts in get_name_for_var_fie
Previous Message Alexander Korotkov 2024-08-10 18:43:36 pgsql: Adjust pg_wal_replay_wait() procedure behavior on promoted stand