Skip to content

Commit 2288d64

Browse files
committed
Convert backslash_quote guc to use enum.
1 parent d672ea6 commit 2288d64

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

src/backend/utils/misc/guc.c

Lines changed: 27 additions & 12 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.444 2008/04/04 08:33:15 mha Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.445 2008/04/04 11:47:19 mha Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -153,7 +153,6 @@ static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
153153
static bool assign_log_stats(bool newval, bool doit, GucSource source);
154154
static bool assign_transaction_read_only(bool newval, bool doit, GucSource source);
155155
static const char *assign_canonical_path(const char *newval, bool doit, GucSource source);
156-
static const char *assign_backslash_quote(const char *newval, bool doit, GucSource source);
157156
static const char *assign_timezone_abbreviations(const char *newval, bool doit, GucSource source);
158157
static const char *show_archive_command(void);
159158
static bool assign_tcp_keepalives_idle(int newval, bool doit, GucSource source);
@@ -253,6 +252,23 @@ static const struct config_enum_entry xmloption_options[] = {
253252
{NULL, 0}
254253
};
255254

255+
/*
256+
* Although only "on", "off", and "safe_encoding" are documented, we
257+
* accept all the likely variants of "on" and "off".
258+
*/
259+
static const struct config_enum_entry backslash_quote_options[] = {
260+
{"safe_encoding", BACKSLASH_QUOTE_SAFE_ENCODING},
261+
{"on", BACKSLASH_QUOTE_ON},
262+
{"off", BACKSLASH_QUOTE_OFF},
263+
{"true", BACKSLASH_QUOTE_ON},
264+
{"false", BACKSLASH_QUOTE_OFF},
265+
{"yes", BACKSLASH_QUOTE_ON},
266+
{"no", BACKSLASH_QUOTE_OFF},
267+
{"1", BACKSLASH_QUOTE_ON},
268+
{"0", BACKSLASH_QUOTE_OFF},
269+
{NULL, 0}
270+
};
271+
256272
/*
257273
* GUC option variables that are exported from this module
258274
*/
@@ -311,7 +327,6 @@ static char *syslog_ident_str;
311327
static bool phony_autocommit;
312328
static bool session_auth_is_superuser;
313329
static double phony_random_seed;
314-
static char *backslash_quote_string;
315330
static char *client_encoding_string;
316331
static char *datestyle_string;
317332
static char *locale_collate;
@@ -1959,15 +1974,6 @@ static struct config_string ConfigureNamesString[] =
19591974
"", NULL, show_archive_command
19601975
},
19611976

1962-
{
1963-
{"backslash_quote", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1964-
gettext_noop("Sets whether \"\\'\" is allowed in string literals."),
1965-
gettext_noop("Valid values are ON, OFF, and SAFE_ENCODING.")
1966-
},
1967-
&backslash_quote_string,
1968-
"safe_encoding", assign_backslash_quote, NULL
1969-
},
1970-
19711977
{
19721978
{"client_encoding", PGC_USERSET, CLIENT_CONN_LOCALE,
19731979
gettext_noop("Sets the client's character set encoding."),
@@ -2419,6 +2425,15 @@ static struct config_string ConfigureNamesString[] =
24192425

24202426
static struct config_enum ConfigureNamesEnum[] =
24212427
{
2428+
{
2429+
{"backslash_quote", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
2430+
gettext_noop("Sets whether \"\\'\" is allowed in string literals."),
2431+
gettext_noop("Valid values are ON, OFF, and SAFE_ENCODING.")
2432+
},
2433+
&backslash_quote,
2434+
BACKSLASH_QUOTE_SAFE_ENCODING, backslash_quote_options, NULL, NULL
2435+
},
2436+
24222437
{
24232438
{"client_min_messages", PGC_USERSET, LOGGING_WHEN,
24242439
gettext_noop("Sets the message levels that are sent to the client."),

src/include/parser/gramparse.h

Lines changed: 2 additions & 2 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/parser/gramparse.h,v 1.40 2008/01/01 19:45:58 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/parser/gramparse.h,v 1.41 2008/04/04 11:47:19 mha Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -35,7 +35,7 @@ typedef enum
3535
} BackslashQuoteType;
3636

3737
/* GUC variables in scan.l (every one of these is a bad idea :-() */
38-
extern BackslashQuoteType backslash_quote;
38+
extern int backslash_quote;
3939
extern bool escape_string_warning;
4040
extern bool standard_conforming_strings;
4141

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy