aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/guc.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-10-29 12:58:40 +0530
committerRobert Haas <rhaas@postgresql.org>2017-10-29 13:14:37 +0530
commitf74f871b80a13ef72b19e3d829a109f8df0df792 (patch)
tree4977690000538348b2192c1428659adb8a47d2fa /src/backend/utils/misc/guc.c
parent21daada10ebf444fb1fc06a705fb22b890867083 (diff)
downloadpostgresql-f74f871b80a13ef72b19e3d829a109f8df0df792.tar.gz
postgresql-f74f871b80a13ef72b19e3d829a109f8df0df792.zip
Fix problems with the "role" GUC and parallel query.
Without this fix, dropping a role can sometimes result in parallel query failures in sessions that have used "SET ROLE" to assume the dropped role, even if that setting isn't active any more. Report by Pavan Deolasee. Patch by Amit Kapila, reviewed by me. Discussion: http://postgr.es/m/CABOikdOomRcZsLsLK+Z+qENM1zxyaWnAvFh3MJZzZnnKiF+REg@mail.gmail.com
Diffstat (limited to 'src/backend/utils/misc/guc.c')
-rw-r--r--src/backend/utils/misc/guc.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 4f1891f8440..7b8e108982b 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -424,6 +424,7 @@ bool default_with_oids = false;
bool SQL_inheritance = true;
bool Password_encryption = true;
+bool session_auth_is_superuser;
int log_min_error_statement = ERROR;
int log_min_messages = WARNING;
@@ -470,7 +471,6 @@ int huge_pages;
* and is kept in sync by assign_hooks.
*/
static char *syslog_ident_str;
-static bool session_auth_is_superuser;
static double phony_random_seed;
static char *client_encoding_string;
static char *datestyle_string;
@@ -8873,12 +8873,18 @@ read_nondefault_variables(void)
* constants; a few, like server_encoding and lc_ctype, are handled specially
* outside the serialize/restore procedure. Therefore, SerializeGUCState()
* never sends these, and RestoreGUCState() never changes them.
+ *
+ * Role is a special variable in the sense that its current value can be an
+ * invalid value and there are multiple ways by which that can happen (like
+ * after setting the role, someone drops it). So we handle it outside of
+ * serialize/restore machinery.
*/
static bool
can_skip_gucvar(struct config_generic * gconf)
{
return gconf->context == PGC_POSTMASTER ||
- gconf->context == PGC_INTERNAL || gconf->source == PGC_S_DEFAULT;
+ gconf->context == PGC_INTERNAL || gconf->source == PGC_S_DEFAULT ||
+ strcmp(gconf->name, "role") == 0;
}
/*
@@ -9139,7 +9145,6 @@ SerializeGUCState(Size maxsize, char *start_address)
Size actual_size;
Size bytes_left;
int i;
- int i_role = -1;
/* Reserve space for saving the actual size of the guc state */
Assert(maxsize > sizeof(actual_size));
@@ -9147,19 +9152,7 @@ SerializeGUCState(Size maxsize, char *start_address)
bytes_left = maxsize - sizeof(actual_size);
for (i = 0; i < num_guc_variables; i++)
- {
- /*
- * It's pretty ugly, but we've got to force "role" to be initialized
- * after "session_authorization"; otherwise, the latter will override
- * the former.
- */
- if (strcmp(guc_variables[i]->name, "role") == 0)
- i_role = i;
- else
- serialize_variable(&curptr, &bytes_left, guc_variables[i]);
- }
- if (i_role >= 0)
- serialize_variable(&curptr, &bytes_left, guc_variables[i_role]);
+ serialize_variable(&curptr, &bytes_left, guc_variables[i]);
/* Store actual size without assuming alignment of start_address. */
actual_size = maxsize - bytes_left - sizeof(actual_size);