There is path implements following item from todo list: "Allow
commenting of variables in postgresql.conf to restore them to defaults".
Main idea is:
General config structure is extend with default_val attribute to keep
really default value. (There is small conflict - for string boot_val has same meaning).
During reconfiguration all values which has reset source equal with
PGC_S_FILE are revert back to really default values. New values from
configuration files are set after this step and commented variables stay
with default value.
Zdenek
Index: src/backend/utils/misc/guc-file.l
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v
retrieving revision 1.37
diff -r1.37 guc-file.l
115c115
< int elevel;
---
int elevel, i;
116a117
char *env;
145a147,182
/* Revert all options with reset source PGC_S_FILE to default value.
* This implementation is easier then implementing some change flag and
verify
* what really was commented out.
* XXX When log_line_prefix is set in configuration file then log output
* is not correct during this phase - prefix is revert to empty value.
*/
for (i = 0; i < num_guc_variables; i++)
{
struct config_generic *gconf = guc_variables[i];
if ( gconf->reset_source == PGC_S_FILE )
{
set_config_option(gconf->name, NULL, context,
PGC_S_FILE, false, true);
}
}
/* Revert to environment variable. PGPORT is ignored, because it cannot be
* set in running state. PGC_S_FILE is used instead PGC_S_ENV so as
* set_config_option can override previous defined option in config file.
* If these options are still in config file They will be overridden in
* the following step.
*/
env = getenv("PGDATESTYLE");
if (env != NULL)
{
set_config_option("datestyle", env, context,
PGC_S_FILE, false, true);
}
env = getenv("PGCLIENTENCODING");
if (env != NULL)
{
set_config_option("client_encoding", env, context,
PGC_S_FILE, false, true);
}
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.319
diff -r1.319 guc.c
2651c2651
< if (!(*conf->assign_hook) (conf->reset_val, true,
---
if (!(*conf->assign_hook) (conf->default_val, true,
2654,2655c2654,2655
< conf->gen.name, (int) conf->reset_val);
< *conf->variable = conf->reset_val;
---
conf->gen.name, (int) conf->default_val);
*conf->variable = conf->reset_val = conf->default_val;
2665c2665
< if (!(*conf->assign_hook) (conf->reset_val, true,
---
if (!(*conf->assign_hook) (conf->default_val, true,
2668,2669c2668,2669
< conf->gen.name, conf->reset_val);
< *conf->variable = conf->reset_val;
---
conf->gen.name, conf->default_val);
*conf->variable = conf->reset_val = conf->default_val;
2679c2679
< if (!(*conf->assign_hook) (conf->reset_val, true,
---
if (!(*conf->assign_hook) (conf->default_val, true,
2682,2683c2682,2683
< conf->gen.name, conf->reset_val);
< *conf->variable = conf->reset_val;
---
conf->gen.name, conf->default_val);
*conf->variable = conf->reset_val = conf->default_val;
3650c3650
< if (changeVal && !is_newvalue_equal(record, value))
---
if (changeVal && value != NULL && !is_newvalue_equal(record,
value))
3726c3726
< makeDefault = changeVal && (source <= PGC_S_OVERRIDE) && (value != NULL);
---
makeDefault = changeVal && (source <= PGC_S_OVERRIDE) && (value != NULL ||
source == PGC_S_FILE);
3769,3770c3769,3781
< newval = conf->reset_val;
< source = conf->gen.reset_source;
---
/* Revert value to default if source is configuration file. It is used when
* configuration parameter is removed/commented out in the
config file. Else
* RESET or SET TO DEFAULT command is called and reset_val is used.
*/
if( source == PGC_S_FILE )
{
newval = conf->default_val;
}
else
{
newval = conf->reset_val;
source = conf->gen.reset_source;
}
3853,3854c3864,3876
< newval = conf->reset_val;
< source = conf->gen.reset_source;
---
/* Revert value to default if source is configuration file. It is used when
* configuration parameter is removed/commented out in the
config file. Else
* RESET or SET TO DEFAULT command is called and reset_val is used.
*/
if( source == PGC_S_FILE )
{
newval = conf->default_val;
}
else
{
newval = conf->reset_val;
source = conf->gen.reset_source;
}
3937,3938c3959,3971
< newval = conf->reset_val;
< source = conf->gen.reset_source;
---
/* Revert value to default if source is configuration file. It is used when
* configuration parameter is removed/commented out in the
config file. Else
* RESET or SET TO DEFAULT command is called and reset_val is used.
*/
if( source == PGC_S_FILE )
{
newval = conf->default_val;
}
else
{
newval = conf->reset_val;
source = conf->gen.reset_source;
}
4011a4045,4058
else if (source == PGC_S_FILE)
{
/* Revert value to default when item is removed from config
file. */
if ( conf->boot_val != NULL )
{
newval = guc_strdup(elevel, conf->boot_val);
if (newval == NULL)
return false;
}
else
{
return false;
}
}
5113a5161,5165
if( !newvalue )
{
return false;
}
Index: src/include/utils/guc_tables.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/guc_tables.h,v
retrieving revision 1.22
diff -r1.22 guc_tables.h
145c145
< bool reset_val;
---
bool default_val;
149a150
bool reset_val;
158c159
< int reset_val;
---
int default_val;
164a166
int reset_val;
173c175
< double reset_val;
---
double default_val;
179a182,183
double reset_val;
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster