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:
parent
ccdb6627ee
commit
bdcc7576f4
|
@ -10,7 +10,7 @@
|
||||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
#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:
|
* file that is read by all exec'ed backends. The format is:
|
||||||
*
|
*
|
||||||
* variable name, string, null terminated
|
* variable name, string, null terminated
|
||||||
* variable value, string, null terminated
|
* variable value, string, null terminated
|
||||||
* variable source, integer
|
* variable source, integer
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
write_nondefault_variables(GucContext context)
|
write_one_nondefault_variable(FILE *fp, struct config_generic *gconf)
|
||||||
{
|
{
|
||||||
int i;
|
if (gconf->source == PGC_S_DEFAULT)
|
||||||
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)));
|
|
||||||
return;
|
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);
|
fprintf(fp, "%s", gconf->name);
|
||||||
fputc(0, fp);
|
fputc(0, fp);
|
||||||
|
|
||||||
|
@ -6723,10 +6699,10 @@ write_nondefault_variables(GucContext context)
|
||||||
{
|
{
|
||||||
struct config_bool *conf = (struct config_bool *) gconf;
|
struct config_bool *conf = (struct config_bool *) gconf;
|
||||||
|
|
||||||
if (*conf->variable == 0)
|
if (*conf->variable)
|
||||||
fprintf(fp, "false");
|
|
||||||
else
|
|
||||||
fprintf(fp, "true");
|
fprintf(fp, "true");
|
||||||
|
else
|
||||||
|
fprintf(fp, "false");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -6759,7 +6735,8 @@ write_nondefault_variables(GucContext context)
|
||||||
{
|
{
|
||||||
struct config_enum *conf = (struct config_enum *) gconf;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6768,6 +6745,46 @@ write_nondefault_variables(GucContext context)
|
||||||
|
|
||||||
fwrite(&gconf->source, sizeof(gconf->source), 1, 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))
|
if (FreeFile(fp))
|
||||||
|
|
Loading…
Reference in New Issue