mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
write_nondefault_variables must take care to write custom_variable_classes
first; otherwise backends reading the file might reject values of custom variables. Per experimentation with auto_explain.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.485 2009/01/02 01:16:02 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.486 2009/01/02 02:02:10 tgl Exp $
|
||||
*
|
||||
*--------------------------------------------------------------------
|
||||
*/
|
||||
@ -6677,43 +6677,19 @@ is_newvalue_equal(struct config_generic * record, const char *newvalue)
|
||||
#ifdef EXEC_BACKEND
|
||||
|
||||
/*
|
||||
* This routine dumps out all non-default GUC options into a binary
|
||||
* These routines dump out all non-default GUC options into a binary
|
||||
* file that is read by all exec'ed backends. The format is:
|
||||
*
|
||||
* variable name, string, null terminated
|
||||
* variable value, string, null terminated
|
||||
* variable source, integer
|
||||
*/
|
||||
void
|
||||
write_nondefault_variables(GucContext context)
|
||||
static void
|
||||
write_one_nondefault_variable(FILE *fp, struct config_generic *gconf)
|
||||
{
|
||||
int i;
|
||||
int elevel;
|
||||
FILE *fp;
|
||||
|
||||
Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
|
||||
|
||||
elevel = (context == PGC_SIGHUP) ? LOG : ERROR;
|
||||
|
||||
/*
|
||||
* Open file
|
||||
*/
|
||||
fp = AllocateFile(CONFIG_EXEC_PARAMS_NEW, "w");
|
||||
if (!fp)
|
||||
{
|
||||
ereport(elevel,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to file \"%s\": %m",
|
||||
CONFIG_EXEC_PARAMS_NEW)));
|
||||
if (gconf->source == PGC_S_DEFAULT)
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_guc_variables; i++)
|
||||
{
|
||||
struct config_generic *gconf = guc_variables[i];
|
||||
|
||||
if (gconf->source != PGC_S_DEFAULT)
|
||||
{
|
||||
fprintf(fp, "%s", gconf->name);
|
||||
fputc(0, fp);
|
||||
|
||||
@ -6723,10 +6699,10 @@ write_nondefault_variables(GucContext context)
|
||||
{
|
||||
struct config_bool *conf = (struct config_bool *) gconf;
|
||||
|
||||
if (*conf->variable == 0)
|
||||
fprintf(fp, "false");
|
||||
else
|
||||
if (*conf->variable)
|
||||
fprintf(fp, "true");
|
||||
else
|
||||
fprintf(fp, "false");
|
||||
}
|
||||
break;
|
||||
|
||||
@ -6759,7 +6735,8 @@ write_nondefault_variables(GucContext context)
|
||||
{
|
||||
struct config_enum *conf = (struct config_enum *) gconf;
|
||||
|
||||
fprintf(fp, "%s", config_enum_lookup_by_value(conf, *conf->variable));
|
||||
fprintf(fp, "%s",
|
||||
config_enum_lookup_by_value(conf, *conf->variable));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -6767,7 +6744,47 @@ write_nondefault_variables(GucContext context)
|
||||
fputc(0, fp);
|
||||
|
||||
fwrite(&gconf->source, sizeof(gconf->source), 1, fp);
|
||||
}
|
||||
|
||||
void
|
||||
write_nondefault_variables(GucContext context)
|
||||
{
|
||||
int elevel;
|
||||
FILE *fp;
|
||||
struct config_generic *cvc_conf;
|
||||
int i;
|
||||
|
||||
Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
|
||||
|
||||
elevel = (context == PGC_SIGHUP) ? LOG : ERROR;
|
||||
|
||||
/*
|
||||
* Open file
|
||||
*/
|
||||
fp = AllocateFile(CONFIG_EXEC_PARAMS_NEW, "w");
|
||||
if (!fp)
|
||||
{
|
||||
ereport(elevel,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to file \"%s\": %m",
|
||||
CONFIG_EXEC_PARAMS_NEW)));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* custom_variable_classes must be written out first; otherwise we might
|
||||
* reject custom variable values while reading the file.
|
||||
*/
|
||||
cvc_conf = find_option("custom_variable_classes", false, ERROR);
|
||||
if (cvc_conf)
|
||||
write_one_nondefault_variable(fp, cvc_conf);
|
||||
|
||||
for (i = 0; i < num_guc_variables; i++)
|
||||
{
|
||||
struct config_generic *gconf = guc_variables[i];
|
||||
|
||||
if (gconf != cvc_conf)
|
||||
write_one_nondefault_variable(fp, gconf);
|
||||
}
|
||||
|
||||
if (FreeFile(fp))
|
||||
|
Reference in New Issue
Block a user