|
10 | 10 | * Written by Peter Eisentraut <peter_e@gmx.net>. |
11 | 11 | * |
12 | 12 | * IDENTIFICATION |
13 | | - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.440 2008/03/25 22:42:45 tgl Exp $ |
| 13 | + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.441 2008/04/02 14:42:56 mha Exp $ |
14 | 14 | * |
15 | 15 | *-------------------------------------------------------------------- |
16 | 16 | */ |
|
54 | 54 | #include "postmaster/postmaster.h" |
55 | 55 | #include "postmaster/syslogger.h" |
56 | 56 | #include "postmaster/walwriter.h" |
| 57 | +#include "regex/regex.h" |
57 | 58 | #include "storage/fd.h" |
58 | 59 | #include "storage/freespace.h" |
59 | 60 | #include "tcop/tcopprot.h" |
@@ -140,9 +141,7 @@ static const char *assign_syslog_ident(const char *ident, |
140 | 141 | bool doit, GucSource source); |
141 | 142 | #endif |
142 | 143 |
|
143 | | -static const char *assign_defaultxactisolevel(const char *newval, bool doit, |
144 | | - GucSource source); |
145 | | -static const char *assign_session_replication_role(const char *newval, bool doit, |
| 144 | +static bool assign_session_replication_role(int newval, bool doit, |
146 | 145 | GucSource source); |
147 | 146 | static const char *show_num_temp_buffers(void); |
148 | 147 | 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 | 207 | {NULL, 0} |
209 | 208 | }; |
210 | 209 |
|
| 210 | +static const struct config_enum_entry regex_flavor_options[] = { |
| 211 | + {"advanced", REG_ADVANCED}, |
| 212 | + {"extended", REG_EXTENDED}, |
| 213 | + {"basic", REG_BASIC}, |
| 214 | + {NULL, 0} |
| 215 | +}; |
| 216 | + |
| 217 | +static const struct config_enum_entry isolation_level_options[] = { |
| 218 | + {"serializable", XACT_SERIALIZABLE}, |
| 219 | + {"repeatable read", XACT_REPEATABLE_READ}, |
| 220 | + {"read committed", XACT_READ_COMMITTED}, |
| 221 | + {"read uncommitted", XACT_READ_UNCOMMITTED}, |
| 222 | + {NULL, 0} |
| 223 | +}; |
| 224 | + |
| 225 | +static const struct config_enum_entry session_replication_role_options[] = { |
| 226 | + {"origin", SESSION_REPLICATION_ROLE_ORIGIN}, |
| 227 | + {"replica", SESSION_REPLICATION_ROLE_REPLICA}, |
| 228 | + {"local", SESSION_REPLICATION_ROLE_LOCAL}, |
| 229 | + {NULL, 0} |
| 230 | +}; |
| 231 | + |
| 232 | + |
211 | 233 | /* |
212 | 234 | * GUC option variables that are exported from this module |
213 | 235 | */ |
@@ -270,11 +292,8 @@ static double phony_random_seed; |
270 | 292 | static char *backslash_quote_string; |
271 | 293 | static char *client_encoding_string; |
272 | 294 | static char *datestyle_string; |
273 | | -static char *default_iso_level_string; |
274 | | -static char *session_replication_role_string; |
275 | 295 | static char *locale_collate; |
276 | 296 | static char *locale_ctype; |
277 | | -static char *regex_flavor_string; |
278 | 297 | static char *server_encoding_string; |
279 | 298 | static char *server_version_string; |
280 | 299 | static int server_version_num; |
@@ -1988,26 +2007,6 @@ static struct config_string ConfigureNamesString[] = |
1988 | 2007 | "", assign_temp_tablespaces, NULL |
1989 | 2008 | }, |
1990 | 2009 |
|
1991 | | - { |
1992 | | - {"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT, |
1993 | | - gettext_noop("Sets the transaction isolation level of each new transaction."), |
1994 | | - gettext_noop("Each SQL transaction has an isolation level, which " |
1995 | | - "can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".") |
1996 | | - }, |
1997 | | - &default_iso_level_string, |
1998 | | - "read committed", assign_defaultxactisolevel, NULL |
1999 | | - }, |
2000 | | - |
2001 | | - { |
2002 | | - {"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT, |
2003 | | - gettext_noop("Sets the session's behavior for triggers and rewrite rules."), |
2004 | | - gettext_noop("Each session can be either" |
2005 | | - " \"origin\", \"replica\", or \"local\".") |
2006 | | - }, |
2007 | | - &session_replication_role_string, |
2008 | | - "origin", assign_session_replication_role, NULL |
2009 | | - }, |
2010 | | - |
2011 | 2010 | { |
2012 | 2011 | {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER, |
2013 | 2012 | gettext_noop("Sets the path for dynamically loadable modules."), |
@@ -2146,15 +2145,6 @@ static struct config_string ConfigureNamesString[] = |
2146 | 2145 | "", NULL, NULL |
2147 | 2146 | }, |
2148 | 2147 |
|
2149 | | - { |
2150 | | - {"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, |
2151 | | - gettext_noop("Sets the regular expression \"flavor\"."), |
2152 | | - gettext_noop("This can be set to advanced, extended, or basic.") |
2153 | | - }, |
2154 | | - ®ex_flavor_string, |
2155 | | - "advanced", assign_regex_flavor, NULL |
2156 | | - }, |
2157 | | - |
2158 | 2148 | { |
2159 | 2149 | {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT, |
2160 | 2150 | gettext_noop("Sets the schema search order for names that are not schema-qualified."), |
@@ -2449,6 +2439,16 @@ static struct config_enum ConfigureNamesEnum[] = |
2449 | 2439 | NOTICE, message_level_options,NULL, NULL |
2450 | 2440 | }, |
2451 | 2441 |
|
| 2442 | + { |
| 2443 | + {"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT, |
| 2444 | + gettext_noop("Sets the transaction isolation level of each new transaction."), |
| 2445 | + gettext_noop("Each SQL transaction has an isolation level, which " |
| 2446 | + "can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".") |
| 2447 | + }, |
| 2448 | + &DefaultXactIsoLevel, |
| 2449 | + XACT_READ_COMMITTED, isolation_level_options, NULL, NULL |
| 2450 | + }, |
| 2451 | + |
2452 | 2452 | { |
2453 | 2453 | {"log_error_verbosity", PGC_SUSET, LOGGING_WHEN, |
2454 | 2454 | gettext_noop("Sets the verbosity of logged messages."), |
@@ -2488,7 +2488,25 @@ static struct config_enum ConfigureNamesEnum[] = |
2488 | 2488 | LOGSTMT_NONE, log_statement_options, NULL, NULL |
2489 | 2489 | }, |
2490 | 2490 |
|
| 2491 | + { |
| 2492 | + {"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, |
| 2493 | + gettext_noop("Sets the regular expression \"flavor\"."), |
| 2494 | + gettext_noop("This can be set to advanced, extended, or basic.") |
| 2495 | + }, |
| 2496 | + ®ex_flavor, |
| 2497 | + REG_ADVANCED, regex_flavor_options, NULL, NULL |
| 2498 | + }, |
2491 | 2499 |
|
| 2500 | + { |
| 2501 | + {"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT, |
| 2502 | + gettext_noop("Sets the session's behavior for triggers and rewrite rules."), |
| 2503 | + gettext_noop("Each session can be either" |
| 2504 | + " \"origin\", \"replica\", or \"local\".") |
| 2505 | + }, |
| 2506 | + &SessionReplicationRole, |
| 2507 | + SESSION_REPLICATION_ROLE_ORIGIN, session_replication_role_options, |
| 2508 | + assign_session_replication_role, NULL |
| 2509 | + }, |
2492 | 2510 |
|
2493 | 2511 |
|
2494 | 2512 | /* End-of-list marker */ |
@@ -6887,59 +6905,19 @@ assign_syslog_ident(const char *ident, bool doit, GucSource source) |
6887 | 6905 | #endif /* HAVE_SYSLOG */ |
6888 | 6906 |
|
6889 | 6907 |
|
6890 | | -static const char * |
6891 | | -assign_defaultxactisolevel(const char *newval, bool doit, GucSource source) |
6892 | | -{ |
6893 | | - if (pg_strcasecmp(newval, "serializable") == 0) |
6894 | | - { |
6895 | | - if (doit) |
6896 | | - DefaultXactIsoLevel = XACT_SERIALIZABLE; |
6897 | | - } |
6898 | | - else if (pg_strcasecmp(newval, "repeatable read") == 0) |
6899 | | - { |
6900 | | - if (doit) |
6901 | | - DefaultXactIsoLevel = XACT_REPEATABLE_READ; |
6902 | | - } |
6903 | | - else if (pg_strcasecmp(newval, "read committed") == 0) |
6904 | | - { |
6905 | | - if (doit) |
6906 | | - DefaultXactIsoLevel = XACT_READ_COMMITTED; |
6907 | | - } |
6908 | | - else if (pg_strcasecmp(newval, "read uncommitted") == 0) |
6909 | | - { |
6910 | | - if (doit) |
6911 | | - DefaultXactIsoLevel = XACT_READ_UNCOMMITTED; |
6912 | | - } |
6913 | | - else |
6914 | | - return NULL; |
6915 | | - return newval; |
6916 | | -} |
6917 | | - |
6918 | | -static const char * |
6919 | | -assign_session_replication_role(const char *newval, bool doit, GucSource source) |
| 6908 | +static bool |
| 6909 | +assign_session_replication_role(int newval, bool doit, GucSource source) |
6920 | 6910 | { |
6921 | | - int newrole; |
6922 | | - |
6923 | | - if (pg_strcasecmp(newval, "origin") == 0) |
6924 | | - newrole = SESSION_REPLICATION_ROLE_ORIGIN; |
6925 | | - else if (pg_strcasecmp(newval, "replica") == 0) |
6926 | | - newrole = SESSION_REPLICATION_ROLE_REPLICA; |
6927 | | - else if (pg_strcasecmp(newval, "local") == 0) |
6928 | | - newrole = SESSION_REPLICATION_ROLE_LOCAL; |
6929 | | - else |
6930 | | - return NULL; |
6931 | | - |
6932 | 6911 | /* |
6933 | 6912 | * Must flush the plan cache when changing replication role; but don't |
6934 | 6913 | * flush unnecessarily. |
6935 | 6914 | */ |
6936 | | - if (doit && SessionReplicationRole != newrole) |
| 6915 | + if (doit && SessionReplicationRole != newval) |
6937 | 6916 | { |
6938 | 6917 | ResetPlanCache(); |
6939 | | - SessionReplicationRole = newrole; |
6940 | 6918 | } |
6941 | 6919 |
|
6942 | | - return newval; |
| 6920 | + return true; |
6943 | 6921 | } |
6944 | 6922 |
|
6945 | 6923 | static const char * |
|
0 commit comments