Commit 40fda15d authored by Tom Lane's avatar Tom Lane

Code review for GUC revert-values-if-removed-from-postgresql.conf patch;

and in passing, fix some bogosities dating from the custom_variable_classes
patch.  Fix guc-file.l to correctly check changes in custom_variable_classes
that are attempted concurrently with additions/removals of custom variables,
and don't allow the new setting to be applied in advance of checking it.
Clean up messy and undocumented situation for string variables with NULL
boot_val.  Fix DefineCustomVariable functions to initialize boot_val
correctly.  Prevent find_option from inserting bogus placeholders for custom
variables that are simply inquired about rather than being set.
parent 43df609d
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* Copyright (c) 2006-2007, PostgreSQL Global Development Group * Copyright (c) 2006-2007, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/ts_cache.c,v 1.2 2007/08/22 01:39:45 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/cache/ts_cache.c,v 1.3 2007/09/10 00:57:21 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -592,14 +592,6 @@ getTSCurrentConfig(bool emitError) ...@@ -592,14 +592,6 @@ getTSCurrentConfig(bool emitError)
const char * const char *
assignTSCurrentConfig(const char *newval, bool doit, GucSource source) assignTSCurrentConfig(const char *newval, bool doit, GucSource source)
{ {
/* do nothing during initial GUC setup */
if (newval == NULL)
{
if (doit)
TSCurrentConfigCache = InvalidOid;
return newval;
}
/* /*
* If we aren't inside a transaction, we cannot do database access so * If we aren't inside a transaction, we cannot do database access so
* cannot verify the config name. Must accept it on faith. * cannot verify the config name. Must accept it on faith.
...@@ -637,7 +629,7 @@ assignTSCurrentConfig(const char *newval, bool doit, GucSource source) ...@@ -637,7 +629,7 @@ assignTSCurrentConfig(const char *newval, bool doit, GucSource source)
newval = strdup(buf); newval = strdup(buf);
pfree(buf); pfree(buf);
if (doit) if (doit && newval)
TSCurrentConfigCache = cfgId; TSCurrentConfigCache = cfgId;
} }
else else
......
$PostgreSQL: pgsql/src/backend/utils/misc/README,v 1.5 2004/07/01 00:51:24 tgl Exp $ $PostgreSQL: pgsql/src/backend/utils/misc/README,v 1.6 2007/09/10 00:57:21 tgl Exp $
GUC IMPLEMENTATION NOTES GUC IMPLEMENTATION NOTES
...@@ -53,6 +53,14 @@ The third choice is allowed in case the assign_hook wants to return a ...@@ -53,6 +53,14 @@ The third choice is allowed in case the assign_hook wants to return a
datestyle always returns a string that includes both output and input datestyle always returns a string that includes both output and input
datestyle options, although the input might have specified only one. datestyle options, although the input might have specified only one.
Note that a string variable's assign_hook will NEVER be called with a NULL
value for newvalue, since there would be no way to distinguish success
and failure returns. If the boot_val or reset_val for a string variable
is NULL, it will just be assigned without calling the assign_hook.
Therefore, a NULL boot_val should never be used in combination with an
assign_hook that has side-effects, as the side-effects wouldn't happen
during a RESET that re-institutes the boot-time setting.
If a show_hook is provided, it points to a function of the signature If a show_hook is provided, it points to a function of the signature
const char *show_hook(void) const char *show_hook(void)
This hook allows variable-specific computation of the value displayed This hook allows variable-specific computation of the value displayed
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.33 2007/04/21 20:02:41 petere Exp $ * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.34 2007/09/10 00:57:22 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -130,7 +130,7 @@ struct config_generic ...@@ -130,7 +130,7 @@ struct config_generic
#define GUC_SUPERUSER_ONLY 0x0100 /* show only to superusers */ #define GUC_SUPERUSER_ONLY 0x0100 /* show only to superusers */
#define GUC_IS_NAME 0x0200 /* limit string to NAMEDATALEN-1 */ #define GUC_IS_NAME 0x0200 /* limit string to NAMEDATALEN-1 */
#define GUC_UNIT_KB 0x0400 /* value is in 1 kB */ #define GUC_UNIT_KB 0x0400 /* value is in kilobytes */
#define GUC_UNIT_BLOCKS 0x0800 /* value is in blocks */ #define GUC_UNIT_BLOCKS 0x0800 /* value is in blocks */
#define GUC_UNIT_XBLOCKS 0x0C00 /* value is in xlog blocks */ #define GUC_UNIT_XBLOCKS 0x0C00 /* value is in xlog blocks */
#define GUC_UNIT_MEMORY 0x0C00 /* mask for KB, BLOCKS, XBLOCKS */ #define GUC_UNIT_MEMORY 0x0C00 /* mask for KB, BLOCKS, XBLOCKS */
...@@ -144,6 +144,11 @@ struct config_generic ...@@ -144,6 +144,11 @@ struct config_generic
#define GUC_HAVE_TENTATIVE 0x0001 /* tentative value is defined */ #define GUC_HAVE_TENTATIVE 0x0001 /* tentative value is defined */
#define GUC_HAVE_LOCAL 0x0002 /* a SET LOCAL has been executed */ #define GUC_HAVE_LOCAL 0x0002 /* a SET LOCAL has been executed */
#define GUC_HAVE_STACK 0x0004 /* we have stacked prior value(s) */ #define GUC_HAVE_STACK 0x0004 /* we have stacked prior value(s) */
#define GUC_IS_IN_FILE 0x0008 /* found it in config file */
/*
* Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
* Do not assume that its value represents useful information elsewhere.
*/
/* GUC records for specific variable types */ /* GUC records for specific variable types */
...@@ -151,8 +156,7 @@ struct config_generic ...@@ -151,8 +156,7 @@ struct config_generic
struct config_bool struct config_bool
{ {
struct config_generic gen; struct config_generic gen;
/* these fields must be set correctly in initial value: */ /* constant fields, must be set correctly in initial value: */
/* (all but reset_val are constants) */
bool *variable; bool *variable;
bool boot_val; bool boot_val;
GucBoolAssignHook assign_hook; GucBoolAssignHook assign_hook;
...@@ -165,8 +169,7 @@ struct config_bool ...@@ -165,8 +169,7 @@ struct config_bool
struct config_int struct config_int
{ {
struct config_generic gen; struct config_generic gen;
/* these fields must be set correctly in initial value: */ /* constant fields, must be set correctly in initial value: */
/* (all but reset_val are constants) */
int *variable; int *variable;
int boot_val; int boot_val;
int min; int min;
...@@ -181,8 +184,7 @@ struct config_int ...@@ -181,8 +184,7 @@ struct config_int
struct config_real struct config_real
{ {
struct config_generic gen; struct config_generic gen;
/* these fields must be set correctly in initial value: */ /* constant fields, must be set correctly in initial value: */
/* (all but reset_val are constants) */
double *variable; double *variable;
double boot_val; double boot_val;
double min; double min;
...@@ -197,8 +199,7 @@ struct config_real ...@@ -197,8 +199,7 @@ struct config_real
struct config_string struct config_string
{ {
struct config_generic gen; struct config_generic gen;
/* these fields must be set correctly in initial value: */ /* constant fields, must be set correctly in initial value: */
/* (all are constants) */
char **variable; char **variable;
const char *boot_val; const char *boot_val;
GucStringAssignHook assign_hook; GucStringAssignHook assign_hook;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment