aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-11-19 02:07:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-11-19 02:07:07 +0000
commit31ec957a1500380d7f9a9e81cd344cc680ca67f6 (patch)
tree57ef15c44a89edc8be65b7ed79df98ee5218aa76 /src
parentcd35e9d7468e8f86dd5a7d928707f4ba8cdae44d (diff)
downloadpostgresql-31ec957a1500380d7f9a9e81cd344cc680ca67f6.tar.gz
postgresql-31ec957a1500380d7f9a9e81cd344cc680ca67f6.zip
Fix define_custom_variable so that SUSET custom variables behave
somewhat reasonably. It's not perfect, but it beats the kluge proposed in the auto-explain patch ...
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/misc/guc.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 3e967527bfe..2d1babc5aeb 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.478 2008/11/19 01:10:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.479 2008/11/19 02:07:07 tgl Exp $
*
*--------------------------------------------------------------------
*/
@@ -5657,6 +5657,7 @@ define_custom_variable(struct config_generic * variable)
const char **nameAddr = &name;
const char *value;
struct config_string *pHolder;
+ GucContext phcontext;
struct config_generic **res;
/*
@@ -5703,6 +5704,28 @@ define_custom_variable(struct config_generic * variable)
*res = variable;
/*
+ * Infer context for assignment based on source of existing value.
+ * We can't tell this with exact accuracy, but we can at least do
+ * something reasonable in typical cases.
+ */
+ switch (pHolder->gen.source)
+ {
+ case PGC_S_DEFAULT:
+ case PGC_S_ENV_VAR:
+ case PGC_S_FILE:
+ case PGC_S_ARGV:
+ phcontext = PGC_SIGHUP;
+ break;
+ case PGC_S_DATABASE:
+ case PGC_S_USER:
+ case PGC_S_CLIENT:
+ case PGC_S_SESSION:
+ default:
+ phcontext = PGC_USERSET;
+ break;
+ }
+
+ /*
* Assign the string value stored in the placeholder to the real variable.
*
* XXX this is not really good enough --- it should be a nontransactional
@@ -5713,7 +5736,7 @@ define_custom_variable(struct config_generic * variable)
if (value)
set_config_option(name, value,
- pHolder->gen.context, pHolder->gen.source,
+ phcontext, pHolder->gen.source,
GUC_ACTION_SET, true);
/*