diff options
| -rw-r--r-- | src/backend/utils/misc/gen_guc_tables.pl | 53 | ||||
| -rw-r--r-- | src/backend/utils/misc/guc.c | 847 | ||||
| -rw-r--r-- | src/backend/utils/misc/guc_funcs.c | 14 | ||||
| -rw-r--r-- | src/backend/utils/misc/help_config.c | 59 | ||||
| -rw-r--r-- | src/include/utils/guc_tables.h | 180 | ||||
| -rw-r--r-- | src/tools/pgindent/typedefs.list | 1 | 
6 files changed, 525 insertions, 629 deletions
diff --git a/src/backend/utils/misc/gen_guc_tables.pl b/src/backend/utils/misc/gen_guc_tables.pl index b187259bf1e..3efde02bab8 100644 --- a/src/backend/utils/misc/gen_guc_tables.pl +++ b/src/backend/utils/misc/gen_guc_tables.pl @@ -25,10 +25,7 @@ my $parse = Catalog::ParseData($input_fname);  open my $ofh, '>', $output_fname or die;  print_boilerplate($ofh, $output_fname, 'GUC tables'); -foreach my $type (qw(bool int real string enum)) -{ -	print_one_table($ofh, $type); -} +print_table($ofh);  close $ofh; @@ -41,56 +38,52 @@ sub dquote  	return q{"} . $s =~ s/"/\\"/gr . q{"};  } -# Print GUC table for one type. -sub print_one_table +# Print GUC table. +sub print_table  { -	my ($ofh, $type) = @_; -	my $Type = ucfirst $type; +	my ($ofh) = @_;  	print $ofh "\n\n"; -	print $ofh "struct config_${type} ConfigureNames${Type}[] =\n"; +	print $ofh "struct config_generic ConfigureNames[] =\n";  	print $ofh "{\n";  	foreach my $entry (@{$parse})  	{ -		next if $entry->{type} ne $type; -  		print $ofh "#ifdef $entry->{ifdef}\n" if $entry->{ifdef};  		print $ofh "\t{\n"; -		print $ofh "\t\t{\n"; -		printf $ofh "\t\t\t.name = %s,\n", dquote($entry->{name}); -		printf $ofh "\t\t\t.context = %s,\n", $entry->{context}; -		printf $ofh "\t\t\t.group = %s,\n", $entry->{group}; -		printf $ofh "\t\t\t.short_desc = gettext_noop(%s),\n", +		printf $ofh "\t\t.name = %s,\n", dquote($entry->{name}); +		printf $ofh "\t\t.context = %s,\n", $entry->{context}; +		printf $ofh "\t\t.group = %s,\n", $entry->{group}; +		printf $ofh "\t\t.short_desc = gettext_noop(%s),\n",  		  dquote($entry->{short_desc}); -		printf $ofh "\t\t\t.long_desc = gettext_noop(%s),\n", +		printf $ofh "\t\t.long_desc = gettext_noop(%s),\n",  		  dquote($entry->{long_desc})  		  if $entry->{long_desc}; -		printf $ofh "\t\t\t.flags = %s,\n", $entry->{flags} -		  if $entry->{flags}; -		printf $ofh "\t\t\t.vartype = %s,\n", ('PGC_' . uc($type)); -		print $ofh "\t\t},\n"; -		printf $ofh "\t\t.variable = &%s,\n", $entry->{variable}; -		printf $ofh "\t\t.boot_val = %s,\n", $entry->{boot_val}; -		printf $ofh "\t\t.min = %s,\n", $entry->{min} +		printf $ofh "\t\t.flags = %s,\n", $entry->{flags} if $entry->{flags}; +		printf $ofh "\t\t.vartype = %s,\n", ('PGC_' . uc($entry->{type})); +		printf $ofh "\t\t._%s = {\n", $entry->{type}; +		printf $ofh "\t\t\t.variable = &%s,\n", $entry->{variable}; +		printf $ofh "\t\t\t.boot_val = %s,\n", $entry->{boot_val}; +		printf $ofh "\t\t\t.min = %s,\n", $entry->{min}  		  if $entry->{type} eq 'int' || $entry->{type} eq 'real'; -		printf $ofh "\t\t.max = %s,\n", $entry->{max} +		printf $ofh "\t\t\t.max = %s,\n", $entry->{max}  		  if $entry->{type} eq 'int' || $entry->{type} eq 'real'; -		printf $ofh "\t\t.options = %s,\n", $entry->{options} +		printf $ofh "\t\t\t.options = %s,\n", $entry->{options}  		  if $entry->{type} eq 'enum'; -		printf $ofh "\t\t.check_hook = %s,\n", $entry->{check_hook} +		printf $ofh "\t\t\t.check_hook = %s,\n", $entry->{check_hook}  		  if $entry->{check_hook}; -		printf $ofh "\t\t.assign_hook = %s,\n", $entry->{assign_hook} +		printf $ofh "\t\t\t.assign_hook = %s,\n", $entry->{assign_hook}  		  if $entry->{assign_hook}; -		printf $ofh "\t\t.show_hook = %s,\n", $entry->{show_hook} +		printf $ofh "\t\t\t.show_hook = %s,\n", $entry->{show_hook}  		  if $entry->{show_hook}; +		print $ofh "\t\t},\n";  		print $ofh "\t},\n";  		print $ofh "#endif\n" if $entry->{ifdef};  		print $ofh "\n";  	}  	print $ofh "\t/* End-of-list marker */\n"; -	print $ofh "\t{{0}}\n"; +	print $ofh "\t{0}\n";  	print $ofh "};\n";  	return; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index a82286cc98a..679846da42c 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -245,12 +245,12 @@ static void ReportGUCOption(struct config_generic *record);  static void set_config_sourcefile(const char *name, char *sourcefile,  								  int sourceline);  static void reapply_stacked_values(struct config_generic *variable, -								   struct config_string *pHolder, +								   struct config_generic *pHolder,  								   GucStack *stack,  								   const char *curvalue,  								   GucContext curscontext, GucSource cursource,  								   Oid cursrole); -static void free_placeholder(struct config_string *pHolder); +static void free_placeholder(struct config_generic *pHolder);  static bool validate_option_array_item(const char *name, const char *value,  									   bool skipIfNoPermissions);  static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *head); @@ -261,15 +261,15 @@ static bool assignable_custom_variable_name(const char *name, bool skip_errors,  											int elevel);  static void do_serialize(char **destptr, Size *maxbytes,  						 const char *fmt,...) pg_attribute_printf(3, 4); -static bool call_bool_check_hook(const struct config_bool *conf, bool *newval, +static bool call_bool_check_hook(const struct config_generic *conf, bool *newval,  								 void **extra, GucSource source, int elevel); -static bool call_int_check_hook(const struct config_int *conf, int *newval, +static bool call_int_check_hook(const struct config_generic *conf, int *newval,  								void **extra, GucSource source, int elevel); -static bool call_real_check_hook(const struct config_real *conf, double *newval, +static bool call_real_check_hook(const struct config_generic *conf, double *newval,  								 void **extra, GucSource source, int elevel); -static bool call_string_check_hook(const struct config_string *conf, char **newval, +static bool call_string_check_hook(const struct config_generic *conf, char **newval,  								   void **extra, GucSource source, int elevel); -static bool call_enum_check_hook(const struct config_enum *conf, int *newval, +static bool call_enum_check_hook(const struct config_generic *conf, int *newval,  								 void **extra, GucSource source, int elevel); @@ -703,13 +703,13 @@ guc_free(void *ptr)   * Detect whether strval is referenced anywhere in a GUC string item   */  static bool -string_field_used(struct config_string *conf, char *strval) +string_field_used(struct config_generic *conf, char *strval)  { -	if (strval == *(conf->variable) || -		strval == conf->reset_val || -		strval == conf->boot_val) +	if (strval == *(conf->_string.variable) || +		strval == conf->_string.reset_val || +		strval == conf->_string.boot_val)  		return true; -	for (GucStack *stack = conf->gen.stack; stack; stack = stack->prev) +	for (GucStack *stack = conf->stack; stack; stack = stack->prev)  	{  		if (strval == stack->prior.val.stringval ||  			strval == stack->masked.val.stringval) @@ -724,7 +724,7 @@ string_field_used(struct config_string *conf, char *strval)   * states).   */  static void -set_string_field(struct config_string *conf, char **field, char *newval) +set_string_field(struct config_generic *conf, char **field, char *newval)  {  	char	   *oldval = *field; @@ -787,25 +787,19 @@ set_stack_value(struct config_generic *gconf, config_var_value *val)  	switch (gconf->vartype)  	{  		case PGC_BOOL: -			val->val.boolval = -				*((struct config_bool *) gconf)->variable; +			val->val.boolval = *gconf->_bool.variable;  			break;  		case PGC_INT: -			val->val.intval = -				*((struct config_int *) gconf)->variable; +			val->val.intval = *gconf->_int.variable;  			break;  		case PGC_REAL: -			val->val.realval = -				*((struct config_real *) gconf)->variable; +			val->val.realval = *gconf->_real.variable;  			break;  		case PGC_STRING: -			set_string_field((struct config_string *) gconf, -							 &(val->val.stringval), -							 *((struct config_string *) gconf)->variable); +			set_string_field(gconf, &(val->val.stringval), *gconf->_string.variable);  			break;  		case PGC_ENUM: -			val->val.enumval = -				*((struct config_enum *) gconf)->variable; +			val->val.enumval = *gconf->_enum.variable;  			break;  	}  	set_extra_field(gconf, &(val->extra), gconf->extra); @@ -827,7 +821,7 @@ discard_stack_value(struct config_generic *gconf, config_var_value *val)  			/* no need to do anything */  			break;  		case PGC_STRING: -			set_string_field((struct config_string *) gconf, +			set_string_field(gconf,  							 &(val->val.stringval),  							 NULL);  			break; @@ -892,19 +886,7 @@ build_guc_variables(void)  	/*  	 * Count all the built-in variables.  	 */ -	for (int i = 0; ConfigureNamesBool[i].gen.name; i++) -		num_vars++; - -	for (int i = 0; ConfigureNamesInt[i].gen.name; i++) -		num_vars++; - -	for (int i = 0; ConfigureNamesReal[i].gen.name; i++) -		num_vars++; - -	for (int i = 0; ConfigureNamesString[i].gen.name; i++) -		num_vars++; - -	for (int i = 0; ConfigureNamesEnum[i].gen.name; i++) +	for (int i = 0; ConfigureNames[i].name; i++)  		num_vars++;  	/* @@ -922,57 +904,9 @@ build_guc_variables(void)  							  &hash_ctl,  							  HASH_ELEM | HASH_FUNCTION | HASH_COMPARE | HASH_CONTEXT); -	for (int i = 0; ConfigureNamesBool[i].gen.name; i++) -	{ -		struct config_generic *gucvar = &ConfigureNamesBool[i].gen; - -		hentry = (GUCHashEntry *) hash_search(guc_hashtab, -											  &gucvar->name, -											  HASH_ENTER, -											  &found); -		Assert(!found); -		hentry->gucvar = gucvar; -	} - -	for (int i = 0; ConfigureNamesInt[i].gen.name; i++) -	{ -		struct config_generic *gucvar = &ConfigureNamesInt[i].gen; - -		hentry = (GUCHashEntry *) hash_search(guc_hashtab, -											  &gucvar->name, -											  HASH_ENTER, -											  &found); -		Assert(!found); -		hentry->gucvar = gucvar; -	} - -	for (int i = 0; ConfigureNamesReal[i].gen.name; i++) -	{ -		struct config_generic *gucvar = &ConfigureNamesReal[i].gen; - -		hentry = (GUCHashEntry *) hash_search(guc_hashtab, -											  &gucvar->name, -											  HASH_ENTER, -											  &found); -		Assert(!found); -		hentry->gucvar = gucvar; -	} - -	for (int i = 0; ConfigureNamesString[i].gen.name; i++) -	{ -		struct config_generic *gucvar = &ConfigureNamesString[i].gen; - -		hentry = (GUCHashEntry *) hash_search(guc_hashtab, -											  &gucvar->name, -											  HASH_ENTER, -											  &found); -		Assert(!found); -		hentry->gucvar = gucvar; -	} - -	for (int i = 0; ConfigureNamesEnum[i].gen.name; i++) +	for (int i = 0; ConfigureNames[i].name; i++)  	{ -		struct config_generic *gucvar = &ConfigureNamesEnum[i].gen; +		struct config_generic *gucvar = &ConfigureNames[i];  		hentry = (GUCHashEntry *) hash_search(guc_hashtab,  											  &gucvar->name, @@ -1122,44 +1056,42 @@ assignable_custom_variable_name(const char *name, bool skip_errors, int elevel)  static struct config_generic *  add_placeholder_variable(const char *name, int elevel)  { -	size_t		sz = sizeof(struct config_string) + sizeof(char *); -	struct config_string *var; -	struct config_generic *gen; +	size_t		sz = sizeof(struct config_generic) + sizeof(char *); +	struct config_generic *var; -	var = (struct config_string *) guc_malloc(elevel, sz); +	var = (struct config_generic *) guc_malloc(elevel, sz);  	if (var == NULL)  		return NULL;  	memset(var, 0, sz); -	gen = &var->gen; -	gen->name = guc_strdup(elevel, name); -	if (gen->name == NULL) +	var->name = guc_strdup(elevel, name); +	if (var->name == NULL)  	{  		guc_free(var);  		return NULL;  	} -	gen->context = PGC_USERSET; -	gen->group = CUSTOM_OPTIONS; -	gen->short_desc = "GUC placeholder variable"; -	gen->flags = GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_CUSTOM_PLACEHOLDER; -	gen->vartype = PGC_STRING; +	var->context = PGC_USERSET; +	var->group = CUSTOM_OPTIONS; +	var->short_desc = "GUC placeholder variable"; +	var->flags = GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_CUSTOM_PLACEHOLDER; +	var->vartype = PGC_STRING;  	/*  	 * The char* is allocated at the end of the struct since we have no  	 * 'static' place to point to.  Note that the current value, as well as  	 * the boot and reset values, start out NULL.  	 */ -	var->variable = (char **) (var + 1); +	var->_string.variable = (char **) (var + 1); -	if (!add_guc_variable((struct config_generic *) var, elevel)) +	if (!add_guc_variable(var, elevel))  	{ -		guc_free(unconstify(char *, gen->name)); +		guc_free(unconstify(char *, var->name));  		guc_free(var);  		return NULL;  	} -	return gen; +	return var;  }  /* @@ -1385,62 +1317,62 @@ check_GUC_init(const struct config_generic *gconf)  	{  		case PGC_BOOL:  			{ -				const struct config_bool *conf = (const struct config_bool *) gconf; +				const struct config_bool *conf = &gconf->_bool;  				if (*conf->variable && !conf->boot_val)  				{  					elog(LOG, "GUC (PGC_BOOL) %s, boot_val=%d, C-var=%d", -						 conf->gen.name, conf->boot_val, *conf->variable); +						 gconf->name, conf->boot_val, *conf->variable);  					return false;  				}  				break;  			}  		case PGC_INT:  			{ -				const struct config_int *conf = (const struct config_int *) gconf; +				const struct config_int *conf = &gconf->_int;  				if (*conf->variable != 0 && *conf->variable != conf->boot_val)  				{  					elog(LOG, "GUC (PGC_INT) %s, boot_val=%d, C-var=%d", -						 conf->gen.name, conf->boot_val, *conf->variable); +						 gconf->name, conf->boot_val, *conf->variable);  					return false;  				}  				break;  			}  		case PGC_REAL:  			{ -				const struct config_real *conf = (const struct config_real *) gconf; +				const struct config_real *conf = &gconf->_real;  				if (*conf->variable != 0.0 && *conf->variable != conf->boot_val)  				{  					elog(LOG, "GUC (PGC_REAL) %s, boot_val=%g, C-var=%g", -						 conf->gen.name, conf->boot_val, *conf->variable); +						 gconf->name, conf->boot_val, *conf->variable);  					return false;  				}  				break;  			}  		case PGC_STRING:  			{ -				const struct config_string *conf = (const struct config_string *) gconf; +				const struct config_string *conf = &gconf->_string;  				if (*conf->variable != NULL &&  					(conf->boot_val == NULL ||  					 strcmp(*conf->variable, conf->boot_val) != 0))  				{  					elog(LOG, "GUC (PGC_STRING) %s, boot_val=%s, C-var=%s", -						 conf->gen.name, conf->boot_val ? conf->boot_val : "<null>", *conf->variable); +						 gconf->name, conf->boot_val ? conf->boot_val : "<null>", *conf->variable);  					return false;  				}  				break;  			}  		case PGC_ENUM:  			{ -				const struct config_enum *conf = (const struct config_enum *) gconf; +				const struct config_enum *conf = &gconf->_enum;  				if (*conf->variable != conf->boot_val)  				{  					elog(LOG, "GUC (PGC_ENUM) %s, boot_val=%d, C-var=%d", -						 conf->gen.name, conf->boot_val, *conf->variable); +						 gconf->name, conf->boot_val, *conf->variable);  					return false;  				}  				break; @@ -1607,13 +1539,13 @@ InitializeOneGUCOption(struct config_generic *gconf)  	{  		case PGC_BOOL:  			{ -				struct config_bool *conf = (struct config_bool *) gconf; +				struct config_bool *conf = &gconf->_bool;  				bool		newval = conf->boot_val; -				if (!call_bool_check_hook(conf, &newval, &extra, +				if (!call_bool_check_hook(gconf, &newval, &extra,  										  PGC_S_DEFAULT, LOG))  					elog(FATAL, "failed to initialize %s to %d", -						 conf->gen.name, (int) newval); +						 gconf->name, (int) newval);  				if (conf->assign_hook)  					conf->assign_hook(newval, extra);  				*conf->variable = conf->reset_val = newval; @@ -1621,15 +1553,15 @@ InitializeOneGUCOption(struct config_generic *gconf)  			}  		case PGC_INT:  			{ -				struct config_int *conf = (struct config_int *) gconf; +				struct config_int *conf = &gconf->_int;  				int			newval = conf->boot_val;  				Assert(newval >= conf->min);  				Assert(newval <= conf->max); -				if (!call_int_check_hook(conf, &newval, &extra, +				if (!call_int_check_hook(gconf, &newval, &extra,  										 PGC_S_DEFAULT, LOG))  					elog(FATAL, "failed to initialize %s to %d", -						 conf->gen.name, newval); +						 gconf->name, newval);  				if (conf->assign_hook)  					conf->assign_hook(newval, extra);  				*conf->variable = conf->reset_val = newval; @@ -1637,15 +1569,15 @@ InitializeOneGUCOption(struct config_generic *gconf)  			}  		case PGC_REAL:  			{ -				struct config_real *conf = (struct config_real *) gconf; +				struct config_real *conf = &gconf->_real;  				double		newval = conf->boot_val;  				Assert(newval >= conf->min);  				Assert(newval <= conf->max); -				if (!call_real_check_hook(conf, &newval, &extra, +				if (!call_real_check_hook(gconf, &newval, &extra,  										  PGC_S_DEFAULT, LOG))  					elog(FATAL, "failed to initialize %s to %g", -						 conf->gen.name, newval); +						 gconf->name, newval);  				if (conf->assign_hook)  					conf->assign_hook(newval, extra);  				*conf->variable = conf->reset_val = newval; @@ -1653,7 +1585,7 @@ InitializeOneGUCOption(struct config_generic *gconf)  			}  		case PGC_STRING:  			{ -				struct config_string *conf = (struct config_string *) gconf; +				struct config_string *conf = &gconf->_string;  				char	   *newval;  				/* non-NULL boot_val must always get strdup'd */ @@ -1662,10 +1594,10 @@ InitializeOneGUCOption(struct config_generic *gconf)  				else  					newval = NULL; -				if (!call_string_check_hook(conf, &newval, &extra, +				if (!call_string_check_hook(gconf, &newval, &extra,  											PGC_S_DEFAULT, LOG))  					elog(FATAL, "failed to initialize %s to \"%s\"", -						 conf->gen.name, newval ? newval : ""); +						 gconf->name, newval ? newval : "");  				if (conf->assign_hook)  					conf->assign_hook(newval, extra);  				*conf->variable = conf->reset_val = newval; @@ -1673,13 +1605,13 @@ InitializeOneGUCOption(struct config_generic *gconf)  			}  		case PGC_ENUM:  			{ -				struct config_enum *conf = (struct config_enum *) gconf; +				struct config_enum *conf = &gconf->_enum;  				int			newval = conf->boot_val; -				if (!call_enum_check_hook(conf, &newval, &extra, +				if (!call_enum_check_hook(gconf, &newval, &extra,  										  PGC_S_DEFAULT, LOG))  					elog(FATAL, "failed to initialize %s to %d", -						 conf->gen.name, newval); +						 gconf->name, newval);  				if (conf->assign_hook)  					conf->assign_hook(newval, extra);  				*conf->variable = conf->reset_val = newval; @@ -1726,7 +1658,7 @@ SelectConfigFiles(const char *userDoption, const char *progname)  	char	   *fname;  	bool		fname_is_malloced;  	struct stat stat_buf; -	struct config_string *data_directory_rec; +	struct config_generic *data_directory_rec;  	/* configdir is -D option, or $PGDATA if no -D */  	if (userDoption) @@ -1806,10 +1738,10 @@ SelectConfigFiles(const char *userDoption, const char *progname)  	 * Note: SetDataDir will copy and absolute-ize its argument, so we don't  	 * have to.  	 */ -	data_directory_rec = (struct config_string *) +	data_directory_rec =  		find_option("data_directory", false, false, PANIC); -	if (*data_directory_rec->variable) -		SetDataDir(*data_directory_rec->variable); +	if (*data_directory_rec->_string.variable) +		SetDataDir(*data_directory_rec->_string.variable);  	else if (configdir)  		SetDataDir(configdir);  	else @@ -1971,62 +1903,62 @@ ResetAllOptions(void)  		{  			case PGC_BOOL:  				{ -					struct config_bool *conf = (struct config_bool *) gconf; +					struct config_bool *conf = &gconf->_bool;  					if (conf->assign_hook)  						conf->assign_hook(conf->reset_val, -										  conf->gen.reset_extra); +										  gconf->reset_extra);  					*conf->variable = conf->reset_val; -					set_extra_field(&conf->gen, &conf->gen.extra, -									conf->gen.reset_extra); +					set_extra_field(gconf, &gconf->extra, +									gconf->reset_extra);  					break;  				}  			case PGC_INT:  				{ -					struct config_int *conf = (struct config_int *) gconf; +					struct config_int *conf = &gconf->_int;  					if (conf->assign_hook)  						conf->assign_hook(conf->reset_val, -										  conf->gen.reset_extra); +										  gconf->reset_extra);  					*conf->variable = conf->reset_val; -					set_extra_field(&conf->gen, &conf->gen.extra, -									conf->gen.reset_extra); +					set_extra_field(gconf, &gconf->extra, +									gconf->reset_extra);  					break;  				}  			case PGC_REAL:  				{ -					struct config_real *conf = (struct config_real *) gconf; +					struct config_real *conf = &gconf->_real;  					if (conf->assign_hook)  						conf->assign_hook(conf->reset_val, -										  conf->gen.reset_extra); +										  gconf->reset_extra);  					*conf->variable = conf->reset_val; -					set_extra_field(&conf->gen, &conf->gen.extra, -									conf->gen.reset_extra); +					set_extra_field(gconf, &gconf->extra, +									gconf->reset_extra);  					break;  				}  			case PGC_STRING:  				{ -					struct config_string *conf = (struct config_string *) gconf; +					struct config_string *conf = &gconf->_string;  					if (conf->assign_hook)  						conf->assign_hook(conf->reset_val, -										  conf->gen.reset_extra); -					set_string_field(conf, conf->variable, conf->reset_val); -					set_extra_field(&conf->gen, &conf->gen.extra, -									conf->gen.reset_extra); +										  gconf->reset_extra); +					set_string_field(gconf, conf->variable, conf->reset_val); +					set_extra_field(gconf, &gconf->extra, +									gconf->reset_extra);  					break;  				}  			case PGC_ENUM:  				{ -					struct config_enum *conf = (struct config_enum *) gconf; +					struct config_enum *conf = &gconf->_enum;  					if (conf->assign_hook)  						conf->assign_hook(conf->reset_val, -										  conf->gen.reset_extra); +										  gconf->reset_extra);  					*conf->variable = conf->reset_val; -					set_extra_field(&conf->gen, &conf->gen.extra, -									conf->gen.reset_extra); +					set_extra_field(gconf, &gconf->extra, +									gconf->reset_extra);  					break;  				}  		} @@ -2346,17 +2278,17 @@ AtEOXact_GUC(bool isCommit, int nestLevel)  				{  					case PGC_BOOL:  						{ -							struct config_bool *conf = (struct config_bool *) gconf; +							struct config_bool *conf = &gconf->_bool;  							bool		newval = newvalue.val.boolval;  							void	   *newextra = newvalue.extra;  							if (*conf->variable != newval || -								conf->gen.extra != newextra) +								gconf->extra != newextra)  							{  								if (conf->assign_hook)  									conf->assign_hook(newval, newextra);  								*conf->variable = newval; -								set_extra_field(&conf->gen, &conf->gen.extra, +								set_extra_field(gconf, &gconf->extra,  												newextra);  								changed = true;  							} @@ -2364,17 +2296,17 @@ AtEOXact_GUC(bool isCommit, int nestLevel)  						}  					case PGC_INT:  						{ -							struct config_int *conf = (struct config_int *) gconf; +							struct config_int *conf = &gconf->_int;  							int			newval = newvalue.val.intval;  							void	   *newextra = newvalue.extra;  							if (*conf->variable != newval || -								conf->gen.extra != newextra) +								gconf->extra != newextra)  							{  								if (conf->assign_hook)  									conf->assign_hook(newval, newextra);  								*conf->variable = newval; -								set_extra_field(&conf->gen, &conf->gen.extra, +								set_extra_field(gconf, &gconf->extra,  												newextra);  								changed = true;  							} @@ -2382,17 +2314,17 @@ AtEOXact_GUC(bool isCommit, int nestLevel)  						}  					case PGC_REAL:  						{ -							struct config_real *conf = (struct config_real *) gconf; +							struct config_real *conf = &gconf->_real;  							double		newval = newvalue.val.realval;  							void	   *newextra = newvalue.extra;  							if (*conf->variable != newval || -								conf->gen.extra != newextra) +								gconf->extra != newextra)  							{  								if (conf->assign_hook)  									conf->assign_hook(newval, newextra);  								*conf->variable = newval; -								set_extra_field(&conf->gen, &conf->gen.extra, +								set_extra_field(gconf, &gconf->extra,  												newextra);  								changed = true;  							} @@ -2400,17 +2332,17 @@ AtEOXact_GUC(bool isCommit, int nestLevel)  						}  					case PGC_STRING:  						{ -							struct config_string *conf = (struct config_string *) gconf; +							struct config_string *conf = &gconf->_string;  							char	   *newval = newvalue.val.stringval;  							void	   *newextra = newvalue.extra;  							if (*conf->variable != newval || -								conf->gen.extra != newextra) +								gconf->extra != newextra)  							{  								if (conf->assign_hook)  									conf->assign_hook(newval, newextra); -								set_string_field(conf, conf->variable, newval); -								set_extra_field(&conf->gen, &conf->gen.extra, +								set_string_field(gconf, conf->variable, newval); +								set_extra_field(gconf, &gconf->extra,  												newextra);  								changed = true;  							} @@ -2421,23 +2353,23 @@ AtEOXact_GUC(bool isCommit, int nestLevel)  							 * we have type-specific code anyway, might as  							 * well inline it.  							 */ -							set_string_field(conf, &stack->prior.val.stringval, NULL); -							set_string_field(conf, &stack->masked.val.stringval, NULL); +							set_string_field(gconf, &stack->prior.val.stringval, NULL); +							set_string_field(gconf, &stack->masked.val.stringval, NULL);  							break;  						}  					case PGC_ENUM:  						{ -							struct config_enum *conf = (struct config_enum *) gconf; +							struct config_enum *conf = &gconf->_enum;  							int			newval = newvalue.val.enumval;  							void	   *newextra = newvalue.extra;  							if (*conf->variable != newval || -								conf->gen.extra != newextra) +								gconf->extra != newextra)  							{  								if (conf->assign_hook)  									conf->assign_hook(newval, newextra);  								*conf->variable = newval; -								set_extra_field(&conf->gen, &conf->gen.extra, +								set_extra_field(gconf, &gconf->extra,  												newextra);  								changed = true;  							} @@ -2960,16 +2892,16 @@ parse_real(const char *value, double *result, int flags, const char **hintmsg)   * allocated for modification.   */  const char * -config_enum_lookup_by_value(const struct config_enum *record, int val) +config_enum_lookup_by_value(const struct config_generic *record, int val)  { -	for (const struct config_enum_entry *entry = record->options; entry && entry->name; entry++) +	for (const struct config_enum_entry *entry = record->_enum.options; entry && entry->name; entry++)  	{  		if (entry->val == val)  			return entry->name;  	}  	elog(ERROR, "could not find enum option %d for %s", -		 val, record->gen.name); +		 val, record->name);  	return NULL;				/* silence compiler */  } @@ -3070,41 +3002,39 @@ parse_and_validate_value(const struct config_generic *record,  	{  		case PGC_BOOL:  			{ -				const struct config_bool *conf = (const struct config_bool *) record; -  				if (!parse_bool(value, &newval->boolval))  				{  					ereport(elevel,  							(errcode(ERRCODE_INVALID_PARAMETER_VALUE),  							 errmsg("parameter \"%s\" requires a Boolean value", -									conf->gen.name))); +									record->name)));  					return false;  				} -				if (!call_bool_check_hook(conf, &newval->boolval, newextra, +				if (!call_bool_check_hook(record, &newval->boolval, newextra,  										  source, elevel))  					return false;  			}  			break;  		case PGC_INT:  			{ -				const struct config_int *conf = (const struct config_int *) record; +				const struct config_int *conf = &record->_int;  				const char *hintmsg;  				if (!parse_int(value, &newval->intval, -							   conf->gen.flags, &hintmsg)) +							   record->flags, &hintmsg))  				{  					ereport(elevel,  							(errcode(ERRCODE_INVALID_PARAMETER_VALUE),  							 errmsg("invalid value for parameter \"%s\": \"%s\"", -									conf->gen.name, value), +									record->name, value),  							 hintmsg ? errhint("%s", _(hintmsg)) : 0));  					return false;  				}  				if (newval->intval < conf->min || newval->intval > conf->max)  				{ -					const char *unit = get_config_unit_name(conf->gen.flags); +					const char *unit = get_config_unit_name(record->flags);  					const char *unitspace;  					if (unit) @@ -3116,36 +3046,36 @@ parse_and_validate_value(const struct config_generic *record,  							(errcode(ERRCODE_INVALID_PARAMETER_VALUE),  							 errmsg("%d%s%s is outside the valid range for parameter \"%s\" (%d%s%s .. %d%s%s)",  									newval->intval, unitspace, unit, -									conf->gen.name, +									record->name,  									conf->min, unitspace, unit,  									conf->max, unitspace, unit)));  					return false;  				} -				if (!call_int_check_hook(conf, &newval->intval, newextra, +				if (!call_int_check_hook(record, &newval->intval, newextra,  										 source, elevel))  					return false;  			}  			break;  		case PGC_REAL:  			{ -				const struct config_real *conf = (const struct config_real *) record; +				const struct config_real *conf = &record->_real;  				const char *hintmsg;  				if (!parse_real(value, &newval->realval, -								conf->gen.flags, &hintmsg)) +								record->flags, &hintmsg))  				{  					ereport(elevel,  							(errcode(ERRCODE_INVALID_PARAMETER_VALUE),  							 errmsg("invalid value for parameter \"%s\": \"%s\"", -									conf->gen.name, value), +									record->name, value),  							 hintmsg ? errhint("%s", _(hintmsg)) : 0));  					return false;  				}  				if (newval->realval < conf->min || newval->realval > conf->max)  				{ -					const char *unit = get_config_unit_name(conf->gen.flags); +					const char *unit = get_config_unit_name(record->flags);  					const char *unitspace;  					if (unit) @@ -3157,21 +3087,19 @@ parse_and_validate_value(const struct config_generic *record,  							(errcode(ERRCODE_INVALID_PARAMETER_VALUE),  							 errmsg("%g%s%s is outside the valid range for parameter \"%s\" (%g%s%s .. %g%s%s)",  									newval->realval, unitspace, unit, -									conf->gen.name, +									record->name,  									conf->min, unitspace, unit,  									conf->max, unitspace, unit)));  					return false;  				} -				if (!call_real_check_hook(conf, &newval->realval, newextra, +				if (!call_real_check_hook(record, &newval->realval, newextra,  										  source, elevel))  					return false;  			}  			break;  		case PGC_STRING:  			{ -				const struct config_string *conf = (const struct config_string *) record; -  				/*  				 * The value passed by the caller could be transient, so we  				 * always strdup it. @@ -3184,12 +3112,12 @@ parse_and_validate_value(const struct config_generic *record,  				 * The only built-in "parsing" check we have is to apply  				 * truncation if GUC_IS_NAME.  				 */ -				if (conf->gen.flags & GUC_IS_NAME) +				if (record->flags & GUC_IS_NAME)  					truncate_identifier(newval->stringval,  										strlen(newval->stringval),  										true); -				if (!call_string_check_hook(conf, &newval->stringval, newextra, +				if (!call_string_check_hook(record, &newval->stringval, newextra,  											source, elevel))  				{  					guc_free(newval->stringval); @@ -3200,7 +3128,7 @@ parse_and_validate_value(const struct config_generic *record,  			break;  		case PGC_ENUM:  			{ -				const struct config_enum *conf = (const struct config_enum *) record; +				const struct config_enum *conf = &record->_enum;  				if (!config_enum_lookup_by_name(conf, value, &newval->enumval))  				{ @@ -3213,7 +3141,7 @@ parse_and_validate_value(const struct config_generic *record,  					ereport(elevel,  							(errcode(ERRCODE_INVALID_PARAMETER_VALUE),  							 errmsg("invalid value for parameter \"%s\": \"%s\"", -									conf->gen.name, value), +									record->name, value),  							 hintmsg ? errhint("%s", _(hintmsg)) : 0));  					if (hintmsg) @@ -3221,7 +3149,7 @@ parse_and_validate_value(const struct config_generic *record,  					return false;  				} -				if (!call_enum_check_hook(conf, &newval->enumval, newextra, +				if (!call_enum_check_hook(record, &newval->enumval, newextra,  										  source, elevel))  					return false;  			} @@ -3639,7 +3567,7 @@ set_config_with_handle(const char *name, config_handle *handle,  	{  		case PGC_BOOL:  			{ -				struct config_bool *conf = (struct config_bool *) record; +				struct config_bool *conf = &record->_bool;  #define newval (newval_union.boolval) @@ -3653,23 +3581,23 @@ set_config_with_handle(const char *name, config_handle *handle,  				else if (source == PGC_S_DEFAULT)  				{  					newval = conf->boot_val; -					if (!call_bool_check_hook(conf, &newval, &newextra, +					if (!call_bool_check_hook(record, &newval, &newextra,  											  source, elevel))  						return 0;  				}  				else  				{  					newval = conf->reset_val; -					newextra = conf->gen.reset_extra; -					source = conf->gen.reset_source; -					context = conf->gen.reset_scontext; -					srole = conf->gen.reset_srole; +					newextra = record->reset_extra; +					source = record->reset_source; +					context = record->reset_scontext; +					srole = record->reset_srole;  				}  				if (prohibitValueChange)  				{  					/* Release newextra, unless it's reset_extra */ -					if (newextra && !extra_field_used(&conf->gen, newextra)) +					if (newextra && !extra_field_used(record, newextra))  						guc_free(newextra);  					if (*conf->variable != newval) @@ -3678,7 +3606,7 @@ set_config_with_handle(const char *name, config_handle *handle,  						ereport(elevel,  								(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),  								 errmsg("parameter \"%s\" cannot be changed without restarting the server", -										conf->gen.name))); +										record->name)));  						return 0;  					}  					record->status &= ~GUC_PENDING_RESTART; @@ -3689,34 +3617,34 @@ set_config_with_handle(const char *name, config_handle *handle,  				{  					/* Save old value to support transaction abort */  					if (!makeDefault) -						push_old_value(&conf->gen, action); +						push_old_value(record, action);  					if (conf->assign_hook)  						conf->assign_hook(newval, newextra);  					*conf->variable = newval; -					set_extra_field(&conf->gen, &conf->gen.extra, +					set_extra_field(record, &record->extra,  									newextra); -					set_guc_source(&conf->gen, source); -					conf->gen.scontext = context; -					conf->gen.srole = srole; +					set_guc_source(record, source); +					record->scontext = context; +					record->srole = srole;  				}  				if (makeDefault)  				{ -					if (conf->gen.reset_source <= source) +					if (record->reset_source <= source)  					{  						conf->reset_val = newval; -						set_extra_field(&conf->gen, &conf->gen.reset_extra, +						set_extra_field(record, &record->reset_extra,  										newextra); -						conf->gen.reset_source = source; -						conf->gen.reset_scontext = context; -						conf->gen.reset_srole = srole; +						record->reset_source = source; +						record->reset_scontext = context; +						record->reset_srole = srole;  					} -					for (GucStack *stack = conf->gen.stack; stack; stack = stack->prev) +					for (GucStack *stack = record->stack; stack; stack = stack->prev)  					{  						if (stack->source <= source)  						{  							stack->prior.val.boolval = newval; -							set_extra_field(&conf->gen, &stack->prior.extra, +							set_extra_field(record, &stack->prior.extra,  											newextra);  							stack->source = source;  							stack->scontext = context; @@ -3726,7 +3654,7 @@ set_config_with_handle(const char *name, config_handle *handle,  				}  				/* Perhaps we didn't install newextra anywhere */ -				if (newextra && !extra_field_used(&conf->gen, newextra)) +				if (newextra && !extra_field_used(record, newextra))  					guc_free(newextra);  				break; @@ -3735,7 +3663,7 @@ set_config_with_handle(const char *name, config_handle *handle,  		case PGC_INT:  			{ -				struct config_int *conf = (struct config_int *) record; +				struct config_int *conf = &record->_int;  #define newval (newval_union.intval) @@ -3749,23 +3677,23 @@ set_config_with_handle(const char *name, config_handle *handle,  				else if (source == PGC_S_DEFAULT)  				{  					newval = conf->boot_val; -					if (!call_int_check_hook(conf, &newval, &newextra, +					if (!call_int_check_hook(record, &newval, &newextra,  											 source, elevel))  						return 0;  				}  				else  				{  					newval = conf->reset_val; -					newextra = conf->gen.reset_extra; -					source = conf->gen.reset_source; -					context = conf->gen.reset_scontext; -					srole = conf->gen.reset_srole; +					newextra = record->reset_extra; +					source = record->reset_source; +					context = record->reset_scontext; +					srole = record->reset_srole;  				}  				if (prohibitValueChange)  				{  					/* Release newextra, unless it's reset_extra */ -					if (newextra && !extra_field_used(&conf->gen, newextra)) +					if (newextra && !extra_field_used(record, newextra))  						guc_free(newextra);  					if (*conf->variable != newval) @@ -3774,7 +3702,7 @@ set_config_with_handle(const char *name, config_handle *handle,  						ereport(elevel,  								(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),  								 errmsg("parameter \"%s\" cannot be changed without restarting the server", -										conf->gen.name))); +										record->name)));  						return 0;  					}  					record->status &= ~GUC_PENDING_RESTART; @@ -3785,34 +3713,34 @@ set_config_with_handle(const char *name, config_handle *handle,  				{  					/* Save old value to support transaction abort */  					if (!makeDefault) -						push_old_value(&conf->gen, action); +						push_old_value(record, action);  					if (conf->assign_hook)  						conf->assign_hook(newval, newextra);  					*conf->variable = newval; -					set_extra_field(&conf->gen, &conf->gen.extra, +					set_extra_field(record, &record->extra,  									newextra); -					set_guc_source(&conf->gen, source); -					conf->gen.scontext = context; -					conf->gen.srole = srole; +					set_guc_source(record, source); +					record->scontext = context; +					record->srole = srole;  				}  				if (makeDefault)  				{ -					if (conf->gen.reset_source <= source) +					if (record->reset_source <= source)  					{  						conf->reset_val = newval; -						set_extra_field(&conf->gen, &conf->gen.reset_extra, +						set_extra_field(record, &record->reset_extra,  										newextra); -						conf->gen.reset_source = source; -						conf->gen.reset_scontext = context; -						conf->gen.reset_srole = srole; +						record->reset_source = source; +						record->reset_scontext = context; +						record->reset_srole = srole;  					} -					for (GucStack *stack = conf->gen.stack; stack; stack = stack->prev) +					for (GucStack *stack = record->stack; stack; stack = stack->prev)  					{  						if (stack->source <= source)  						{  							stack->prior.val.intval = newval; -							set_extra_field(&conf->gen, &stack->prior.extra, +							set_extra_field(record, &stack->prior.extra,  											newextra);  							stack->source = source;  							stack->scontext = context; @@ -3822,7 +3750,7 @@ set_config_with_handle(const char *name, config_handle *handle,  				}  				/* Perhaps we didn't install newextra anywhere */ -				if (newextra && !extra_field_used(&conf->gen, newextra)) +				if (newextra && !extra_field_used(record, newextra))  					guc_free(newextra);  				break; @@ -3831,7 +3759,7 @@ set_config_with_handle(const char *name, config_handle *handle,  		case PGC_REAL:  			{ -				struct config_real *conf = (struct config_real *) record; +				struct config_real *conf = &record->_real;  #define newval (newval_union.realval) @@ -3845,23 +3773,23 @@ set_config_with_handle(const char *name, config_handle *handle,  				else if (source == PGC_S_DEFAULT)  				{  					newval = conf->boot_val; -					if (!call_real_check_hook(conf, &newval, &newextra, +					if (!call_real_check_hook(record, &newval, &newextra,  											  source, elevel))  						return 0;  				}  				else  				{  					newval = conf->reset_val; -					newextra = conf->gen.reset_extra; -					source = conf->gen.reset_source; -					context = conf->gen.reset_scontext; -					srole = conf->gen.reset_srole; +					newextra = record->reset_extra; +					source = record->reset_source; +					context = record->reset_scontext; +					srole = record->reset_srole;  				}  				if (prohibitValueChange)  				{  					/* Release newextra, unless it's reset_extra */ -					if (newextra && !extra_field_used(&conf->gen, newextra)) +					if (newextra && !extra_field_used(record, newextra))  						guc_free(newextra);  					if (*conf->variable != newval) @@ -3870,7 +3798,7 @@ set_config_with_handle(const char *name, config_handle *handle,  						ereport(elevel,  								(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),  								 errmsg("parameter \"%s\" cannot be changed without restarting the server", -										conf->gen.name))); +										record->name)));  						return 0;  					}  					record->status &= ~GUC_PENDING_RESTART; @@ -3881,34 +3809,34 @@ set_config_with_handle(const char *name, config_handle *handle,  				{  					/* Save old value to support transaction abort */  					if (!makeDefault) -						push_old_value(&conf->gen, action); +						push_old_value(record, action);  					if (conf->assign_hook)  						conf->assign_hook(newval, newextra);  					*conf->variable = newval; -					set_extra_field(&conf->gen, &conf->gen.extra, +					set_extra_field(record, &record->extra,  									newextra); -					set_guc_source(&conf->gen, source); -					conf->gen.scontext = context; -					conf->gen.srole = srole; +					set_guc_source(record, source); +					record->scontext = context; +					record->srole = srole;  				}  				if (makeDefault)  				{ -					if (conf->gen.reset_source <= source) +					if (record->reset_source <= source)  					{  						conf->reset_val = newval; -						set_extra_field(&conf->gen, &conf->gen.reset_extra, +						set_extra_field(record, &record->reset_extra,  										newextra); -						conf->gen.reset_source = source; -						conf->gen.reset_scontext = context; -						conf->gen.reset_srole = srole; +						record->reset_source = source; +						record->reset_scontext = context; +						record->reset_srole = srole;  					} -					for (GucStack *stack = conf->gen.stack; stack; stack = stack->prev) +					for (GucStack *stack = record->stack; stack; stack = stack->prev)  					{  						if (stack->source <= source)  						{  							stack->prior.val.realval = newval; -							set_extra_field(&conf->gen, &stack->prior.extra, +							set_extra_field(record, &stack->prior.extra,  											newextra);  							stack->source = source;  							stack->scontext = context; @@ -3918,7 +3846,7 @@ set_config_with_handle(const char *name, config_handle *handle,  				}  				/* Perhaps we didn't install newextra anywhere */ -				if (newextra && !extra_field_used(&conf->gen, newextra)) +				if (newextra && !extra_field_used(record, newextra))  					guc_free(newextra);  				break; @@ -3927,7 +3855,7 @@ set_config_with_handle(const char *name, config_handle *handle,  		case PGC_STRING:  			{ -				struct config_string *conf = (struct config_string *) record; +				struct config_string *conf = &record->_string;  				GucContext	orig_context = context;  				GucSource	orig_source = source;  				Oid			orig_srole = srole; @@ -3953,7 +3881,7 @@ set_config_with_handle(const char *name, config_handle *handle,  					else  						newval = NULL; -					if (!call_string_check_hook(conf, &newval, &newextra, +					if (!call_string_check_hook(record, &newval, &newextra,  												source, elevel))  					{  						guc_free(newval); @@ -3967,10 +3895,10 @@ set_config_with_handle(const char *name, config_handle *handle,  					 * guc.c's control  					 */  					newval = conf->reset_val; -					newextra = conf->gen.reset_extra; -					source = conf->gen.reset_source; -					context = conf->gen.reset_scontext; -					srole = conf->gen.reset_srole; +					newextra = record->reset_extra; +					source = record->reset_source; +					context = record->reset_scontext; +					srole = record->reset_srole;  				}  				if (prohibitValueChange) @@ -3983,10 +3911,10 @@ set_config_with_handle(const char *name, config_handle *handle,  										strcmp(*conf->variable, newval) != 0);  					/* Release newval, unless it's reset_val */ -					if (newval && !string_field_used(conf, newval)) +					if (newval && !string_field_used(record, newval))  						guc_free(newval);  					/* Release newextra, unless it's reset_extra */ -					if (newextra && !extra_field_used(&conf->gen, newextra)) +					if (newextra && !extra_field_used(record, newextra))  						guc_free(newextra);  					if (newval_different) @@ -3995,7 +3923,7 @@ set_config_with_handle(const char *name, config_handle *handle,  						ereport(elevel,  								(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),  								 errmsg("parameter \"%s\" cannot be changed without restarting the server", -										conf->gen.name))); +										record->name)));  						return 0;  					}  					record->status &= ~GUC_PENDING_RESTART; @@ -4006,16 +3934,16 @@ set_config_with_handle(const char *name, config_handle *handle,  				{  					/* Save old value to support transaction abort */  					if (!makeDefault) -						push_old_value(&conf->gen, action); +						push_old_value(record, action);  					if (conf->assign_hook)  						conf->assign_hook(newval, newextra); -					set_string_field(conf, conf->variable, newval); -					set_extra_field(&conf->gen, &conf->gen.extra, +					set_string_field(record, conf->variable, newval); +					set_extra_field(record, &record->extra,  									newextra); -					set_guc_source(&conf->gen, source); -					conf->gen.scontext = context; -					conf->gen.srole = srole; +					set_guc_source(record, source); +					record->scontext = context; +					record->srole = srole;  					/*  					 * Ugly hack: during SET session_authorization, forcibly @@ -4042,7 +3970,7 @@ set_config_with_handle(const char *name, config_handle *handle,  					 * that.  					 */  					if (!is_reload && -						strcmp(conf->gen.name, "session_authorization") == 0) +						strcmp(record->name, "session_authorization") == 0)  						(void) set_config_with_handle("role", NULL,  													  value ? "none" : NULL,  													  orig_context, @@ -4058,22 +3986,22 @@ set_config_with_handle(const char *name, config_handle *handle,  				if (makeDefault)  				{ -					if (conf->gen.reset_source <= source) +					if (record->reset_source <= source)  					{ -						set_string_field(conf, &conf->reset_val, newval); -						set_extra_field(&conf->gen, &conf->gen.reset_extra, +						set_string_field(record, &conf->reset_val, newval); +						set_extra_field(record, &record->reset_extra,  										newextra); -						conf->gen.reset_source = source; -						conf->gen.reset_scontext = context; -						conf->gen.reset_srole = srole; +						record->reset_source = source; +						record->reset_scontext = context; +						record->reset_srole = srole;  					} -					for (GucStack *stack = conf->gen.stack; stack; stack = stack->prev) +					for (GucStack *stack = record->stack; stack; stack = stack->prev)  					{  						if (stack->source <= source)  						{ -							set_string_field(conf, &stack->prior.val.stringval, +							set_string_field(record, &stack->prior.val.stringval,  											 newval); -							set_extra_field(&conf->gen, &stack->prior.extra, +							set_extra_field(record, &stack->prior.extra,  											newextra);  							stack->source = source;  							stack->scontext = context; @@ -4083,10 +4011,10 @@ set_config_with_handle(const char *name, config_handle *handle,  				}  				/* Perhaps we didn't install newval anywhere */ -				if (newval && !string_field_used(conf, newval)) +				if (newval && !string_field_used(record, newval))  					guc_free(newval);  				/* Perhaps we didn't install newextra anywhere */ -				if (newextra && !extra_field_used(&conf->gen, newextra)) +				if (newextra && !extra_field_used(record, newextra))  					guc_free(newextra);  				break; @@ -4095,7 +4023,7 @@ set_config_with_handle(const char *name, config_handle *handle,  		case PGC_ENUM:  			{ -				struct config_enum *conf = (struct config_enum *) record; +				struct config_enum *conf = &record->_enum;  #define newval (newval_union.enumval) @@ -4109,23 +4037,23 @@ set_config_with_handle(const char *name, config_handle *handle,  				else if (source == PGC_S_DEFAULT)  				{  					newval = conf->boot_val; -					if (!call_enum_check_hook(conf, &newval, &newextra, +					if (!call_enum_check_hook(record, &newval, &newextra,  											  source, elevel))  						return 0;  				}  				else  				{  					newval = conf->reset_val; -					newextra = conf->gen.reset_extra; -					source = conf->gen.reset_source; -					context = conf->gen.reset_scontext; -					srole = conf->gen.reset_srole; +					newextra = record->reset_extra; +					source = record->reset_source; +					context = record->reset_scontext; +					srole = record->reset_srole;  				}  				if (prohibitValueChange)  				{  					/* Release newextra, unless it's reset_extra */ -					if (newextra && !extra_field_used(&conf->gen, newextra)) +					if (newextra && !extra_field_used(record, newextra))  						guc_free(newextra);  					if (*conf->variable != newval) @@ -4134,7 +4062,7 @@ set_config_with_handle(const char *name, config_handle *handle,  						ereport(elevel,  								(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),  								 errmsg("parameter \"%s\" cannot be changed without restarting the server", -										conf->gen.name))); +										record->name)));  						return 0;  					}  					record->status &= ~GUC_PENDING_RESTART; @@ -4145,34 +4073,34 @@ set_config_with_handle(const char *name, config_handle *handle,  				{  					/* Save old value to support transaction abort */  					if (!makeDefault) -						push_old_value(&conf->gen, action); +						push_old_value(record, action);  					if (conf->assign_hook)  						conf->assign_hook(newval, newextra);  					*conf->variable = newval; -					set_extra_field(&conf->gen, &conf->gen.extra, +					set_extra_field(record, &record->extra,  									newextra); -					set_guc_source(&conf->gen, source); -					conf->gen.scontext = context; -					conf->gen.srole = srole; +					set_guc_source(record, source); +					record->scontext = context; +					record->srole = srole;  				}  				if (makeDefault)  				{ -					if (conf->gen.reset_source <= source) +					if (record->reset_source <= source)  					{  						conf->reset_val = newval; -						set_extra_field(&conf->gen, &conf->gen.reset_extra, +						set_extra_field(record, &record->reset_extra,  										newextra); -						conf->gen.reset_source = source; -						conf->gen.reset_scontext = context; -						conf->gen.reset_srole = srole; +						record->reset_source = source; +						record->reset_scontext = context; +						record->reset_srole = srole;  					} -					for (GucStack *stack = conf->gen.stack; stack; stack = stack->prev) +					for (GucStack *stack = record->stack; stack; stack = stack->prev)  					{  						if (stack->source <= source)  						{  							stack->prior.val.enumval = newval; -							set_extra_field(&conf->gen, &stack->prior.extra, +							set_extra_field(record, &stack->prior.extra,  											newextra);  							stack->source = source;  							stack->scontext = context; @@ -4182,7 +4110,7 @@ set_config_with_handle(const char *name, config_handle *handle,  				}  				/* Perhaps we didn't install newextra anywhere */ -				if (newextra && !extra_field_used(&conf->gen, newextra)) +				if (newextra && !extra_field_used(record, newextra))  					guc_free(newextra);  				break; @@ -4296,25 +4224,25 @@ GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)  	switch (record->vartype)  	{  		case PGC_BOOL: -			return *((struct config_bool *) record)->variable ? "on" : "off"; +			return *record->_bool.variable ? "on" : "off";  		case PGC_INT:  			snprintf(buffer, sizeof(buffer), "%d", -					 *((struct config_int *) record)->variable); +					 *record->_int.variable);  			return buffer;  		case PGC_REAL:  			snprintf(buffer, sizeof(buffer), "%g", -					 *((struct config_real *) record)->variable); +					 *record->_real.variable);  			return buffer;  		case PGC_STRING: -			return *((struct config_string *) record)->variable ? -				*((struct config_string *) record)->variable : ""; +			return *record->_string.variable ? +				*record->_string.variable : "";  		case PGC_ENUM: -			return config_enum_lookup_by_value((struct config_enum *) record, -											   *((struct config_enum *) record)->variable); +			return config_enum_lookup_by_value(record, +											   *record->_enum.variable);  	}  	return NULL;  } @@ -4344,25 +4272,25 @@ GetConfigOptionResetString(const char *name)  	switch (record->vartype)  	{  		case PGC_BOOL: -			return ((struct config_bool *) record)->reset_val ? "on" : "off"; +			return record->_bool.reset_val ? "on" : "off";  		case PGC_INT:  			snprintf(buffer, sizeof(buffer), "%d", -					 ((struct config_int *) record)->reset_val); +					 record->_int.reset_val);  			return buffer;  		case PGC_REAL:  			snprintf(buffer, sizeof(buffer), "%g", -					 ((struct config_real *) record)->reset_val); +					 record->_real.reset_val);  			return buffer;  		case PGC_STRING: -			return ((struct config_string *) record)->reset_val ? -				((struct config_string *) record)->reset_val : ""; +			return record->_string.reset_val ? +				record->_string.reset_val : "";  		case PGC_ENUM: -			return config_enum_lookup_by_value((struct config_enum *) record, -											   ((struct config_enum *) record)->reset_val); +			return config_enum_lookup_by_value(record, +											   record->_enum.reset_val);  	}  	return NULL;  } @@ -4802,8 +4730,7 @@ init_custom_variable(const char *name,  					 const char *long_desc,  					 GucContext context,  					 int flags, -					 enum config_type type, -					 size_t sz) +					 enum config_type type)  {  	struct config_generic *gen; @@ -4839,8 +4766,8 @@ init_custom_variable(const char *name,  		context = PGC_SUSET;  	/* As above, an OOM here is FATAL */ -	gen = (struct config_generic *) guc_malloc(FATAL, sz); -	memset(gen, 0, sz); +	gen = (struct config_generic *) guc_malloc(FATAL, sizeof(struct config_generic)); +	memset(gen, 0, sizeof(struct config_generic));  	gen->name = guc_strdup(FATAL, name);  	gen->context = context; @@ -4862,7 +4789,7 @@ define_custom_variable(struct config_generic *variable)  {  	const char *name = variable->name;  	GUCHashEntry *hentry; -	struct config_string *pHolder; +	struct config_generic *pHolder;  	/* Check mapping between initial and default value */  	Assert(check_GUC_init(variable)); @@ -4894,7 +4821,7 @@ define_custom_variable(struct config_generic *variable)  				 errmsg("attempt to redefine parameter \"%s\"", name)));  	Assert(hentry->gucvar->vartype == PGC_STRING); -	pHolder = (struct config_string *) hentry->gucvar; +	pHolder = hentry->gucvar;  	/*  	 * First, set the variable to its default value.  We must do this even @@ -4913,7 +4840,7 @@ define_custom_variable(struct config_generic *variable)  	/*  	 * Remove the placeholder from any lists it's in, too.  	 */ -	RemoveGUCFromLists(&pHolder->gen); +	RemoveGUCFromLists(pHolder);  	/*  	 * Assign the string value(s) stored in the placeholder to the real @@ -4927,25 +4854,25 @@ define_custom_variable(struct config_generic *variable)  	 */  	/* First, apply the reset value if any */ -	if (pHolder->reset_val) -		(void) set_config_option_ext(name, pHolder->reset_val, -									 pHolder->gen.reset_scontext, -									 pHolder->gen.reset_source, -									 pHolder->gen.reset_srole, +	if (pHolder->_string.reset_val) +		(void) set_config_option_ext(name, pHolder->_string.reset_val, +									 pHolder->reset_scontext, +									 pHolder->reset_source, +									 pHolder->reset_srole,  									 GUC_ACTION_SET, true, WARNING, false);  	/* That should not have resulted in stacking anything */  	Assert(variable->stack == NULL);  	/* Now, apply current and stacked values, in the order they were stacked */ -	reapply_stacked_values(variable, pHolder, pHolder->gen.stack, -						   *(pHolder->variable), -						   pHolder->gen.scontext, pHolder->gen.source, -						   pHolder->gen.srole); +	reapply_stacked_values(variable, pHolder, pHolder->stack, +						   *(pHolder->_string.variable), +						   pHolder->scontext, pHolder->source, +						   pHolder->srole);  	/* Also copy over any saved source-location information */ -	if (pHolder->gen.sourcefile) -		set_config_sourcefile(name, pHolder->gen.sourcefile, -							  pHolder->gen.sourceline); +	if (pHolder->sourcefile) +		set_config_sourcefile(name, pHolder->sourcefile, +							  pHolder->sourceline);  	/* Now we can free the no-longer-referenced placeholder variable */  	free_placeholder(pHolder); @@ -4960,7 +4887,7 @@ define_custom_variable(struct config_generic *variable)   */  static void  reapply_stacked_values(struct config_generic *variable, -					   struct config_string *pHolder, +					   struct config_generic *pHolder,  					   GucStack *stack,  					   const char *curvalue,  					   GucContext curscontext, GucSource cursource, @@ -5030,10 +4957,10 @@ reapply_stacked_values(struct config_generic *variable,  		 * this is to be just a transactional assignment.  (We leak the stack  		 * entry.)  		 */ -		if (curvalue != pHolder->reset_val || -			curscontext != pHolder->gen.reset_scontext || -			cursource != pHolder->gen.reset_source || -			cursrole != pHolder->gen.reset_srole) +		if (curvalue != pHolder->_string.reset_val || +			curscontext != pHolder->reset_scontext || +			cursource != pHolder->reset_source || +			cursrole != pHolder->reset_srole)  		{  			(void) set_config_option_ext(name, curvalue,  										 curscontext, cursource, cursrole, @@ -5055,14 +4982,14 @@ reapply_stacked_values(struct config_generic *variable,   * doesn't seem worth spending much code on.   */  static void -free_placeholder(struct config_string *pHolder) +free_placeholder(struct config_generic *pHolder)  {  	/* Placeholders are always STRING type, so free their values */ -	Assert(pHolder->gen.vartype == PGC_STRING); -	set_string_field(pHolder, pHolder->variable, NULL); -	set_string_field(pHolder, &pHolder->reset_val, NULL); +	Assert(pHolder->vartype == PGC_STRING); +	set_string_field(pHolder, pHolder->_string.variable, NULL); +	set_string_field(pHolder, &pHolder->_string.reset_val, NULL); -	guc_free(unconstify(char *, pHolder->gen.name)); +	guc_free(unconstify(char *, pHolder->name));  	guc_free(pHolder);  } @@ -5081,18 +5008,16 @@ DefineCustomBoolVariable(const char *name,  						 GucBoolAssignHook assign_hook,  						 GucShowHook show_hook)  { -	struct config_bool *var; - -	var = (struct config_bool *) -		init_custom_variable(name, short_desc, long_desc, context, flags, -							 PGC_BOOL, sizeof(struct config_bool)); -	var->variable = valueAddr; -	var->boot_val = bootValue; -	var->reset_val = bootValue; -	var->check_hook = check_hook; -	var->assign_hook = assign_hook; -	var->show_hook = show_hook; -	define_custom_variable(&var->gen); +	struct config_generic *var; + +	var = init_custom_variable(name, short_desc, long_desc, context, flags, PGC_BOOL); +	var->_bool.variable = valueAddr; +	var->_bool.boot_val = bootValue; +	var->_bool.reset_val = bootValue; +	var->_bool.check_hook = check_hook; +	var->_bool.assign_hook = assign_hook; +	var->_bool.show_hook = show_hook; +	define_custom_variable(var);  }  void @@ -5109,20 +5034,18 @@ DefineCustomIntVariable(const char *name,  						GucIntAssignHook assign_hook,  						GucShowHook show_hook)  { -	struct config_int *var; - -	var = (struct config_int *) -		init_custom_variable(name, short_desc, long_desc, context, flags, -							 PGC_INT, sizeof(struct config_int)); -	var->variable = valueAddr; -	var->boot_val = bootValue; -	var->reset_val = bootValue; -	var->min = minValue; -	var->max = maxValue; -	var->check_hook = check_hook; -	var->assign_hook = assign_hook; -	var->show_hook = show_hook; -	define_custom_variable(&var->gen); +	struct config_generic *var; + +	var = init_custom_variable(name, short_desc, long_desc, context, flags, PGC_INT); +	var->_int.variable = valueAddr; +	var->_int.boot_val = bootValue; +	var->_int.reset_val = bootValue; +	var->_int.min = minValue; +	var->_int.max = maxValue; +	var->_int.check_hook = check_hook; +	var->_int.assign_hook = assign_hook; +	var->_int.show_hook = show_hook; +	define_custom_variable(var);  }  void @@ -5139,20 +5062,18 @@ DefineCustomRealVariable(const char *name,  						 GucRealAssignHook assign_hook,  						 GucShowHook show_hook)  { -	struct config_real *var; - -	var = (struct config_real *) -		init_custom_variable(name, short_desc, long_desc, context, flags, -							 PGC_REAL, sizeof(struct config_real)); -	var->variable = valueAddr; -	var->boot_val = bootValue; -	var->reset_val = bootValue; -	var->min = minValue; -	var->max = maxValue; -	var->check_hook = check_hook; -	var->assign_hook = assign_hook; -	var->show_hook = show_hook; -	define_custom_variable(&var->gen); +	struct config_generic *var; + +	var = init_custom_variable(name, short_desc, long_desc, context, flags, PGC_REAL); +	var->_real.variable = valueAddr; +	var->_real.boot_val = bootValue; +	var->_real.reset_val = bootValue; +	var->_real.min = minValue; +	var->_real.max = maxValue; +	var->_real.check_hook = check_hook; +	var->_real.assign_hook = assign_hook; +	var->_real.show_hook = show_hook; +	define_custom_variable(var);  }  void @@ -5167,17 +5088,15 @@ DefineCustomStringVariable(const char *name,  						   GucStringAssignHook assign_hook,  						   GucShowHook show_hook)  { -	struct config_string *var; - -	var = (struct config_string *) -		init_custom_variable(name, short_desc, long_desc, context, flags, -							 PGC_STRING, sizeof(struct config_string)); -	var->variable = valueAddr; -	var->boot_val = bootValue; -	var->check_hook = check_hook; -	var->assign_hook = assign_hook; -	var->show_hook = show_hook; -	define_custom_variable(&var->gen); +	struct config_generic *var; + +	var = init_custom_variable(name, short_desc, long_desc, context, flags, PGC_STRING); +	var->_string.variable = valueAddr; +	var->_string.boot_val = bootValue; +	var->_string.check_hook = check_hook; +	var->_string.assign_hook = assign_hook; +	var->_string.show_hook = show_hook; +	define_custom_variable(var);  }  void @@ -5193,19 +5112,17 @@ DefineCustomEnumVariable(const char *name,  						 GucEnumAssignHook assign_hook,  						 GucShowHook show_hook)  { -	struct config_enum *var; - -	var = (struct config_enum *) -		init_custom_variable(name, short_desc, long_desc, context, flags, -							 PGC_ENUM, sizeof(struct config_enum)); -	var->variable = valueAddr; -	var->boot_val = bootValue; -	var->reset_val = bootValue; -	var->options = options; -	var->check_hook = check_hook; -	var->assign_hook = assign_hook; -	var->show_hook = show_hook; -	define_custom_variable(&var->gen); +	struct config_generic *var; + +	var = init_custom_variable(name, short_desc, long_desc, context, flags, PGC_ENUM); +	var->_enum.variable = valueAddr; +	var->_enum.boot_val = bootValue; +	var->_enum.reset_val = bootValue; +	var->_enum.options = options; +	var->_enum.check_hook = check_hook; +	var->_enum.assign_hook = assign_hook; +	var->_enum.show_hook = show_hook; +	define_custom_variable(var);  }  /* @@ -5251,7 +5168,7 @@ MarkGUCPrefixReserved(const char *className)  			/* Remove it from any lists it's in, too */  			RemoveGUCFromLists(var);  			/* And free it */ -			free_placeholder((struct config_string *) var); +			free_placeholder(var);  		}  	} @@ -5304,7 +5221,7 @@ get_explain_guc_options(int *num)  		{  			case PGC_BOOL:  				{ -					struct config_bool *lconf = (struct config_bool *) conf; +					struct config_bool *lconf = &conf->_bool;  					modified = (lconf->boot_val != *(lconf->variable));  				} @@ -5312,7 +5229,7 @@ get_explain_guc_options(int *num)  			case PGC_INT:  				{ -					struct config_int *lconf = (struct config_int *) conf; +					struct config_int *lconf = &conf->_int;  					modified = (lconf->boot_val != *(lconf->variable));  				} @@ -5320,7 +5237,7 @@ get_explain_guc_options(int *num)  			case PGC_REAL:  				{ -					struct config_real *lconf = (struct config_real *) conf; +					struct config_real *lconf = &conf->_real;  					modified = (lconf->boot_val != *(lconf->variable));  				} @@ -5328,7 +5245,7 @@ get_explain_guc_options(int *num)  			case PGC_STRING:  				{ -					struct config_string *lconf = (struct config_string *) conf; +					struct config_string *lconf = &conf->_string;  					if (lconf->boot_val == NULL &&  						*lconf->variable == NULL) @@ -5343,7 +5260,7 @@ get_explain_guc_options(int *num)  			case PGC_ENUM:  				{ -					struct config_enum *lconf = (struct config_enum *) conf; +					struct config_enum *lconf = &conf->_enum;  					modified = (lconf->boot_val != *(lconf->variable));  				} @@ -5412,7 +5329,7 @@ ShowGUCOption(const struct config_generic *record, bool use_units)  	{  		case PGC_BOOL:  			{ -				const struct config_bool *conf = (const struct config_bool *) record; +				const struct config_bool *conf = &record->_bool;  				if (conf->show_hook)  					val = conf->show_hook(); @@ -5423,7 +5340,7 @@ ShowGUCOption(const struct config_generic *record, bool use_units)  		case PGC_INT:  			{ -				const struct config_int *conf = (const struct config_int *) record; +				const struct config_int *conf = &record->_int;  				if (conf->show_hook)  					val = conf->show_hook(); @@ -5452,7 +5369,7 @@ ShowGUCOption(const struct config_generic *record, bool use_units)  		case PGC_REAL:  			{ -				const struct config_real *conf = (const struct config_real *) record; +				const struct config_real *conf = &record->_real;  				if (conf->show_hook)  					val = conf->show_hook(); @@ -5477,7 +5394,7 @@ ShowGUCOption(const struct config_generic *record, bool use_units)  		case PGC_STRING:  			{ -				const struct config_string *conf = (const struct config_string *) record; +				const struct config_string *conf = &record->_string;  				if (conf->show_hook)  					val = conf->show_hook(); @@ -5490,12 +5407,12 @@ ShowGUCOption(const struct config_generic *record, bool use_units)  		case PGC_ENUM:  			{ -				const struct config_enum *conf = (const struct config_enum *) record; +				const struct config_enum *conf = &record->_enum;  				if (conf->show_hook)  					val = conf->show_hook();  				else -					val = config_enum_lookup_by_value(conf, *conf->variable); +					val = config_enum_lookup_by_value(record, *conf->variable);  			}  			break; @@ -5535,7 +5452,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf)  	{  		case PGC_BOOL:  			{ -				struct config_bool *conf = (struct config_bool *) gconf; +				struct config_bool *conf = &gconf->_bool;  				if (*conf->variable)  					fprintf(fp, "true"); @@ -5546,7 +5463,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf)  		case PGC_INT:  			{ -				struct config_int *conf = (struct config_int *) gconf; +				struct config_int *conf = &gconf->_int;  				fprintf(fp, "%d", *conf->variable);  			} @@ -5554,7 +5471,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf)  		case PGC_REAL:  			{ -				struct config_real *conf = (struct config_real *) gconf; +				struct config_real *conf = &gconf->_real;  				fprintf(fp, "%.17g", *conf->variable);  			} @@ -5562,7 +5479,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf)  		case PGC_STRING:  			{ -				struct config_string *conf = (struct config_string *) gconf; +				struct config_string *conf = &gconf->_string;  				if (*conf->variable)  					fprintf(fp, "%s", *conf->variable); @@ -5571,10 +5488,10 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf)  		case PGC_ENUM:  			{ -				struct config_enum *conf = (struct config_enum *) gconf; +				struct config_enum *conf = &gconf->_enum;  				fprintf(fp, "%s", -						config_enum_lookup_by_value(conf, *conf->variable)); +						config_enum_lookup_by_value(gconf, *conf->variable));  			}  			break;  	} @@ -5809,7 +5726,7 @@ estimate_variable_size(struct config_generic *gconf)  		case PGC_INT:  			{ -				struct config_int *conf = (struct config_int *) gconf; +				struct config_int *conf = &gconf->_int;  				/*  				 * Instead of getting the exact display length, use max @@ -5838,7 +5755,7 @@ estimate_variable_size(struct config_generic *gconf)  		case PGC_STRING:  			{ -				struct config_string *conf = (struct config_string *) gconf; +				struct config_string *conf = &gconf->_string;  				/*  				 * If the value is NULL, we transmit it as an empty string. @@ -5854,9 +5771,9 @@ estimate_variable_size(struct config_generic *gconf)  		case PGC_ENUM:  			{ -				struct config_enum *conf = (struct config_enum *) gconf; +				struct config_enum *conf = &gconf->_enum; -				valsize = strlen(config_enum_lookup_by_value(conf, *conf->variable)); +				valsize = strlen(config_enum_lookup_by_value(gconf, *conf->variable));  			}  			break;  	} @@ -5975,7 +5892,7 @@ serialize_variable(char **destptr, Size *maxbytes,  	{  		case PGC_BOOL:  			{ -				struct config_bool *conf = (struct config_bool *) gconf; +				struct config_bool *conf = &gconf->_bool;  				do_serialize(destptr, maxbytes,  							 (*conf->variable ? "true" : "false")); @@ -5984,7 +5901,7 @@ serialize_variable(char **destptr, Size *maxbytes,  		case PGC_INT:  			{ -				struct config_int *conf = (struct config_int *) gconf; +				struct config_int *conf = &gconf->_int;  				do_serialize(destptr, maxbytes, "%d", *conf->variable);  			} @@ -5992,7 +5909,7 @@ serialize_variable(char **destptr, Size *maxbytes,  		case PGC_REAL:  			{ -				struct config_real *conf = (struct config_real *) gconf; +				struct config_real *conf = &gconf->_real;  				do_serialize(destptr, maxbytes, "%.*e",  							 REALTYPE_PRECISION, *conf->variable); @@ -6001,7 +5918,7 @@ serialize_variable(char **destptr, Size *maxbytes,  		case PGC_STRING:  			{ -				struct config_string *conf = (struct config_string *) gconf; +				struct config_string *conf = &gconf->_string;  				/* NULL becomes empty string, see estimate_variable_size() */  				do_serialize(destptr, maxbytes, "%s", @@ -6011,10 +5928,10 @@ serialize_variable(char **destptr, Size *maxbytes,  		case PGC_ENUM:  			{ -				struct config_enum *conf = (struct config_enum *) gconf; +				struct config_enum *conf = &gconf->_enum;  				do_serialize(destptr, maxbytes, "%s", -							 config_enum_lookup_by_value(conf, *conf->variable)); +							 config_enum_lookup_by_value(gconf, *conf->variable));  			}  			break;  	} @@ -6199,7 +6116,7 @@ RestoreGUCState(void *gucstate)  				break;  			case PGC_STRING:  				{ -					struct config_string *conf = (struct config_string *) gconf; +					struct config_string *conf = &gconf->_string;  					guc_free(*conf->variable);  					if (conf->reset_val && conf->reset_val != *conf->variable) @@ -6710,11 +6627,11 @@ GUC_check_errcode(int sqlerrcode)   */  static bool -call_bool_check_hook(const struct config_bool *conf, bool *newval, void **extra, +call_bool_check_hook(const struct config_generic *conf, bool *newval, void **extra,  					 GucSource source, int elevel)  {  	/* Quick success if no hook */ -	if (!conf->check_hook) +	if (!conf->_bool.check_hook)  		return true;  	/* Reset variables that might be set by hook */ @@ -6723,14 +6640,14 @@ call_bool_check_hook(const struct config_bool *conf, bool *newval, void **extra,  	GUC_check_errdetail_string = NULL;  	GUC_check_errhint_string = NULL; -	if (!conf->check_hook(newval, extra, source)) +	if (!conf->_bool.check_hook(newval, extra, source))  	{  		ereport(elevel,  				(errcode(GUC_check_errcode_value),  				 GUC_check_errmsg_string ?  				 errmsg_internal("%s", GUC_check_errmsg_string) :  				 errmsg("invalid value for parameter \"%s\": %d", -						conf->gen.name, (int) *newval), +						conf->name, (int) *newval),  				 GUC_check_errdetail_string ?  				 errdetail_internal("%s", GUC_check_errdetail_string) : 0,  				 GUC_check_errhint_string ? @@ -6744,11 +6661,11 @@ call_bool_check_hook(const struct config_bool *conf, bool *newval, void **extra,  }  static bool -call_int_check_hook(const struct config_int *conf, int *newval, void **extra, +call_int_check_hook(const struct config_generic *conf, int *newval, void **extra,  					GucSource source, int elevel)  {  	/* Quick success if no hook */ -	if (!conf->check_hook) +	if (!conf->_int.check_hook)  		return true;  	/* Reset variables that might be set by hook */ @@ -6757,14 +6674,14 @@ call_int_check_hook(const struct config_int *conf, int *newval, void **extra,  	GUC_check_errdetail_string = NULL;  	GUC_check_errhint_string = NULL; -	if (!conf->check_hook(newval, extra, source)) +	if (!conf->_int.check_hook(newval, extra, source))  	{  		ereport(elevel,  				(errcode(GUC_check_errcode_value),  				 GUC_check_errmsg_string ?  				 errmsg_internal("%s", GUC_check_errmsg_string) :  				 errmsg("invalid value for parameter \"%s\": %d", -						conf->gen.name, *newval), +						conf->name, *newval),  				 GUC_check_errdetail_string ?  				 errdetail_internal("%s", GUC_check_errdetail_string) : 0,  				 GUC_check_errhint_string ? @@ -6778,11 +6695,11 @@ call_int_check_hook(const struct config_int *conf, int *newval, void **extra,  }  static bool -call_real_check_hook(const struct config_real *conf, double *newval, void **extra, +call_real_check_hook(const struct config_generic *conf, double *newval, void **extra,  					 GucSource source, int elevel)  {  	/* Quick success if no hook */ -	if (!conf->check_hook) +	if (!conf->_real.check_hook)  		return true;  	/* Reset variables that might be set by hook */ @@ -6791,14 +6708,14 @@ call_real_check_hook(const struct config_real *conf, double *newval, void **extr  	GUC_check_errdetail_string = NULL;  	GUC_check_errhint_string = NULL; -	if (!conf->check_hook(newval, extra, source)) +	if (!conf->_real.check_hook(newval, extra, source))  	{  		ereport(elevel,  				(errcode(GUC_check_errcode_value),  				 GUC_check_errmsg_string ?  				 errmsg_internal("%s", GUC_check_errmsg_string) :  				 errmsg("invalid value for parameter \"%s\": %g", -						conf->gen.name, *newval), +						conf->name, *newval),  				 GUC_check_errdetail_string ?  				 errdetail_internal("%s", GUC_check_errdetail_string) : 0,  				 GUC_check_errhint_string ? @@ -6812,13 +6729,13 @@ call_real_check_hook(const struct config_real *conf, double *newval, void **extr  }  static bool -call_string_check_hook(const struct config_string *conf, char **newval, void **extra, +call_string_check_hook(const struct config_generic *conf, char **newval, void **extra,  					   GucSource source, int elevel)  {  	volatile bool result = true;  	/* Quick success if no hook */ -	if (!conf->check_hook) +	if (!conf->_string.check_hook)  		return true;  	/* @@ -6834,14 +6751,14 @@ call_string_check_hook(const struct config_string *conf, char **newval, void **e  		GUC_check_errdetail_string = NULL;  		GUC_check_errhint_string = NULL; -		if (!conf->check_hook(newval, extra, source)) +		if (!conf->_string.check_hook(newval, extra, source))  		{  			ereport(elevel,  					(errcode(GUC_check_errcode_value),  					 GUC_check_errmsg_string ?  					 errmsg_internal("%s", GUC_check_errmsg_string) :  					 errmsg("invalid value for parameter \"%s\": \"%s\"", -							conf->gen.name, *newval ? *newval : ""), +							conf->name, *newval ? *newval : ""),  					 GUC_check_errdetail_string ?  					 errdetail_internal("%s", GUC_check_errdetail_string) : 0,  					 GUC_check_errhint_string ? @@ -6862,11 +6779,11 @@ call_string_check_hook(const struct config_string *conf, char **newval, void **e  }  static bool -call_enum_check_hook(const struct config_enum *conf, int *newval, void **extra, +call_enum_check_hook(const struct config_generic *conf, int *newval, void **extra,  					 GucSource source, int elevel)  {  	/* Quick success if no hook */ -	if (!conf->check_hook) +	if (!conf->_enum.check_hook)  		return true;  	/* Reset variables that might be set by hook */ @@ -6875,14 +6792,14 @@ call_enum_check_hook(const struct config_enum *conf, int *newval, void **extra,  	GUC_check_errdetail_string = NULL;  	GUC_check_errhint_string = NULL; -	if (!conf->check_hook(newval, extra, source)) +	if (!conf->_enum.check_hook(newval, extra, source))  	{  		ereport(elevel,  				(errcode(GUC_check_errcode_value),  				 GUC_check_errmsg_string ?  				 errmsg_internal("%s", GUC_check_errmsg_string) :  				 errmsg("invalid value for parameter \"%s\": \"%s\"", -						conf->gen.name, +						conf->name,  						config_enum_lookup_by_value(conf, *newval)),  				 GUC_check_errdetail_string ?  				 errdetail_internal("%s", GUC_check_errdetail_string) : 0, diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c index d7a822e1462..4f58fa3d4e0 100644 --- a/src/backend/utils/misc/guc_funcs.c +++ b/src/backend/utils/misc/guc_funcs.c @@ -629,7 +629,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)  	{  		case PGC_BOOL:  			{ -				const struct config_bool *lconf = (const struct config_bool *) conf; +				const struct config_bool *lconf = &conf->_bool;  				/* min_val */  				values[9] = NULL; @@ -650,7 +650,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)  		case PGC_INT:  			{ -				const struct config_int *lconf = (const struct config_int *) conf; +				const struct config_int *lconf = &conf->_int;  				/* min_val */  				snprintf(buffer, sizeof(buffer), "%d", lconf->min); @@ -675,7 +675,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)  		case PGC_REAL:  			{ -				const struct config_real *lconf = (const struct config_real *) conf; +				const struct config_real *lconf = &conf->_real;  				/* min_val */  				snprintf(buffer, sizeof(buffer), "%g", lconf->min); @@ -700,7 +700,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)  		case PGC_STRING:  			{ -				const struct config_string *lconf = (const struct config_string *) conf; +				const struct config_string *lconf = &conf->_string;  				/* min_val */  				values[9] = NULL; @@ -727,7 +727,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)  		case PGC_ENUM:  			{ -				const struct config_enum *lconf = (const struct config_enum *) conf; +				const struct config_enum *lconf = &conf->_enum;  				/* min_val */  				values[9] = NULL; @@ -745,11 +745,11 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)  													 "{\"", "\"}", "\",\"");  				/* boot_val */ -				values[12] = pstrdup(config_enum_lookup_by_value(lconf, +				values[12] = pstrdup(config_enum_lookup_by_value(conf,  																 lconf->boot_val));  				/* reset_val */ -				values[13] = pstrdup(config_enum_lookup_by_value(lconf, +				values[13] = pstrdup(config_enum_lookup_by_value(conf,  																 lconf->reset_val));  			}  			break; diff --git a/src/backend/utils/misc/help_config.c b/src/backend/utils/misc/help_config.c index 86812ac881f..2810715693c 100644 --- a/src/backend/utils/misc/help_config.c +++ b/src/backend/utils/misc/help_config.c @@ -23,23 +23,8 @@  #include "utils/help_config.h" -/* - * This union allows us to mix the numerous different types of structs - * that we are organizing. - */ -typedef union -{ -	struct config_generic generic; -	struct config_bool _bool; -	struct config_real real; -	struct config_int integer; -	struct config_string string; -	struct config_enum _enum; -} mixedStruct; - - -static void printMixedStruct(mixedStruct *structToPrint); -static bool displayStruct(mixedStruct *structToDisplay); +static void printMixedStruct(const struct config_generic *structToPrint); +static bool displayStruct(const struct config_generic *structToDisplay);  void @@ -55,7 +40,7 @@ GucInfoMain(void)  	for (int i = 0; i < numOpts; i++)  	{ -		mixedStruct *var = (mixedStruct *) guc_vars[i]; +		const struct config_generic *var = guc_vars[i];  		if (displayStruct(var))  			printMixedStruct(var); @@ -70,11 +55,11 @@ GucInfoMain(void)   * should be displayed to the user.   */  static bool -displayStruct(mixedStruct *structToDisplay) +displayStruct(const struct config_generic *structToDisplay)  { -	return !(structToDisplay->generic.flags & (GUC_NO_SHOW_ALL | -											   GUC_NOT_IN_SAMPLE | -											   GUC_DISALLOW_IN_FILE)); +	return !(structToDisplay->flags & (GUC_NO_SHOW_ALL | +									   GUC_NOT_IN_SAMPLE | +									   GUC_DISALLOW_IN_FILE));  } @@ -83,14 +68,14 @@ displayStruct(mixedStruct *structToDisplay)   * a different format, depending on what the user wants to see.   */  static void -printMixedStruct(mixedStruct *structToPrint) +printMixedStruct(const struct config_generic *structToPrint)  {  	printf("%s\t%s\t%s\t", -		   structToPrint->generic.name, -		   GucContext_Names[structToPrint->generic.context], -		   _(config_group_names[structToPrint->generic.group])); +		   structToPrint->name, +		   GucContext_Names[structToPrint->context], +		   _(config_group_names[structToPrint->group])); -	switch (structToPrint->generic.vartype) +	switch (structToPrint->vartype)  	{  		case PGC_BOOL: @@ -101,26 +86,26 @@ printMixedStruct(mixedStruct *structToPrint)  		case PGC_INT:  			printf("INTEGER\t%d\t%d\t%d\t", -				   structToPrint->integer.reset_val, -				   structToPrint->integer.min, -				   structToPrint->integer.max); +				   structToPrint->_int.reset_val, +				   structToPrint->_int.min, +				   structToPrint->_int.max);  			break;  		case PGC_REAL:  			printf("REAL\t%g\t%g\t%g\t", -				   structToPrint->real.reset_val, -				   structToPrint->real.min, -				   structToPrint->real.max); +				   structToPrint->_real.reset_val, +				   structToPrint->_real.min, +				   structToPrint->_real.max);  			break;  		case PGC_STRING:  			printf("STRING\t%s\t\t\t", -				   structToPrint->string.boot_val ? structToPrint->string.boot_val : ""); +				   structToPrint->_string.boot_val ? structToPrint->_string.boot_val : "");  			break;  		case PGC_ENUM:  			printf("ENUM\t%s\t\t\t", -				   config_enum_lookup_by_value(&structToPrint->_enum, +				   config_enum_lookup_by_value(structToPrint,  											   structToPrint->_enum.boot_val));  			break; @@ -130,6 +115,6 @@ printMixedStruct(mixedStruct *structToPrint)  	}  	printf("%s\t%s\n", -		   (structToPrint->generic.short_desc == NULL) ? "" : _(structToPrint->generic.short_desc), -		   (structToPrint->generic.long_desc == NULL) ? "" : _(structToPrint->generic.long_desc)); +		   (structToPrint->short_desc == NULL) ? "" : _(structToPrint->short_desc), +		   (structToPrint->long_desc == NULL) ? "" : _(structToPrint->long_desc));  } diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h index 3de3d809545..bbfcc633014 100644 --- a/src/include/utils/guc_tables.h +++ b/src/include/utils/guc_tables.h @@ -132,6 +132,84 @@ typedef struct guc_stack  	config_var_value masked;	/* SET value in a GUC_SET_LOCAL entry */  } GucStack; + +/* GUC records for specific variable types */ + +struct config_bool +{ +	/* constant fields, must be set correctly in initial value: */ +	bool	   *variable; +	bool		boot_val; +	GucBoolCheckHook check_hook; +	GucBoolAssignHook assign_hook; +	GucShowHook show_hook; +	/* variable fields, initialized at runtime: */ +	bool		reset_val; +}; + +struct config_int +{ +	/* constant fields, must be set correctly in initial value: */ +	int		   *variable; +	int			boot_val; +	int			min; +	int			max; +	GucIntCheckHook check_hook; +	GucIntAssignHook assign_hook; +	GucShowHook show_hook; +	/* variable fields, initialized at runtime: */ +	int			reset_val; +}; + +struct config_real +{ +	/* constant fields, must be set correctly in initial value: */ +	double	   *variable; +	double		boot_val; +	double		min; +	double		max; +	GucRealCheckHook check_hook; +	GucRealAssignHook assign_hook; +	GucShowHook show_hook; +	/* variable fields, initialized at runtime: */ +	double		reset_val; +}; + +/* + * A note about string GUCs: the boot_val is allowed to be NULL, which leads + * to the reset_val and the actual variable value (*variable) also being NULL. + * However, there is no way to set a NULL value subsequently using + * set_config_option or any other GUC API.  Also, GUC APIs such as SHOW will + * display a NULL value as an empty string.  Callers that choose to use a NULL + * boot_val should overwrite the setting later in startup, or else be careful + * that NULL doesn't have semantics that are visibly different from an empty + * string. + */ +struct config_string +{ +	/* constant fields, must be set correctly in initial value: */ +	char	  **variable; +	const char *boot_val; +	GucStringCheckHook check_hook; +	GucStringAssignHook assign_hook; +	GucShowHook show_hook; +	/* variable fields, initialized at runtime: */ +	char	   *reset_val; +}; + +struct config_enum +{ +	/* constant fields, must be set correctly in initial value: */ +	int		   *variable; +	int			boot_val; +	const struct config_enum_entry *options; +	GucEnumCheckHook check_hook; +	GucEnumAssignHook assign_hook; +	GucShowHook show_hook; +	/* variable fields, initialized at runtime: */ +	int			reset_val; +}; +  /*   * Generic fields applicable to all types of variables   * @@ -200,6 +278,16 @@ struct config_generic  	char	   *sourcefile;		/* file current setting is from (NULL if not  								 * set in config file) */  	int			sourceline;		/* line in source file */ + +	/* fields for specific variable types */ +	union +	{ +		struct config_bool _bool; +		struct config_int _int; +		struct config_real _real; +		struct config_string _string; +		struct config_enum _enum; +	};  };  /* bit values in status field */ @@ -212,100 +300,14 @@ struct config_generic  #define GUC_NEEDS_REPORT	0x0004	/* new value must be reported to client */ -/* GUC records for specific variable types */ - -struct config_bool -{ -	struct config_generic gen; -	/* constant fields, must be set correctly in initial value: */ -	bool	   *variable; -	bool		boot_val; -	GucBoolCheckHook check_hook; -	GucBoolAssignHook assign_hook; -	GucShowHook show_hook; -	/* variable fields, initialized at runtime: */ -	bool		reset_val; -}; - -struct config_int -{ -	struct config_generic gen; -	/* constant fields, must be set correctly in initial value: */ -	int		   *variable; -	int			boot_val; -	int			min; -	int			max; -	GucIntCheckHook check_hook; -	GucIntAssignHook assign_hook; -	GucShowHook show_hook; -	/* variable fields, initialized at runtime: */ -	int			reset_val; -}; - -struct config_real -{ -	struct config_generic gen; -	/* constant fields, must be set correctly in initial value: */ -	double	   *variable; -	double		boot_val; -	double		min; -	double		max; -	GucRealCheckHook check_hook; -	GucRealAssignHook assign_hook; -	GucShowHook show_hook; -	/* variable fields, initialized at runtime: */ -	double		reset_val; -}; - -/* - * A note about string GUCs: the boot_val is allowed to be NULL, which leads - * to the reset_val and the actual variable value (*variable) also being NULL. - * However, there is no way to set a NULL value subsequently using - * set_config_option or any other GUC API.  Also, GUC APIs such as SHOW will - * display a NULL value as an empty string.  Callers that choose to use a NULL - * boot_val should overwrite the setting later in startup, or else be careful - * that NULL doesn't have semantics that are visibly different from an empty - * string. - */ -struct config_string -{ -	struct config_generic gen; -	/* constant fields, must be set correctly in initial value: */ -	char	  **variable; -	const char *boot_val; -	GucStringCheckHook check_hook; -	GucStringAssignHook assign_hook; -	GucShowHook show_hook; -	/* variable fields, initialized at runtime: */ -	char	   *reset_val; -}; - -struct config_enum -{ -	struct config_generic gen; -	/* constant fields, must be set correctly in initial value: */ -	int		   *variable; -	int			boot_val; -	const struct config_enum_entry *options; -	GucEnumCheckHook check_hook; -	GucEnumAssignHook assign_hook; -	GucShowHook show_hook; -	/* variable fields, initialized at runtime: */ -	int			reset_val; -}; -  /* constant tables corresponding to enums above and in guc.h */  extern PGDLLIMPORT const char *const config_group_names[];  extern PGDLLIMPORT const char *const config_type_names[];  extern PGDLLIMPORT const char *const GucContext_Names[];  extern PGDLLIMPORT const char *const GucSource_Names[]; -/* data arrays defining all the built-in GUC variables */ -extern PGDLLIMPORT struct config_bool ConfigureNamesBool[]; -extern PGDLLIMPORT struct config_int ConfigureNamesInt[]; -extern PGDLLIMPORT struct config_real ConfigureNamesReal[]; -extern PGDLLIMPORT struct config_string ConfigureNamesString[]; -extern PGDLLIMPORT struct config_enum ConfigureNamesEnum[]; +/* data array defining all the built-in GUC variables */ +extern PGDLLIMPORT struct config_generic ConfigureNames[];  /* lookup GUC variables, returning config_generic pointers */  extern struct config_generic *find_option(const char *name, @@ -326,7 +328,7 @@ extern struct config_generic **get_guc_variables(int *num_vars);  extern void build_guc_variables(void);  /* search in enum options */ -extern const char *config_enum_lookup_by_value(const struct config_enum *record, int val); +extern const char *config_enum_lookup_by_value(const struct config_generic *record, int val);  extern bool config_enum_lookup_by_name(const struct config_enum *record,  									   const char *value, int *retval);  extern char *config_enum_get_options(const struct config_enum *record, diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index bb4e1b37005..ac2da4c98cf 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -3808,7 +3808,6 @@ memoize_iterator  metastring  missing_cache_key  mix_data_t -mixedStruct  mode_t  movedb_failure_params  multirange_bsearch_comparison  | 
