Server Configuration
Escape string syntax (E'...'>) should be used for
- escapes, because in future versions of
-
PostgreSQL ordinary strings will have
+ backslash escape sequences, because ordinary strings have
the standard-conforming behavior of treating backslashes
- literally.
+ literally when the standard-conforming-strings>
+ option is set on>.
+
+
+
+
+
+ standard_conforming_strings (boolean)
+
+
standard_conforming_strings> configuration parameter
+
+
+ Controls whether ordinary string literals
+ ('...'>) treat backslashes literally, as specified in
+ the SQL standard. Applications may check this
+ parameter to determine how string literals will be processed.
+ The presence of this parameter can also be taken as an indication
+ that the escape string syntax (E'...'>) is supported.
-
- standard_conforming_strings (boolean)
-
-
standard_conforming_strings> configuration parameter
-
-
- Reports whether ordinary string literals
- ('...'>) treat backslashes literally, as specified in
- the SQL standard. The value is currently always off>,
- indicating that backslashes are treated as escapes. It is planned
- that this will change to on> in a future
-
PostgreSQL release when string literal
- syntax changes to meet the standard. Applications may check this
- parameter to determine how string literals will be processed.
- The presence of this parameter can also be taken as an indication
- that the escape string syntax (E'...'>) is supported.
-
-
-
-
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.130 2006/03/05 15:58:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.131 2006/03/06 19:49:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static char *dolqstart; /* current $foo$ quote start string */
/*
- * GUC variable. This is a DIRECT violation of the warning given at the
+ * GUC variables. This is a DIRECT violation of the warning given at the
* head of gram.y, ie flex/bison code must not depend on any GUC variables;
* as such, changing its value can induce very unintuitive behavior.
* But we shall have to live with it as a short-term thing until the switch
* to SQL-standard string syntax is complete.
*/
bool escape_string_warning;
+bool standard_conforming_strings;
static bool warn_on_first_escape;
static char *litbufdup(void);
static int pg_err_position(void);
static void check_escape_warning(void);
+static void check_string_escape_warning(unsigned char ychar);
/*
* When we parse a token that requires multiple lexer rules to process,
* extended C-style comments
* delimited identifiers (double-quoted identifiers)
* hexadecimal numeric string
- * quoted strings
+ * standard quoted strings
+ * extended quoted strings (support backslash escape sequences)
* $foo$ quoted strings
*/
%x xc
%x xd
%x xh
+%x xe
%x xq
%x xdolq
/* Quoted string that allows backslash escapes */
xestart [eE]{quote}
+xeinside [^\\']+
+xeescape [\\][^0-7]
+xeoctesc [\\][0-7]{1,3}
+xehexesc [\\]x[0-9A-Fa-f]{1,2}
/* Extended quote
* xqdouble implements embedded quote, ''''
xqstart {quote}
xqdouble {quote}{quote}
xqinside [^\\']+
-xqescape [\\][^0-7]
-xqoctesc [\\][0-7]{1,3}
-xqhexesc [\\]x[0-9A-Fa-f]{1,2}
+xqbackslash [\\]
/* $foo$ style quotes ("dollar quoting")
* The quoted string starts with $foo$ where "foo" is an optional string
{xqstart} {
warn_on_first_escape = true;
token_start = yytext;
- BEGIN(xq);
+ if (standard_conforming_strings)
+ BEGIN(xq);
+ else
+ BEGIN(xe);
startlit();
}
{xestart} {
warn_on_first_escape = false;
token_start = yytext;
- BEGIN(xq);
+ BEGIN(xe);
startlit();
}
->{quotestop} |
-{quotefail} {
+,xe>{quotestop} |
+,xe>{quotefail} {
yyless(1);
BEGIN(INITIAL);
yylval.str = litbufdup();
return SCONST;
}
-{xqdouble} {
+,xe>{xqdouble} {
addlitchar('\'');
}
{xqinside} {
addlit(yytext, yyleng);
}
-{xqescape} {
- if (yytext[1] == '\'')
- {
- if (warn_on_first_escape && escape_string_warning)
- ereport(WARNING,
- (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
- errmsg("nonstandard use of \\' in a string literal"),
- errhint("Use '' to write quotes in strings, or use the escape string syntax (E'...')."),
- errposition(pg_err_position())));
- warn_on_first_escape = false; /* warn only once per string */
- }
- else if (yytext[1] == '\\')
- {
- if (warn_on_first_escape && escape_string_warning)
- ereport(WARNING,
- (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
- errmsg("nonstandard use of \\\\ in a string literal"),
- errhint("Use the escape string syntax for backslashes, e.g., E'\\\\'."),
- errposition(pg_err_position())));
- warn_on_first_escape = false; /* warn only once per string */
- }
- else
- check_escape_warning();
+{xeinside} {
+ addlit(yytext, yyleng);
+ }
+{xqbackslash} {
+ check_string_escape_warning(yytext[1]);
+ addlitchar('\\');
+ }
+{xeescape} {
+ check_string_escape_warning(yytext[1]);
addlitchar(unescape_single_char(yytext[1]));
}
-q>{xqoctesc} {
+e>{xeoctesc} {
unsigned char c = strtoul(yytext+1, NULL, 8);
check_escape_warning();
addlitchar(c);
}
-q>{xqhexesc} {
+e>{xehexesc} {
unsigned char c = strtoul(yytext+2, NULL, 16);
check_escape_warning();
addlitchar(c);
}
-{quotecontinue} {
+,xe>{quotecontinue} {
/* ignore */
}
-q>. {
+e>. {
/* This is only needed for \ just before EOF */
addlitchar(yytext[0]);
}
-><> { yyerror("unterminated quoted string"); }
+,xe><> { yyerror("unterminated quoted string"); }
{dolqdelim} {
token_start = yytext;
}
}
+static void
+check_string_escape_warning(unsigned char ychar)
+{
+ if (ychar == '\'')
+ {
+ if (warn_on_first_escape && escape_string_warning)
+ ereport(WARNING,
+ (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
+ errmsg("nonstandard use of \\' in a string literal"),
+ errhint("Use '' to write quotes in strings, or use the escape string syntax (E'...')."),
+ errposition(pg_err_position())));
+ warn_on_first_escape = false; /* warn only once per string */
+ }
+ else if (ychar == '\\')
+ {
+ if (warn_on_first_escape && escape_string_warning)
+ ereport(WARNING,
+ (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
+ errmsg("nonstandard use of \\\\ in a string literal"),
+ errhint("Use the escape string syntax for backslashes, e.g., E'\\\\'."),
+ errposition(pg_err_position())));
+ warn_on_first_escape = false; /* warn only once per string */
+ }
+ else
+ check_escape_warning();
+}
+
static void
check_escape_warning(void)
{
* Written by Peter Eisentraut
.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.312 2006/03/05 15:58:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.313 2006/03/06 19:49:20 momjian Exp $
*
*--------------------------------------------------------------------
*/
static int max_identifier_length;
static int block_size;
static bool integer_datetimes;
-static bool standard_conforming_strings;
/* should be static, but commands/variable.c needs to get at these */
char *role_string;
},
{
- {"standard_conforming_strings", PGC_INTERNAL, PRESET_OPTIONS,
+ {"standard_conforming_strings", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
gettext_noop("'...' strings treat backslashes literally."),
NULL,
- GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+ GUC_REPORT
},
&standard_conforming_strings,
false, NULL, NULL
#add_missing_from = off
#array_nulls = on
#default_with_oids = off
-#escape_string_warning = off
+#escape_string_warning = off # warn about backslashes in string literals
+#standard_conforming_strings = off # SQL standard string literal processing
#regex_flavor = advanced # advanced, extended, or basic
#sql_inheritance = on
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.114 2006/03/05 15:58:51 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.115 2006/03/06 19:49:20 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
}
+/*
+ * Test if the current session uses standard string literals.
+ *
+ * Note: this will correctly detect the setting only with a protocol-3.0
+ * or newer backend; otherwise it will always say "false".
+ */
+bool
+standard_strings(void)
+{
+ const char *val;
+
+ if (!pset.db)
+ return false;
+
+ val = PQparameterStatus(pset.db, "standard_conforming_strings");
+
+ if (val && strcmp(val, "on") == 0)
+ return true;
+
+ return false;
+}
+
+
/*
* Return the session user of the current connection.
*
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.46 2006/03/05 15:58:51 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.47 2006/03/06 19:49:20 momjian Exp $
*/
#ifndef COMMON_H
#define COMMON_H
extern bool SendQuery(const char *query);
extern bool is_superuser(void);
+extern bool standard_strings(void);
extern const char *session_username(void);
extern char *expand_tilde(char **filename);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.16 2006/03/05 15:58:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.17 2006/03/06 19:49:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* extended C-style comments
* delimited identifiers (double-quoted identifiers)
* hexadecimal numeric string
- * quoted strings
+ * standard quoted strings
+ * extended quoted strings (support backslash escape sequences)
* $foo$ quoted strings
*/
%x xc
%x xd
%x xh
+%x xe
%x xq
%x xdolq
/* Additional exclusive states for psql only: lex backslash commands */
/* Quoted string that allows backslash escapes */
xestart [eE]{quote}
+xeinside [^\\']+
+xeescape [\\][^0-7]
+xeoctesc [\\][0-7]{1,3}
+xehexesc [\\]x[0-9A-Fa-f]{1,2}
/* Extended quote
* xqdouble implements embedded quote, ''''
*/
xqstart {quote}
xqdouble {quote}{quote}
-xqinside [^\\']+
-xqescape [\\][^0-7]
-xqoctesc [\\][0-7]{1,3}
-xqhexesc [\\]x[0-9A-Fa-f]{1,2}
+xqinside [^']+
/* $foo$ style quotes ("dollar quoting")
* The quoted string starts with $foo$ where "foo" is an optional string
}
{xqstart} {
- BEGIN(xq);
+ if (standard_strings())
+ BEGIN(xq);
+ else
+ BEGIN(xe);
ECHO;
}
{xestart} {
- BEGIN(xq);
+ BEGIN(xe);
ECHO;
}
->{quotestop} |
-{quotefail} {
+,xe>{quotestop} |
+,xe>{quotefail} {
yyless(1);
BEGIN(INITIAL);
ECHO;
}
-{xqdouble} {
+,xe>{xqdouble} {
ECHO;
}
{xqinside} {
ECHO;
}
-{xqescape} {
+{xeinside} {
+ ECHO;
+ }
+{xeescape} {
ECHO;
}
-q>{xqoctesc} {
+e>{xeoctesc} {
ECHO;
}
-q>{xqhexesc} {
+e>{xehexesc} {
ECHO;
}
-{quotecontinue} {
+,xe>{quotecontinue} {
ECHO;
}
-q>. {
+e>. {
/* This is only needed for \ just before EOF */
ECHO;
}
"\\r" { appendPQExpBufferChar(output_buf, '\r'); }
"\\f" { appendPQExpBufferChar(output_buf, '\f'); }
-{xqoctesc} {
+{xeoctesc} {
/* octal case */
appendPQExpBufferChar(output_buf,
(char) strtol(yytext + 1, NULL, 8));
}
-{xqhexesc} {
+{xehexesc} {
/* hex case */
appendPQExpBufferChar(output_buf,
(char) strtol(yytext + 2, NULL, 16));
result = PSCAN_INCOMPLETE;
*prompt = PROMPT_SINGLEQUOTE;
break;
+ case xe:
+ result = PSCAN_INCOMPLETE;
+ *prompt = PROMPT_SINGLEQUOTE;
+ break;
case xdolq:
result = PSCAN_INCOMPLETE;
*prompt = PROMPT_DOLLARQUOTE;
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
* Written by Peter Eisentraut
.
*
- * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.65 2006/03/06 18:38:11 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.66 2006/03/06 19:49:20 momjian Exp $
*--------------------------------------------------------------------
*/
#ifndef GUC_H
extern bool default_with_oids;
extern bool escape_string_warning;
+extern bool standard_conforming_strings;
extern int log_min_error_statement;
extern int log_min_messages;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.144 2006/03/05 15:59:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.145 2006/03/06 19:49:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static int xcdepth = 0; /* depth of nesting in slash-star comments */
static char *dolqstart; /* current $foo$ quote start string */
bool escape_string_warning;
-static bool warn_on_first_escape;
+bool standard_conforming_strings;
+static bool warn_on_first_escape;
/*
* literalbuf is used to accumulate literal values when multiple rules
* extended C-style comments - thomas 1997-07-12
* delimited identifiers (double-quoted identifiers) - thomas 1997-10-27
* hexadecimal numeric string - thomas 1997-11-16
- * quoted strings - thomas 1997-07-30
+ * standard quoted strings - thomas 1997-07-30
+ * extended quoted strings (support backslash escape sequences)
* $foo$ quoted strings
*/
%x xd
%x xdc
%x xh
+%x xe
%x xq
%x xdolq
%x xpre
/* Quoted string that allows backslash escapes */
xestart [eE]{quote}
+xeinside [^\\']+
+xeescape [\\][^0-7]
+xeoctesc [\\][0-7]{1,3}
+xehexesc [\\]x[0-9A-Fa-f]{1,2}
/* C version of hex number */
xch 0[xX][0-9A-Fa-f]*
xqstart {quote}
xqdouble {quote}{quote}
xqinside [^\\']+
-xqescape [\\][^0-7]
-xqoctesc [\\][0-7]{1,3}
-xqhexesc [\\]x[0-9A-Fa-f]{1,2}
+xqbackslash [\\]
/* $foo$ style quotes ("dollar quoting")
* The quoted string starts with $foo$ where "foo" is an optional string
warn_on_first_escape = true;
token_start = yytext;
state_before = YYSTATE;
- BEGIN(xq);
+ if (standard_conforming_strings)
+ BEGIN(xq);
+ else
+ BEGIN(xe);
startlit();
}
{xestart} {
warn_on_first_escape = false;
token_start = yytext;
state_before = YYSTATE;
- BEGIN(xq);
+ BEGIN(xe);
startlit();
}
-{quotestop} |
->{quotefail} {
+,xe>{quotestop} |
+,xe>{quotefail} {
yyless(1);
BEGIN(state_before);
yylval.str = mm_strdup(literalbuf);
return SCONST;
}
->{xqdouble} { addlitchar('\''); }
+,xe>{xqdouble} { addlitchar('\''); }
{xqinside} { addlit(yytext, yyleng); }
-{xqescape} {
+{xeinside} { addlit(yytext, yyleng); }
+{xqbackslash} {
+ check_escape_warning();
+ addlitchar('\\');
+ }
+{xeescape} {
check_escape_warning();
addlit(yytext, yyleng);
}
-q>{xqoctesc} {
+e>{xeoctesc} {
check_escape_warning();
addlit(yytext, yyleng);
}
-q>{xqhexesc} {
+e>{xehexesc} {
check_escape_warning();
addlit(yytext, yyleng);
}
->{quotecontinue} { /* ignore */ }
-q>{other} {
+,xe>{quotecontinue} { /* ignore */ }
+e>. {
/* This is only needed for \ just before EOF */
addlitchar(yytext[0]);
}
-><> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated quoted string"); }
+,xe><> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated quoted string"); }
{dolqfailed} {
/* throw back all but the initial "$" */
yyless(1);
(1 row)
-- PostgreSQL extension to allow using back reference in replace string;
-SELECT regexp_replace('1112223333', '(\\d{3})(\\d{3})(\\d{4})', '(\\1) \\2-\\3');
+SELECT regexp_replace('1112223333', E'(\\d{3})(\\d{3})(\\d{4})', E'(\\1) \\2-\\3');
regexp_replace
----------------
(111) 222-3333
(1 row)
-SELECT regexp_replace('AAA BBB CCC ', '\\s+', ' ', 'g');
+SELECT regexp_replace('AAA BBB CCC ', E'\\s+', ' ', 'g');
regexp_replace
----------------
AAA BBB CCC
t
(1 row)
+--
+-- test behavior of escape_string_warning and standard_conforming_strings options
+--
+set escape_string_warning = off;
+set standard_conforming_strings = off;
+show escape_string_warning;
+ escape_string_warning
+-----------------------
+ off
+(1 row)
+
+show standard_conforming_strings;
+ standard_conforming_strings
+-----------------------------
+ off
+(1 row)
+
+set escape_string_warning = on;
+set standard_conforming_strings = on;
+show escape_string_warning;
+ escape_string_warning
+-----------------------
+ on
+(1 row)
+
+show standard_conforming_strings;
+ standard_conforming_strings
+-----------------------------
+ on
+(1 row)
+
+select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6;
+WARNING: nonstandard use of escape in a string literal at character 8
+HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
+WARNING: nonstandard use of escape in a string literal at character 23
+HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
+WARNING: nonstandard use of escape in a string literal at character 40
+HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
+WARNING: nonstandard use of escape in a string literal at character 59
+HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
+WARNING: nonstandard use of escape in a string literal at character 76
+HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
+WARNING: nonstandard use of escape in a string literal at character 93
+HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
+ f1 | f2 | f3 | f4 | f5 | f6
+-------+--------+---------+-------+--------+----
+ a\bcd | a\b'cd | a\b''cd | abcd\ | ab\'cd | \\
+(1 row)
+
+set standard_conforming_strings = off;
+select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6;
+WARNING: nonstandard use of \\ in a string literal at character 8
+HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
+WARNING: nonstandard use of \\ in a string literal at character 24
+HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
+WARNING: nonstandard use of \\ in a string literal at character 42
+HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
+WARNING: nonstandard use of \\ in a string literal at character 62
+HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
+WARNING: nonstandard use of \\ in a string literal at character 80
+HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
+WARNING: nonstandard use of \\ in a string literal at character 98
+HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
+ f1 | f2 | f3 | f4 | f5 | f6
+-------+--------+---------+-------+--------+----
+ a\bcd | a\b'cd | a\b''cd | abcd\ | ab\'cd | \\
+(1 row)
+
+set escape_string_warning = off;
+set standard_conforming_strings = on;
+select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6;
+ f1 | f2 | f3 | f4 | f5 | f6
+-------+--------+---------+-------+--------+----
+ a\bcd | a\b'cd | a\b''cd | abcd\ | ab\'cd | \\
+(1 row)
+
+set standard_conforming_strings = off;
+select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6;
+ f1 | f2 | f3 | f4 | f5 | f6
+-------+--------+---------+-------+--------+----
+ a\bcd | a\b'cd | a\b''cd | abcd\ | ab\'cd | \\
+(1 row)
+
SELECT SUBSTRING('abcdefg' FROM 'b(.*)f') AS "cde";
-- PostgreSQL extension to allow using back reference in replace string;
-SELECT regexp_replace('1112223333', '(\\d{3})(\\d{3})(\\d{4})', '(\\1) \\2-\\3');
-SELECT regexp_replace('AAA BBB CCC ', '\\s+', ' ', 'g');
+SELECT regexp_replace('1112223333', E'(\\d{3})(\\d{3})(\\d{4})', E'(\\1) \\2-\\3');
+SELECT regexp_replace('AAA BBB CCC ', E'\\s+', ' ', 'g');
SELECT regexp_replace('AAA', '^|$', 'Z', 'g');
SELECT regexp_replace('AAA aaa', 'A+', 'Z', 'gi');
-- invalid option of REGEXP_REPLACE
select md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'::bytea) = 'd174ab98d277d9f5a5611c2c9f419d9f' AS "TRUE";
select md5('12345678901234567890123456789012345678901234567890123456789012345678901234567890'::bytea) = '57edf4a22be3c955ac49da2e2107b67a' AS "TRUE";
+
+--
+-- test behavior of escape_string_warning and standard_conforming_strings options
+--
+set escape_string_warning = off;
+set standard_conforming_strings = off;
+
+show escape_string_warning;
+show standard_conforming_strings;
+
+set escape_string_warning = on;
+set standard_conforming_strings = on;
+
+show escape_string_warning;
+show standard_conforming_strings;
+
+select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6;
+
+set standard_conforming_strings = off;
+
+select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6;
+
+set escape_string_warning = off;
+set standard_conforming_strings = on;
+
+select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6;
+
+set standard_conforming_strings = off;
+
+select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6;