1010 * Written by Peter Eisentraut <peter_e@gmx.net>.
1111 *
1212 * IDENTIFICATION
13- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.478 2008/11/1901:10:23 tgl Exp $
13+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.479 2008/11/1902:07:07 tgl Exp $
1414 *
1515 *--------------------------------------------------------------------
1616 */
@@ -5657,6 +5657,7 @@ define_custom_variable(struct config_generic * variable)
56575657const char * * nameAddr = & name ;
56585658const char * value ;
56595659struct config_string * pHolder ;
5660+ GucContext phcontext ;
56605661struct config_generic * * res ;
56615662
56625663/*
@@ -5702,6 +5703,28 @@ define_custom_variable(struct config_generic * variable)
57025703 */
57035704* res = variable ;
57045705
5706+ /*
5707+ * Infer context for assignment based on source of existing value.
5708+ * We can't tell this with exact accuracy, but we can at least do
5709+ * something reasonable in typical cases.
5710+ */
5711+ switch (pHolder -> gen .source )
5712+ {
5713+ case PGC_S_DEFAULT :
5714+ case PGC_S_ENV_VAR :
5715+ case PGC_S_FILE :
5716+ case PGC_S_ARGV :
5717+ phcontext = PGC_SIGHUP ;
5718+ break ;
5719+ case PGC_S_DATABASE :
5720+ case PGC_S_USER :
5721+ case PGC_S_CLIENT :
5722+ case PGC_S_SESSION :
5723+ default :
5724+ phcontext = PGC_USERSET ;
5725+ break ;
5726+ }
5727+
57055728/*
57065729 * Assign the string value stored in the placeholder to the real variable.
57075730 *
@@ -5713,7 +5736,7 @@ define_custom_variable(struct config_generic * variable)
57135736
57145737if (value )
57155738set_config_option (name ,value ,
5716- pHolder -> gen . context ,pHolder -> gen .source ,
5739+ phcontext ,pHolder -> gen .source ,
57175740GUC_ACTION_SET , true);
57185741
57195742/*