Skip to content

Commit 31ec957

Browse files
committed
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 ...
1 parent cd35e9d commit 31ec957

File tree

1 file changed

+25
-2
lines changed
  • src/backend/utils/misc

1 file changed

+25
-2
lines changed

src/backend/utils/misc/guc.c

+25-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <[email protected]>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.478 2008/11/19 01:10:23 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.479 2008/11/19 02:07:07 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -5657,6 +5657,7 @@ define_custom_variable(struct config_generic * variable)
56575657
const char **nameAddr = &name;
56585658
const char *value;
56595659
struct config_string *pHolder;
5660+
GucContext phcontext;
56605661
struct 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

57145737
if (value)
57155738
set_config_option(name, value,
5716-
pHolder->gen.context, pHolder->gen.source,
5739+
phcontext, pHolder->gen.source,
57175740
GUC_ACTION_SET, true);
57185741

57195742
/*

0 commit comments

Comments
 (0)