Skip to content

Commit 3b4f9fe

Browse files
committed
The appended patch addresses the outstanding issues of the recent guc patch.
It makes PGCLIENTENCODING work again and uses bsearch() instead of iterating over the array of guc variables in guc_get_index(). Joachim Wieland
1 parent 067deaf commit 3b4f9fe

File tree

1 file changed

+28
-15
lines changed
  • src/backend/utils/misc

1 file changed

+28
-15
lines changed

src/backend/utils/misc/guc.c

Lines changed: 28 additions & 15 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.390 2007/05/04 01:13:44 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.391 2007/05/08 16:33:51 petere Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -2692,18 +2692,6 @@ add_guc_variable(struct config_generic * var, int elevel)
26922692
return true;
26932693
}
26942694

2695-
static int
2696-
guc_get_index(const char *name)
2697-
{
2698-
int i;
2699-
2700-
for (i = 0; i < num_guc_variables; i++)
2701-
if (guc_name_compare(name, guc_variables[i]->name) == 0)
2702-
return i;
2703-
2704-
return -1;
2705-
}
2706-
27072695
/*
27082696
* Create and add a placeholder variable. It's presumed to belong
27092697
* to a valid custom variable class at this point.
@@ -2843,6 +2831,30 @@ guc_name_compare(const char *namea, const char *nameb)
28432831
}
28442832

28452833

2834+
static int
2835+
guc_get_index(const char *name)
2836+
{
2837+
const char **key = &name;
2838+
struct config_generic **res;
2839+
2840+
Assert(name);
2841+
2842+
/*
2843+
* By equating const char ** with struct config_generic *, we are assuming
2844+
* the name field is first in config_generic.
2845+
*/
2846+
res = (struct config_generic **) bsearch((void *) &key,
2847+
(void *) guc_variables,
2848+
num_guc_variables,
2849+
sizeof(struct config_generic *),
2850+
guc_var_compare);
2851+
if (!res)
2852+
return -1;
2853+
2854+
return res - guc_variables;
2855+
}
2856+
2857+
28462858
/*
28472859
* Initialize GUC options during program startup.
28482860
*
@@ -4095,9 +4107,10 @@ set_config_option(const char *name, const char *value,
40954107
* we can't set the variable itself. There's one exception to
40964108
* this rule: if we want to apply the default value to variables
40974109
* that were removed from the configuration file. This is
4098-
* indicated by source == PGC_S_DEFAULT.
4110+
* indicated by source == PGC_S_DEFAULT and context == PGC_SIGHUP.
40994111
*/
4100-
if (record->source > source && source != PGC_S_DEFAULT)
4112+
if (record->source > source
4113+
&& !(source == PGC_S_DEFAULT && context == PGC_SIGHUP))
41014114
{
41024115
if (changeVal && !makeDefault)
41034116
{

0 commit comments

Comments
 (0)