Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad6bf71

Browse files
committed
Convert three more guc settings to enum type:
default_transaction_isolation, session_replication_role and regex_flavor.
1 parentafa2a9e commitad6bf71

File tree

4 files changed

+67
-115
lines changed

4 files changed

+67
-115
lines changed

‎src/backend/utils/adt/regexp.c

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.79 2008/03/19 02:40:37 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.80 2008/04/02 14:42:56 mha Exp $
1212
*
1313
*Alistair Crooks added the code for the regex caching
1414
*agc - cached the regular expressions used - there's a good chance
@@ -40,7 +40,7 @@
4040

4141

4242
/* GUC-settable flavor parameter */
43-
staticintregex_flavor=REG_ADVANCED;
43+
intregex_flavor=REG_ADVANCED;
4444

4545

4646
/* all the options of interest for regex functions */
@@ -414,33 +414,6 @@ parse_re_flags(pg_re_flags *flags, text *opts)
414414
}
415415

416416

417-
/*
418-
* assign_regex_flavor - GUC hook to validate and set REGEX_FLAVOR
419-
*/
420-
constchar*
421-
assign_regex_flavor(constchar*value,booldoit,GucSourcesource)
422-
{
423-
if (pg_strcasecmp(value,"advanced")==0)
424-
{
425-
if (doit)
426-
regex_flavor=REG_ADVANCED;
427-
}
428-
elseif (pg_strcasecmp(value,"extended")==0)
429-
{
430-
if (doit)
431-
regex_flavor=REG_EXTENDED;
432-
}
433-
elseif (pg_strcasecmp(value,"basic")==0)
434-
{
435-
if (doit)
436-
regex_flavor=REG_BASIC;
437-
}
438-
else
439-
returnNULL;/* fail */
440-
returnvalue;/* OK */
441-
}
442-
443-
444417
/*
445418
* report whether regex_flavor is currently BASIC
446419
*/

‎src/backend/utils/misc/guc.c

Lines changed: 58 additions & 80 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.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 $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -54,6 +54,7 @@
5454
#include"postmaster/postmaster.h"
5555
#include"postmaster/syslogger.h"
5656
#include"postmaster/walwriter.h"
57+
#include"regex/regex.h"
5758
#include"storage/fd.h"
5859
#include"storage/freespace.h"
5960
#include"tcop/tcopprot.h"
@@ -140,9 +141,7 @@ static const char *assign_syslog_ident(const char *ident,
140141
booldoit,GucSourcesource);
141142
#endif
142143

143-
staticconstchar*assign_defaultxactisolevel(constchar*newval,booldoit,
144-
GucSourcesource);
145-
staticconstchar*assign_session_replication_role(constchar*newval,booldoit,
144+
staticboolassign_session_replication_role(intnewval,booldoit,
146145
GucSourcesource);
147146
staticconstchar*show_num_temp_buffers(void);
148147
staticboolassign_phony_autocommit(boolnewval,booldoit,GucSourcesource);
@@ -208,6 +207,29 @@ static const struct config_enum_entry log_statement_options[] = {
208207
{NULL,0}
209208
};
210209

210+
staticconststructconfig_enum_entryregex_flavor_options[]= {
211+
{"advanced",REG_ADVANCED},
212+
{"extended",REG_EXTENDED},
213+
{"basic",REG_BASIC},
214+
{NULL,0}
215+
};
216+
217+
staticconststructconfig_enum_entryisolation_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+
staticconststructconfig_enum_entrysession_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+
211233
/*
212234
* GUC option variables that are exported from this module
213235
*/
@@ -270,11 +292,8 @@ static double phony_random_seed;
270292
staticchar*backslash_quote_string;
271293
staticchar*client_encoding_string;
272294
staticchar*datestyle_string;
273-
staticchar*default_iso_level_string;
274-
staticchar*session_replication_role_string;
275295
staticchar*locale_collate;
276296
staticchar*locale_ctype;
277-
staticchar*regex_flavor_string;
278297
staticchar*server_encoding_string;
279298
staticchar*server_version_string;
280299
staticintserver_version_num;
@@ -1988,26 +2007,6 @@ static struct config_string ConfigureNamesString[] =
19882007
"",assign_temp_tablespaces,NULL
19892008
},
19902009

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-
20112010
{
20122011
{"dynamic_library_path",PGC_SUSET,CLIENT_CONN_OTHER,
20132012
gettext_noop("Sets the path for dynamically loadable modules."),
@@ -2146,15 +2145,6 @@ static struct config_string ConfigureNamesString[] =
21462145
"",NULL,NULL
21472146
},
21482147

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-
&regex_flavor_string,
2155-
"advanced",assign_regex_flavor,NULL
2156-
},
2157-
21582148
{
21592149
{"search_path",PGC_USERSET,CLIENT_CONN_STATEMENT,
21602150
gettext_noop("Sets the schema search order for names that are not schema-qualified."),
@@ -2449,6 +2439,16 @@ static struct config_enum ConfigureNamesEnum[] =
24492439
NOTICE,message_level_options,NULL,NULL
24502440
},
24512441

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+
24522452
{
24532453
{"log_error_verbosity",PGC_SUSET,LOGGING_WHEN,
24542454
gettext_noop("Sets the verbosity of logged messages."),
@@ -2488,7 +2488,25 @@ static struct config_enum ConfigureNamesEnum[] =
24882488
LOGSTMT_NONE,log_statement_options,NULL,NULL
24892489
},
24902490

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+
&regex_flavor,
2497+
REG_ADVANCED,regex_flavor_options,NULL,NULL
2498+
},
24912499

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+
},
24922510

24932511

24942512
/* End-of-list marker */
@@ -6887,59 +6905,19 @@ assign_syslog_ident(const char *ident, bool doit, GucSource source)
68876905
#endif/* HAVE_SYSLOG */
68886906

68896907

6890-
staticconstchar*
6891-
assign_defaultxactisolevel(constchar*newval,booldoit,GucSourcesource)
6892-
{
6893-
if (pg_strcasecmp(newval,"serializable")==0)
6894-
{
6895-
if (doit)
6896-
DefaultXactIsoLevel=XACT_SERIALIZABLE;
6897-
}
6898-
elseif (pg_strcasecmp(newval,"repeatable read")==0)
6899-
{
6900-
if (doit)
6901-
DefaultXactIsoLevel=XACT_REPEATABLE_READ;
6902-
}
6903-
elseif (pg_strcasecmp(newval,"read committed")==0)
6904-
{
6905-
if (doit)
6906-
DefaultXactIsoLevel=XACT_READ_COMMITTED;
6907-
}
6908-
elseif (pg_strcasecmp(newval,"read uncommitted")==0)
6909-
{
6910-
if (doit)
6911-
DefaultXactIsoLevel=XACT_READ_UNCOMMITTED;
6912-
}
6913-
else
6914-
returnNULL;
6915-
returnnewval;
6916-
}
6917-
6918-
staticconstchar*
6919-
assign_session_replication_role(constchar*newval,booldoit,GucSourcesource)
6908+
staticbool
6909+
assign_session_replication_role(intnewval,booldoit,GucSourcesource)
69206910
{
6921-
intnewrole;
6922-
6923-
if (pg_strcasecmp(newval,"origin")==0)
6924-
newrole=SESSION_REPLICATION_ROLE_ORIGIN;
6925-
elseif (pg_strcasecmp(newval,"replica")==0)
6926-
newrole=SESSION_REPLICATION_ROLE_REPLICA;
6927-
elseif (pg_strcasecmp(newval,"local")==0)
6928-
newrole=SESSION_REPLICATION_ROLE_LOCAL;
6929-
else
6930-
returnNULL;
6931-
69326911
/*
69336912
* Must flush the plan cache when changing replication role; but don't
69346913
* flush unnecessarily.
69356914
*/
6936-
if (doit&&SessionReplicationRole!=newrole)
6915+
if (doit&&SessionReplicationRole!=newval)
69376916
{
69386917
ResetPlanCache();
6939-
SessionReplicationRole=newrole;
69406918
}
69416919

6942-
returnnewval;
6920+
returntrue;
69436921
}
69446922

69456923
staticconstchar*

‎src/include/regex/regex.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
3030
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*
32-
* $PostgreSQL: pgsql/src/include/regex/regex.h,v 1.29 2008/01/03 20:47:55 tgl Exp $
32+
* $PostgreSQL: pgsql/src/include/regex/regex.h,v 1.30 2008/04/02 14:42:56 mha Exp $
3333
*/
3434

3535
/*
@@ -166,4 +166,9 @@ extern intpg_regexec(regex_t *, const pg_wchar *, size_t, size_t, rm_detail_t *
166166
externvoidpg_regfree(regex_t*);
167167
externsize_tpg_regerror(int,constregex_t*,char*,size_t);
168168

169+
/*
170+
* guc configuration variables
171+
*/
172+
externintregex_flavor;
173+
169174
#endif/* _REGEX_H_ */

‎src/include/utils/guc.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
88
* Written by Peter Eisentraut <peter_e@gmx.net>.
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.92 2008/03/16 16:42:44 mha Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.93 2008/04/02 14:42:56 mha Exp $
1111
*--------------------------------------------------------------------
1212
*/
1313
#ifndefGUC_H
@@ -263,10 +263,6 @@ extern const char *assign_default_tablespace(const char *newval,
263263
externconstchar*assign_temp_tablespaces(constchar*newval,
264264
booldoit,GucSourcesource);
265265

266-
/* in utils/adt/regexp.c */
267-
externconstchar*assign_regex_flavor(constchar*value,
268-
booldoit,GucSourcesource);
269-
270266
/* in catalog/namespace.c */
271267
externconstchar*assign_search_path(constchar*newval,
272268
booldoit,GucSourcesource);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp