Index: configure =================================================================== RCS file: /projects/cvsroot/pgsql/configure,v retrieving revision 1.466 diff -c -r1.466 configure *** configure 6 Dec 2005 18:35:08 -0000 1.466 --- configure 8 Dec 2005 17:08:44 -0000 *************** *** 860,865 **** --- 860,866 ---- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-integer-datetimes enable 64-bit integer date/time support + --enable-standard-strings enable strings without backslash as an escape --enable-nls[=LANGUAGES] enable Native Language Support --disable-shared do not build shared libraries --disable-rpath do not embed shared library search path in executables *************** *** 1728,1733 **** --- 1729,1772 ---- # + # standard conforming strings (--enable-standard-strings) + # + echo "$as_me:$LINENO: checking whether to build with standard conforming strings" >&5 + echo $ECHO_N "checking whether to build with standard conforming strings... $ECHO_C" >&6 + + + # Check whether --enable-standard-strings or --disable-standard-strings was given. + if test "${enable_standard_strings+set}" = set; then + enableval="$enable_standard_strings" + + case $enableval in + yes) + + cat >>confdefs.h <<\_ACEOF + #define USE_STANDARD_CONFORMING_STRINGS 1 + _ACEOF + + ;; + no) + : + ;; + *) + { { echo "$as_me:$LINENO: error: no argument expected for --enable-standard-strings option" >&5 + echo "$as_me: error: no argument expected for --enable-standard-strings option" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + else + enable_standard_strings=no + + fi; + + echo "$as_me:$LINENO: result: $enable_standard_strings" >&5 + echo "${ECHO_T}$enable_standard_strings" >&6 + + + # # NLS # echo "$as_me:$LINENO: checking whether NLS is wanted" >&5 Index: configure.in =================================================================== RCS file: /projects/cvsroot/pgsql/configure.in,v retrieving revision 1.436 diff -c -r1.436 configure.in *** configure.in 6 Dec 2005 18:35:09 -0000 1.436 --- configure.in 8 Dec 2005 17:08:44 -0000 *************** *** 149,154 **** --- 149,164 ---- # + # standard conforming strings (--enable-standard-strings) + # + AC_MSG_CHECKING([whether to build with standard conforming strings]) + PGAC_ARG_BOOL(enable, standard-strings, no, [ --enable-standard-strings enable standard conforming strings], + [AC_DEFINE([USE_STANDARD_CONFORMING_STRINGS], 1, + [Define to 1 if you want standard conforming strings. (--enable-standard-strings)])]) + AC_MSG_RESULT([$enable_standard_strings]) + + + # # NLS # AC_MSG_CHECKING([whether NLS is wanted]) Index: src/backend/parser/scan.l =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/parser/scan.l,v retrieving revision 1.128 diff -c -r1.128 scan.l *** src/backend/parser/scan.l 16 Aug 2005 00:48:12 -0000 1.128 --- src/backend/parser/scan.l 8 Dec 2005 17:08:45 -0000 *************** *** 50,55 **** --- 50,58 ---- static int xcdepth = 0; /* depth of nesting in slash-star comments */ static char *dolqstart; /* current $foo$ quote start string */ + #ifdef USE_STANDARD_CONFORMING_STRINGS + static bool standard_string; + #else /* * GUC variable. 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; *************** *** 60,65 **** --- 63,69 ---- bool escape_string_warning; static bool warn_on_first_escape; + #endif /* * literalbuf is used to accumulate literal values when multiple rules *************** *** 76,82 **** --- 80,88 ---- static void addlitchar(unsigned char ychar); static char *litbufdup(void); static int pg_err_position(void); + #ifndef USE_STANDARD_CONFORMING_STRINGS static void check_escape_warning(void); + #endif /* * When we parse a token that requires multiple lexer rules to process, *************** *** 301,309 **** * Dollar quoted strings are totally opaque, and no escaping is done on them. * Other quoted strings must allow some special characters such as single-quote * and newline. ! * Embedded single-quotes are implemented both in the SQL standard ! * style of two adjacent single quotes "''" and in the Postgres/Java style ! * of escaped-quote "\'". * Other embedded escaped characters are matched explicitly and the leading * backslash is dropped from the string. * Note that xcstart must appear before operator, as explained above! --- 307,316 ---- * Dollar quoted strings are totally opaque, and no escaping is done on them. * Other quoted strings must allow some special characters such as single-quote * and newline. ! * Standard quoted strings allow a single-quote to be represented in the SQL ! * standard style of two adjacent single quotes "''". ! * Extended quoted strings support embedded single-quotes in both in the SQL ! * standard style and in the Postgres/Java style of escaped-quote "\'". * Other embedded escaped characters are matched explicitly and the leading * backslash is dropped from the string. * Note that xcstart must appear before operator, as explained above! *************** *** 426,438 **** --- 433,453 ---- } {xqstart} { + #ifdef USE_STANDARD_CONFORMING_STRINGS + standard_string = true; + #else warn_on_first_escape = true; + #endif token_start = yytext; BEGIN(xq); startlit(); } {xestart} { + #ifdef USE_STANDARD_CONFORMING_STRINGS + standard_string = false; + #else warn_on_first_escape = false; + #endif token_start = yytext; BEGIN(xq); startlit(); *************** *** 451,456 **** --- 466,477 ---- addlit(yytext, yyleng); } {xqescape} { + #ifdef USE_STANDARD_CONFORMING_STRINGS + if (standard_string) + addlit(yytext, yyleng); + else + addlitchar(unescape_single_char(yytext[1])); + #else if (yytext[1] == '\'') { if (warn_on_first_escape && escape_string_warning) *************** *** 474,491 **** --- 495,527 ---- else check_escape_warning(); addlitchar(unescape_single_char(yytext[1])); + #endif } {xqoctesc} { + #ifdef USE_STANDARD_CONFORMING_STRINGS + if (standard_string) + addlit(yytext, yyleng); + else + addlitchar(strtoul(yytext+1, NULL, 8)); + #else unsigned char c = strtoul(yytext+1, NULL, 8); check_escape_warning(); addlitchar(c); + #endif } {xqhexesc} { + #ifdef USE_STANDARD_CONFORMING_STRINGS + if (standard_string) + addlit(yytext, yyleng); + else + addlitchar(strtoul(yytext+2, NULL, 16)); + #else unsigned char c = strtoul(yytext+2, NULL, 16); check_escape_warning(); addlitchar(c); + #endif } {quotecontinue} { /* ignore */ *************** *** 874,880 **** return c; } } ! static void check_escape_warning(void) { --- 910,916 ---- return c; } } ! #ifndef USE_STANDARD_CONFORMING_STRINGS static void check_escape_warning(void) { *************** *** 886,888 **** --- 922,925 ---- errposition(pg_err_position()))); warn_on_first_escape = false; /* warn only once per string */ } + #endif Index: src/backend/utils/misc/guc.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc.c,v retrieving revision 1.301 diff -c -r1.301 guc.c *** src/backend/utils/misc/guc.c 22 Nov 2005 18:17:26 -0000 1.301 --- src/backend/utils/misc/guc.c 8 Dec 2005 17:08:46 -0000 *************** *** 957,963 **** &pg_krb_caseins_users, false, NULL, NULL }, ! { {"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, gettext_noop("Warn about backslash escapes in ordinary string literals."), --- 957,963 ---- &pg_krb_caseins_users, false, NULL, NULL }, ! #ifndef USE_STANDARD_CONFORMING_STRINGS { {"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, gettext_noop("Warn about backslash escapes in ordinary string literals."), *************** *** 966,972 **** &escape_string_warning, false, NULL, NULL }, ! { {"standard_conforming_strings", PGC_INTERNAL, PRESET_OPTIONS, gettext_noop("'...' strings treat backslashes literally."), --- 966,972 ---- &escape_string_warning, false, NULL, NULL }, ! #endif { {"standard_conforming_strings", PGC_INTERNAL, PRESET_OPTIONS, gettext_noop("'...' strings treat backslashes literally."), *************** *** 974,980 **** --- 974,984 ---- GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE }, &standard_conforming_strings, + #ifdef USE_STANDARD_CONFORMING_STRINGS + true, NULL, NULL + #else false, NULL, NULL + #endif }, /* End-of-list marker */ Index: src/include/pg_config.h.in =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/pg_config.h.in,v retrieving revision 1.88 diff -c -r1.88 pg_config.h.in *** src/include/pg_config.h.in 6 Dec 2005 02:29:03 -0000 1.88 --- src/include/pg_config.h.in 8 Dec 2005 17:08:46 -0000 *************** *** 633,638 **** --- 633,642 ---- (--enable-integer-datetimes) */ #undef USE_INTEGER_DATETIMES + /* Define to 1 if you want standard conforming strings. + (--enable-standard-strings) */ + #undef USE_STANDARD_CONFORMING_STRINGS + /* Define to select named POSIX semaphores. */ #undef USE_NAMED_POSIX_SEMAPHORES Index: src/include/utils/guc.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/utils/guc.h,v retrieving revision 1.63 diff -c -r1.63 guc.h *** src/include/utils/guc.h 15 Oct 2005 02:49:46 -0000 1.63 --- src/include/utils/guc.h 8 Dec 2005 17:08:46 -0000 *************** *** 120,126 **** --- 120,128 ---- extern bool Australian_timezones; extern bool default_with_oids; + #ifndef USE_STANDARD_CONFORMING_STRINGS extern bool escape_string_warning; + #endif extern int log_min_error_statement; extern int log_min_messages;