@@ -425,6 +425,7 @@ bool default_with_oids = false;
425425bool SQL_inheritance = true;
426426
427427bool Password_encryption = true;
428+ bool session_auth_is_superuser ;
428429
429430int log_min_error_statement = ERROR ;
430431int log_min_messages = WARNING ;
@@ -471,7 +472,6 @@ int huge_pages;
471472 * and is kept in sync by assign_hooks.
472473 */
473474static char * syslog_ident_str ;
474- static bool session_auth_is_superuser ;
475475static double phony_random_seed ;
476476static char * client_encoding_string ;
477477static char * datestyle_string ;
@@ -8884,12 +8884,18 @@ read_nondefault_variables(void)
88848884 * constants; a few, like server_encoding and lc_ctype, are handled specially
88858885 * outside the serialize/restore procedure. Therefore, SerializeGUCState()
88868886 * never sends these, and RestoreGUCState() never changes them.
8887+ *
8888+ * Role is a special variable in the sense that its current value can be an
8889+ * invalid value and there are multiple ways by which that can happen (like
8890+ * after setting the role, someone drops it). So we handle it outside of
8891+ * serialize/restore machinery.
88878892 */
88888893static bool
88898894can_skip_gucvar (struct config_generic * gconf )
88908895{
88918896 return gconf -> context == PGC_POSTMASTER ||
8892- gconf -> context == PGC_INTERNAL || gconf -> source == PGC_S_DEFAULT ;
8897+ gconf -> context == PGC_INTERNAL || gconf -> source == PGC_S_DEFAULT ||
8898+ strcmp (gconf -> name , "role" ) == 0 ;
88938899}
88948900
88958901/*
@@ -9150,27 +9156,14 @@ SerializeGUCState(Size maxsize, char *start_address)
91509156 Size actual_size ;
91519157 Size bytes_left ;
91529158 int i ;
9153- int i_role = -1 ;
91549159
91559160 /* Reserve space for saving the actual size of the guc state */
91569161 Assert (maxsize > sizeof (actual_size ));
91579162 curptr = start_address + sizeof (actual_size );
91589163 bytes_left = maxsize - sizeof (actual_size );
91599164
91609165 for (i = 0 ; i < num_guc_variables ; i ++ )
9161- {
9162- /*
9163- * It's pretty ugly, but we've got to force "role" to be initialized
9164- * after "session_authorization"; otherwise, the latter will override
9165- * the former.
9166- */
9167- if (strcmp (guc_variables [i ]-> name , "role" ) == 0 )
9168- i_role = i ;
9169- else
9170- serialize_variable (& curptr , & bytes_left , guc_variables [i ]);
9171- }
9172- if (i_role >= 0 )
9173- serialize_variable (& curptr , & bytes_left , guc_variables [i_role ]);
9166+ serialize_variable (& curptr , & bytes_left , guc_variables [i ]);
91749167
91759168 /* Store actual size without assuming alignment of start_address. */
91769169 actual_size = maxsize - bytes_left - sizeof (actual_size );
0 commit comments