Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbdcc757

Browse files
committed
write_nondefault_variables must take care to write custom_variable_classes
first; otherwise backends reading the file might reject values of customvariables. Per experimentation with auto_explain.
1 parentccdb662 commitbdcc757

File tree

1 file changed

+76
-59
lines changed
  • src/backend/utils/misc

1 file changed

+76
-59
lines changed

‎src/backend/utils/misc/guc.c

Lines changed: 76 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.485 2009/01/0201:16:02 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.486 2009/01/0202:02:10 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -6677,19 +6677,82 @@ is_newvalue_equal(struct config_generic * record, const char *newvalue)
66776677
#ifdefEXEC_BACKEND
66786678

66796679
/*
6680-
*This routine dumps out all non-default GUC options into a binary
6680+
*These routines dump out all non-default GUC options into a binary
66816681
*file that is read by all exec'ed backends. The format is:
66826682
*
66836683
*variable name, string, null terminated
66846684
*variable value, string, null terminated
66856685
*variable source, integer
66866686
*/
6687+
staticvoid
6688+
write_one_nondefault_variable(FILE*fp,structconfig_generic*gconf)
6689+
{
6690+
if (gconf->source==PGC_S_DEFAULT)
6691+
return;
6692+
6693+
fprintf(fp,"%s",gconf->name);
6694+
fputc(0,fp);
6695+
6696+
switch (gconf->vartype)
6697+
{
6698+
casePGC_BOOL:
6699+
{
6700+
structconfig_bool*conf= (structconfig_bool*)gconf;
6701+
6702+
if (*conf->variable)
6703+
fprintf(fp,"true");
6704+
else
6705+
fprintf(fp,"false");
6706+
}
6707+
break;
6708+
6709+
casePGC_INT:
6710+
{
6711+
structconfig_int*conf= (structconfig_int*)gconf;
6712+
6713+
fprintf(fp,"%d",*conf->variable);
6714+
}
6715+
break;
6716+
6717+
casePGC_REAL:
6718+
{
6719+
structconfig_real*conf= (structconfig_real*)gconf;
6720+
6721+
/* Could lose precision here? */
6722+
fprintf(fp,"%f",*conf->variable);
6723+
}
6724+
break;
6725+
6726+
casePGC_STRING:
6727+
{
6728+
structconfig_string*conf= (structconfig_string*)gconf;
6729+
6730+
fprintf(fp,"%s",*conf->variable);
6731+
}
6732+
break;
6733+
6734+
casePGC_ENUM:
6735+
{
6736+
structconfig_enum*conf= (structconfig_enum*)gconf;
6737+
6738+
fprintf(fp,"%s",
6739+
config_enum_lookup_by_value(conf,*conf->variable));
6740+
}
6741+
break;
6742+
}
6743+
6744+
fputc(0,fp);
6745+
6746+
fwrite(&gconf->source,sizeof(gconf->source),1,fp);
6747+
}
6748+
66876749
void
66886750
write_nondefault_variables(GucContextcontext)
66896751
{
6690-
inti;
66916752
intelevel;
66926753
FILE*fp;
6754+
structconfig_generic*cvc_conf;
6755+
inti;
66936756

66946757
Assert(context==PGC_POSTMASTER||context==PGC_SIGHUP);
66956758

@@ -6708,66 +6771,20 @@ write_nondefault_variables(GucContext context)
67086771
return;
67096772
}
67106773

6774+
/*
6775+
* custom_variable_classes must be written out first; otherwise we might
6776+
* reject custom variable values while reading the file.
6777+
*/
6778+
cvc_conf=find_option("custom_variable_classes", false,ERROR);
6779+
if (cvc_conf)
6780+
write_one_nondefault_variable(fp,cvc_conf);
6781+
67116782
for (i=0;i<num_guc_variables;i++)
67126783
{
67136784
structconfig_generic*gconf=guc_variables[i];
67146785

6715-
if (gconf->source!=PGC_S_DEFAULT)
6716-
{
6717-
fprintf(fp,"%s",gconf->name);
6718-
fputc(0,fp);
6719-
6720-
switch (gconf->vartype)
6721-
{
6722-
casePGC_BOOL:
6723-
{
6724-
structconfig_bool*conf= (structconfig_bool*)gconf;
6725-
6726-
if (*conf->variable==0)
6727-
fprintf(fp,"false");
6728-
else
6729-
fprintf(fp,"true");
6730-
}
6731-
break;
6732-
6733-
casePGC_INT:
6734-
{
6735-
structconfig_int*conf= (structconfig_int*)gconf;
6736-
6737-
fprintf(fp,"%d",*conf->variable);
6738-
}
6739-
break;
6740-
6741-
casePGC_REAL:
6742-
{
6743-
structconfig_real*conf= (structconfig_real*)gconf;
6744-
6745-
/* Could lose precision here? */
6746-
fprintf(fp,"%f",*conf->variable);
6747-
}
6748-
break;
6749-
6750-
casePGC_STRING:
6751-
{
6752-
structconfig_string*conf= (structconfig_string*)gconf;
6753-
6754-
fprintf(fp,"%s",*conf->variable);
6755-
}
6756-
break;
6757-
6758-
casePGC_ENUM:
6759-
{
6760-
structconfig_enum*conf= (structconfig_enum*)gconf;
6761-
6762-
fprintf(fp,"%s",config_enum_lookup_by_value(conf,*conf->variable));
6763-
}
6764-
break;
6765-
}
6766-
6767-
fputc(0,fp);
6768-
6769-
fwrite(&gconf->source,sizeof(gconf->source),1,fp);
6770-
}
6786+
if (gconf!=cvc_conf)
6787+
write_one_nondefault_variable(fp,gconf);
67716788
}
67726789

67736790
if (FreeFile(fp))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp