Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d672ea6

Browse files
committed
Turn xmlbinary and xmloption GUC variables into enumsTurn xmlbinary and
xmloption GUC variables into enums..
1 parent 55f6e5f commit d672ea6

File tree

3 files changed

+37
-66
lines changed

3 files changed

+37
-66
lines changed

src/backend/utils/adt/xml.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.71 2008/03/25 22:42:44 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.72 2008/04/04 08:33:15 mha Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -86,8 +86,8 @@
8686

8787

8888
/* GUC variables */
89-
XmlBinaryType xmlbinary;
90-
XmlOptionType xmloption;
89+
int xmlbinary;
90+
int xmloption;
9191

9292
#ifdef USE_LIBXML
9393

src/backend/utils/misc/guc.c

Lines changed: 31 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <[email protected]>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.443 2008/04/03 13:25:02 mha Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.444 2008/04/04 08:33:15 mha Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -155,8 +155,6 @@ static bool assign_transaction_read_only(bool newval, bool doit, GucSource sourc
155155
static const char *assign_canonical_path(const char *newval, bool doit, GucSource source);
156156
static const char *assign_backslash_quote(const char *newval, bool doit, GucSource source);
157157
static const char *assign_timezone_abbreviations(const char *newval, bool doit, GucSource source);
158-
static const char *assign_xmlbinary(const char *newval, bool doit, GucSource source);
159-
static const char *assign_xmloption(const char *newval, bool doit, GucSource source);
160158
static const char *show_archive_command(void);
161159
static bool assign_tcp_keepalives_idle(int newval, bool doit, GucSource source);
162160
static bool assign_tcp_keepalives_interval(int newval, bool doit, GucSource source);
@@ -243,6 +241,17 @@ static const struct config_enum_entry syslog_facility_options[] = {
243241
};
244242
#endif
245243

244+
static const struct config_enum_entry xmlbinary_options[] = {
245+
{"base64", XMLBINARY_BASE64},
246+
{"hex", XMLBINARY_HEX},
247+
{NULL, 0}
248+
};
249+
250+
static const struct config_enum_entry xmloption_options[] = {
251+
{"content", XMLOPTION_CONTENT},
252+
{"document", XMLOPTION_DOCUMENT},
253+
{NULL, 0}
254+
};
246255

247256
/*
248257
* GUC option variables that are exported from this module
@@ -316,8 +325,6 @@ static char *timezone_abbreviations_string;
316325
static char *XactIsoLevel_string;
317326
static char *data_directory;
318327
static char *custom_variable_classes;
319-
static char *xmlbinary_string;
320-
static char *xmloption_string;
321328
static int max_function_args;
322329
static int max_index_keys;
323330
static int max_identifier_length;
@@ -2382,25 +2389,6 @@ static struct config_string ConfigureNamesString[] =
23822389
NULL, assign_canonical_path, NULL
23832390
},
23842391

2385-
{
2386-
{"xmlbinary", PGC_USERSET, CLIENT_CONN_STATEMENT,
2387-
gettext_noop("Sets how binary values are to be encoded in XML."),
2388-
gettext_noop("Valid values are BASE64 and HEX.")
2389-
},
2390-
&xmlbinary_string,
2391-
"base64", assign_xmlbinary, NULL
2392-
},
2393-
2394-
{
2395-
{"xmloption", PGC_USERSET, CLIENT_CONN_STATEMENT,
2396-
gettext_noop("Sets whether XML data in implicit parsing and serialization "
2397-
"operations is to be considered as documents or content fragments."),
2398-
gettext_noop("Valid values are DOCUMENT and CONTENT.")
2399-
},
2400-
&xmloption_string,
2401-
"content", assign_xmloption, NULL
2402-
},
2403-
24042392
{
24052393
{"default_text_search_config", PGC_USERSET, CLIENT_CONN_LOCALE,
24062394
gettext_noop("Sets default text search configuration."),
@@ -2524,6 +2512,25 @@ static struct config_enum ConfigureNamesEnum[] =
25242512
assign_session_replication_role, NULL
25252513
},
25262514

2515+
{
2516+
{"xmlbinary", PGC_USERSET, CLIENT_CONN_STATEMENT,
2517+
gettext_noop("Sets how binary values are to be encoded in XML."),
2518+
gettext_noop("Valid values are BASE64 and HEX.")
2519+
},
2520+
&xmlbinary,
2521+
XMLBINARY_BASE64, xmlbinary_options, NULL, NULL
2522+
},
2523+
2524+
{
2525+
{"xmloption", PGC_USERSET, CLIENT_CONN_STATEMENT,
2526+
gettext_noop("Sets whether XML data in implicit parsing and serialization "
2527+
"operations is to be considered as documents or content fragments."),
2528+
gettext_noop("Valid values are DOCUMENT and CONTENT.")
2529+
},
2530+
&xmloption,
2531+
XMLOPTION_CONTENT, xmloption_options, NULL, NULL
2532+
},
2533+
25272534

25282535
/* End-of-list marker */
25292536
{
@@ -7172,42 +7179,6 @@ pg_timezone_abbrev_initialize(void)
71727179
}
71737180
}
71747181

7175-
static const char *
7176-
assign_xmlbinary(const char *newval, bool doit, GucSource source)
7177-
{
7178-
XmlBinaryType xb;
7179-
7180-
if (pg_strcasecmp(newval, "base64") == 0)
7181-
xb = XMLBINARY_BASE64;
7182-
else if (pg_strcasecmp(newval, "hex") == 0)
7183-
xb = XMLBINARY_HEX;
7184-
else
7185-
return NULL; /* reject */
7186-
7187-
if (doit)
7188-
xmlbinary = xb;
7189-
7190-
return newval;
7191-
}
7192-
7193-
static const char *
7194-
assign_xmloption(const char *newval, bool doit, GucSource source)
7195-
{
7196-
XmlOptionType xo;
7197-
7198-
if (pg_strcasecmp(newval, "document") == 0)
7199-
xo = XMLOPTION_DOCUMENT;
7200-
else if (pg_strcasecmp(newval, "content") == 0)
7201-
xo = XMLOPTION_CONTENT;
7202-
else
7203-
return NULL; /* reject */
7204-
7205-
if (doit)
7206-
xmloption = xo;
7207-
7208-
return newval;
7209-
}
7210-
72117182
static const char *
72127183
show_archive_command(void)
72137184
{

src/include/utils/xml.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.23 2008/01/15 18:57:00 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.24 2008/04/04 08:33:15 mha Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -83,8 +83,8 @@ typedef enum
8383
XMLBINARY_HEX
8484
} XmlBinaryType;
8585

86-
extern XmlBinaryType xmlbinary;
86+
extern int xmlbinary; /* XmlBinaryType, but int for guc enum */
8787

88-
extern XmlOptionType xmloption;
88+
extern int xmloption; /* XmlOptionType, but int for guc enum */
8989

9090
#endif /* XML_H */

0 commit comments

Comments
 (0)