Commit ad6bf716 authored by Magnus Hagander's avatar Magnus Hagander

Convert three more guc settings to enum type:

default_transaction_isolation, session_replication_role and regex_flavor.
parent afa2a9ec
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.79 2008/03/19 02:40:37 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.80 2008/04/02 14:42:56 mha Exp $
* *
* Alistair Crooks added the code for the regex caching * Alistair Crooks added the code for the regex caching
* agc - cached the regular expressions used - there's a good chance * agc - cached the regular expressions used - there's a good chance
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
/* GUC-settable flavor parameter */ /* GUC-settable flavor parameter */
static int regex_flavor = REG_ADVANCED; int regex_flavor = REG_ADVANCED;
/* all the options of interest for regex functions */ /* all the options of interest for regex functions */
...@@ -414,33 +414,6 @@ parse_re_flags(pg_re_flags *flags, text *opts) ...@@ -414,33 +414,6 @@ parse_re_flags(pg_re_flags *flags, text *opts)
} }
/*
* assign_regex_flavor - GUC hook to validate and set REGEX_FLAVOR
*/
const char *
assign_regex_flavor(const char *value, bool doit, GucSource source)
{
if (pg_strcasecmp(value, "advanced") == 0)
{
if (doit)
regex_flavor = REG_ADVANCED;
}
else if (pg_strcasecmp(value, "extended") == 0)
{
if (doit)
regex_flavor = REG_EXTENDED;
}
else if (pg_strcasecmp(value, "basic") == 0)
{
if (doit)
regex_flavor = REG_BASIC;
}
else
return NULL; /* fail */
return value; /* OK */
}
/* /*
* report whether regex_flavor is currently BASIC * report whether regex_flavor is currently BASIC
*/ */
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.440 2008/03/25 22:42:45 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.441 2008/04/02 14:42:56 mha Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "postmaster/postmaster.h" #include "postmaster/postmaster.h"
#include "postmaster/syslogger.h" #include "postmaster/syslogger.h"
#include "postmaster/walwriter.h" #include "postmaster/walwriter.h"
#include "regex/regex.h"
#include "storage/fd.h" #include "storage/fd.h"
#include "storage/freespace.h" #include "storage/freespace.h"
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
...@@ -140,9 +141,7 @@ static const char *assign_syslog_ident(const char *ident, ...@@ -140,9 +141,7 @@ static const char *assign_syslog_ident(const char *ident,
bool doit, GucSource source); bool doit, GucSource source);
#endif #endif
static const char *assign_defaultxactisolevel(const char *newval, bool doit, static bool assign_session_replication_role(int newval, bool doit,
GucSource source);
static const char *assign_session_replication_role(const char *newval, bool doit,
GucSource source); GucSource source);
static const char *show_num_temp_buffers(void); static const char *show_num_temp_buffers(void);
static bool assign_phony_autocommit(bool newval, bool doit, GucSource source); static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);
...@@ -208,6 +207,29 @@ static const struct config_enum_entry log_statement_options[] = { ...@@ -208,6 +207,29 @@ static const struct config_enum_entry log_statement_options[] = {
{NULL, 0} {NULL, 0}
}; };
static const struct config_enum_entry regex_flavor_options[] = {
{"advanced", REG_ADVANCED},
{"extended", REG_EXTENDED},
{"basic", REG_BASIC},
{NULL, 0}
};
static const struct config_enum_entry isolation_level_options[] = {
{"serializable", XACT_SERIALIZABLE},
{"repeatable read", XACT_REPEATABLE_READ},
{"read committed", XACT_READ_COMMITTED},
{"read uncommitted", XACT_READ_UNCOMMITTED},
{NULL, 0}
};
static const struct config_enum_entry session_replication_role_options[] = {
{"origin", SESSION_REPLICATION_ROLE_ORIGIN},
{"replica", SESSION_REPLICATION_ROLE_REPLICA},
{"local", SESSION_REPLICATION_ROLE_LOCAL},
{NULL, 0}
};
/* /*
* GUC option variables that are exported from this module * GUC option variables that are exported from this module
*/ */
...@@ -270,11 +292,8 @@ static double phony_random_seed; ...@@ -270,11 +292,8 @@ static double phony_random_seed;
static char *backslash_quote_string; static char *backslash_quote_string;
static char *client_encoding_string; static char *client_encoding_string;
static char *datestyle_string; static char *datestyle_string;
static char *default_iso_level_string;
static char *session_replication_role_string;
static char *locale_collate; static char *locale_collate;
static char *locale_ctype; static char *locale_ctype;
static char *regex_flavor_string;
static char *server_encoding_string; static char *server_encoding_string;
static char *server_version_string; static char *server_version_string;
static int server_version_num; static int server_version_num;
...@@ -1988,26 +2007,6 @@ static struct config_string ConfigureNamesString[] = ...@@ -1988,26 +2007,6 @@ static struct config_string ConfigureNamesString[] =
"", assign_temp_tablespaces, NULL "", assign_temp_tablespaces, NULL
}, },
{
{"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets the transaction isolation level of each new transaction."),
gettext_noop("Each SQL transaction has an isolation level, which "
"can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".")
},
&default_iso_level_string,
"read committed", assign_defaultxactisolevel, NULL
},
{
{"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets the session's behavior for triggers and rewrite rules."),
gettext_noop("Each session can be either"
" \"origin\", \"replica\", or \"local\".")
},
&session_replication_role_string,
"origin", assign_session_replication_role, NULL
},
{ {
{"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER, {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER,
gettext_noop("Sets the path for dynamically loadable modules."), gettext_noop("Sets the path for dynamically loadable modules."),
...@@ -2146,15 +2145,6 @@ static struct config_string ConfigureNamesString[] = ...@@ -2146,15 +2145,6 @@ static struct config_string ConfigureNamesString[] =
"", NULL, NULL "", NULL, NULL
}, },
{
{"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
gettext_noop("Sets the regular expression \"flavor\"."),
gettext_noop("This can be set to advanced, extended, or basic.")
},
&regex_flavor_string,
"advanced", assign_regex_flavor, NULL
},
{ {
{"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT, {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets the schema search order for names that are not schema-qualified."), gettext_noop("Sets the schema search order for names that are not schema-qualified."),
...@@ -2449,6 +2439,16 @@ static struct config_enum ConfigureNamesEnum[] = ...@@ -2449,6 +2439,16 @@ static struct config_enum ConfigureNamesEnum[] =
NOTICE, message_level_options,NULL, NULL NOTICE, message_level_options,NULL, NULL
}, },
{
{"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets the transaction isolation level of each new transaction."),
gettext_noop("Each SQL transaction has an isolation level, which "
"can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".")
},
&DefaultXactIsoLevel,
XACT_READ_COMMITTED, isolation_level_options, NULL, NULL
},
{ {
{"log_error_verbosity", PGC_SUSET, LOGGING_WHEN, {"log_error_verbosity", PGC_SUSET, LOGGING_WHEN,
gettext_noop("Sets the verbosity of logged messages."), gettext_noop("Sets the verbosity of logged messages."),
...@@ -2488,7 +2488,25 @@ static struct config_enum ConfigureNamesEnum[] = ...@@ -2488,7 +2488,25 @@ static struct config_enum ConfigureNamesEnum[] =
LOGSTMT_NONE, log_statement_options, NULL, NULL LOGSTMT_NONE, log_statement_options, NULL, NULL
}, },
{
{"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
gettext_noop("Sets the regular expression \"flavor\"."),
gettext_noop("This can be set to advanced, extended, or basic.")
},
&regex_flavor,
REG_ADVANCED, regex_flavor_options, NULL, NULL
},
{
{"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets the session's behavior for triggers and rewrite rules."),
gettext_noop("Each session can be either"
" \"origin\", \"replica\", or \"local\".")
},
&SessionReplicationRole,
SESSION_REPLICATION_ROLE_ORIGIN, session_replication_role_options,
assign_session_replication_role, NULL
},
/* End-of-list marker */ /* End-of-list marker */
...@@ -6887,59 +6905,19 @@ assign_syslog_ident(const char *ident, bool doit, GucSource source) ...@@ -6887,59 +6905,19 @@ assign_syslog_ident(const char *ident, bool doit, GucSource source)
#endif /* HAVE_SYSLOG */ #endif /* HAVE_SYSLOG */
static const char * static bool
assign_defaultxactisolevel(const char *newval, bool doit, GucSource source) assign_session_replication_role(int newval, bool doit, GucSource source)
{
if (pg_strcasecmp(newval, "serializable") == 0)
{
if (doit)
DefaultXactIsoLevel = XACT_SERIALIZABLE;
}
else if (pg_strcasecmp(newval, "repeatable read") == 0)
{
if (doit)
DefaultXactIsoLevel = XACT_REPEATABLE_READ;
}
else if (pg_strcasecmp(newval, "read committed") == 0)
{
if (doit)
DefaultXactIsoLevel = XACT_READ_COMMITTED;
}
else if (pg_strcasecmp(newval, "read uncommitted") == 0)
{
if (doit)
DefaultXactIsoLevel = XACT_READ_UNCOMMITTED;
}
else
return NULL;
return newval;
}
static const char *
assign_session_replication_role(const char *newval, bool doit, GucSource source)
{ {
int newrole;
if (pg_strcasecmp(newval, "origin") == 0)
newrole = SESSION_REPLICATION_ROLE_ORIGIN;
else if (pg_strcasecmp(newval, "replica") == 0)
newrole = SESSION_REPLICATION_ROLE_REPLICA;
else if (pg_strcasecmp(newval, "local") == 0)
newrole = SESSION_REPLICATION_ROLE_LOCAL;
else
return NULL;
/* /*
* Must flush the plan cache when changing replication role; but don't * Must flush the plan cache when changing replication role; but don't
* flush unnecessarily. * flush unnecessarily.
*/ */
if (doit && SessionReplicationRole != newrole) if (doit && SessionReplicationRole != newval)
{ {
ResetPlanCache(); ResetPlanCache();
SessionReplicationRole = newrole;
} }
return newval; return true;
} }
static const char * static const char *
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/src/include/regex/regex.h,v 1.29 2008/01/03 20:47:55 tgl Exp $ * $PostgreSQL: pgsql/src/include/regex/regex.h,v 1.30 2008/04/02 14:42:56 mha Exp $
*/ */
/* /*
...@@ -166,4 +166,9 @@ extern int pg_regexec(regex_t *, const pg_wchar *, size_t, size_t, rm_detail_t * ...@@ -166,4 +166,9 @@ extern int pg_regexec(regex_t *, const pg_wchar *, size_t, size_t, rm_detail_t *
extern void pg_regfree(regex_t *); extern void pg_regfree(regex_t *);
extern size_t pg_regerror(int, const regex_t *, char *, size_t); extern size_t pg_regerror(int, const regex_t *, char *, size_t);
/*
* guc configuration variables
*/
extern int regex_flavor;
#endif /* _REGEX_H_ */ #endif /* _REGEX_H_ */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 2000-2008, PostgreSQL Global Development Group * Copyright (c) 2000-2008, PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.92 2008/03/16 16:42:44 mha Exp $ * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.93 2008/04/02 14:42:56 mha Exp $
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
#ifndef GUC_H #ifndef GUC_H
...@@ -263,10 +263,6 @@ extern const char *assign_default_tablespace(const char *newval, ...@@ -263,10 +263,6 @@ extern const char *assign_default_tablespace(const char *newval,
extern const char *assign_temp_tablespaces(const char *newval, extern const char *assign_temp_tablespaces(const char *newval,
bool doit, GucSource source); bool doit, GucSource source);
/* in utils/adt/regexp.c */
extern const char *assign_regex_flavor(const char *value,
bool doit, GucSource source);
/* in catalog/namespace.c */ /* in catalog/namespace.c */
extern const char *assign_search_path(const char *newval, extern const char *assign_search_path(const char *newval,
bool doit, GucSource source); bool doit, GucSource source);
......
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