diff options
Diffstat (limited to 'src/backend/utils/misc/guc.c')
-rw-r--r-- | src/backend/utils/misc/guc.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 99854be4394..772fbc1b1a0 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4002,6 +4002,9 @@ set_config_with_handle(const char *name, config_handle *handle, case PGC_STRING: { struct config_string *conf = (struct config_string *) record; + GucContext orig_context = context; + GucSource orig_source = source; + Oid orig_srole = srole; #define newval (newval_union.stringval) @@ -4087,6 +4090,36 @@ set_config_with_handle(const char *name, config_handle *handle, set_guc_source(&conf->gen, source); conf->gen.scontext = context; conf->gen.srole = srole; + + /* + * Ugly hack: during SET session_authorization, forcibly + * do SET ROLE NONE with the same context/source/etc, so + * that the effects will have identical lifespan. This is + * required by the SQL spec, and it's not possible to do + * it within the variable's check hook or assign hook + * because our APIs for those don't pass enough info. + * However, don't do it if is_reload: in that case we + * expect that if "role" isn't supposed to be default, it + * has been or will be set by a separate reload action. + * + * A fine point: for RESET session_authorization, we do + * "RESET role" not "SET ROLE NONE" (by passing down NULL + * rather than "none" for the value). This would have the + * same effects in typical cases, but if the reset value + * of "role" is not "none" it seems better to revert to + * that. + */ + if (!is_reload && + strcmp(conf->gen.name, "session_authorization") == 0) + (void) set_config_with_handle("role", NULL, + value ? "none" : NULL, + orig_context, + orig_source, + orig_srole, + action, + true, + elevel, + false); } if (makeDefault) @@ -5788,12 +5821,6 @@ can_skip_gucvar(struct config_generic *gconf) * mechanisms (if indeed they aren't compile-time constants). So we may * always skip these. * - * Role must be handled specially because its current value can be an - * invalid value (for instance, if someone dropped the role since we set - * it). So if we tried to serialize it normally, we might get a failure. - * We skip it here, and use another mechanism to ensure the worker has the - * right value. - * * For all other GUCs, we skip if the GUC has its compiled-in default * value (i.e., source == PGC_S_DEFAULT). On the leader side, this means * we don't send GUCs that have their default values, which typically @@ -5802,8 +5829,8 @@ can_skip_gucvar(struct config_generic *gconf) * comments in RestoreGUCState for more info. */ return gconf->context == PGC_POSTMASTER || - gconf->context == PGC_INTERNAL || gconf->source == PGC_S_DEFAULT || - strcmp(gconf->name, "role") == 0; + gconf->context == PGC_INTERNAL || + gconf->source == PGC_S_DEFAULT; } /* |