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#ifdef EXEC_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+ static void
6688+ write_one_nondefault_variable (FILE * fp ,struct config_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+ case PGC_BOOL :
6699+ {
6700+ struct config_bool * conf = (struct config_bool * )gconf ;
6701+
6702+ if (* conf -> variable )
6703+ fprintf (fp ,"true" );
6704+ else
6705+ fprintf (fp ,"false" );
6706+ }
6707+ break ;
6708+
6709+ case PGC_INT :
6710+ {
6711+ struct config_int * conf = (struct config_int * )gconf ;
6712+
6713+ fprintf (fp ,"%d" ,* conf -> variable );
6714+ }
6715+ break ;
6716+
6717+ case PGC_REAL :
6718+ {
6719+ struct config_real * conf = (struct config_real * )gconf ;
6720+
6721+ /* Could lose precision here? */
6722+ fprintf (fp ,"%f" ,* conf -> variable );
6723+ }
6724+ break ;
6725+
6726+ case PGC_STRING :
6727+ {
6728+ struct config_string * conf = (struct config_string * )gconf ;
6729+
6730+ fprintf (fp ,"%s" ,* conf -> variable );
6731+ }
6732+ break ;
6733+
6734+ case PGC_ENUM :
6735+ {
6736+ struct config_enum * conf = (struct config_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+
66876749void
66886750write_nondefault_variables (GucContext context )
66896751{
6690- int i ;
66916752int elevel ;
66926753FILE * fp ;
6754+ struct config_generic * cvc_conf ;
6755+ int i ;
66936756
66946757Assert (context == PGC_POSTMASTER || context == PGC_SIGHUP );
66956758
@@ -6708,66 +6771,20 @@ write_nondefault_variables(GucContext context)
67086771return ;
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+
67116782for (i = 0 ;i < num_guc_variables ;i ++ )
67126783{
67136784struct config_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- case PGC_BOOL :
6723- {
6724- struct config_bool * conf = (struct config_bool * )gconf ;
6725-
6726- if (* conf -> variable == 0 )
6727- fprintf (fp ,"false" );
6728- else
6729- fprintf (fp ,"true" );
6730- }
6731- break ;
6732-
6733- case PGC_INT :
6734- {
6735- struct config_int * conf = (struct config_int * )gconf ;
6736-
6737- fprintf (fp ,"%d" ,* conf -> variable );
6738- }
6739- break ;
6740-
6741- case PGC_REAL :
6742- {
6743- struct config_real * conf = (struct config_real * )gconf ;
6744-
6745- /* Could lose precision here? */
6746- fprintf (fp ,"%f" ,* conf -> variable );
6747- }
6748- break ;
6749-
6750- case PGC_STRING :
6751- {
6752- struct config_string * conf = (struct config_string * )gconf ;
6753-
6754- fprintf (fp ,"%s" ,* conf -> variable );
6755- }
6756- break ;
6757-
6758- case PGC_ENUM :
6759- {
6760- struct config_enum * conf = (struct config_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
67736790if (FreeFile (fp ))