Force standard_conforming_strings to always be ON. master
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 21 Jan 2026 20:08:38 +0000 (15:08 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 21 Jan 2026 20:08:38 +0000 (15:08 -0500)
Continuing to support this backwards-compatibility feature has
nontrivial costs; in particular it is potentially a security hazard
if an application somehow gets confused about which setting the
server is using.  We changed the default to ON fifteen years ago,
which seems like enough time for applications to have adapted.
Let's remove support for the legacy string syntax.

We should not remove the GUC altogether, since client-side code will
still test it, pg_dump scripts will attempt to set it to ON, etc.
Instead, just prevent it from being set to OFF.  There is precedent
for this approach (see commit de66987ad).

This patch does remove the related GUC escape_string_warning, however.
That setting does nothing when standard_conforming_strings is on,
so it's now useless.  We could leave it in place as a do-nothing
setting to avoid breaking clients that still set it, if there are any.
But it seems likely that any such client is also trying to turn off
standard_conforming_strings, so it'll need work anyway.

The client-side changes in this patch are pretty minimal, because even
though we are dropping the server's support, most of our clients still
need to be able to talk to older server versions.  We could remove
dead client code only once we disclaim compatibility with pre-v19
servers, which is surely years away.  One change of note is that
pg_dump/pg_dumpall now set standard_conforming_strings = on in their
source session, rather than accepting the source server's default.
This ensures that literals in view definitions and such will be
printed in a way that's acceptable to v19+.  In particular,
pg_upgrade will work transparently even if the source installation has
standard_conforming_strings = off.  (However, pg_restore will behave
the same as before if given an archive file containing
standard_conforming_strings = off.  Such an archive will not be safely
restorable into v19+, but we shouldn't break the ability to extract
valid data from it for use with an older server.)

Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3279216.1767072538@sss.pgh.pa.us

48 files changed:
contrib/hstore/expected/hstore.out
contrib/hstore/sql/hstore.sql
contrib/pg_stat_statements/pg_stat_statements.c
contrib/pg_trgm/expected/pg_trgm.out
contrib/pg_trgm/sql/pg_trgm.sql
contrib/test_decoding/test_decoding.c
doc/src/sgml/config.sgml
doc/src/sgml/ecpg.sgml
doc/src/sgml/func/func-matching.sgml
doc/src/sgml/hstore.sgml
doc/src/sgml/libpq.sgml
doc/src/sgml/protocol.sgml
doc/src/sgml/syntax.sgml
src/backend/commands/variable.c
src/backend/parser/scan.l
src/backend/utils/adt/quote.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/misc/guc_parameters.dat
src/backend/utils/misc/guc_tables.c
src/backend/utils/misc/postgresql.conf.sample
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dumpall.c
src/fe_utils/string_utils.c
src/include/parser/parser.h
src/include/parser/scanner.h
src/include/utils/guc_hooks.h
src/interfaces/ecpg/test/expected/sql-quote.c
src/interfaces/ecpg/test/expected/sql-quote.stderr
src/interfaces/ecpg/test/expected/sql-quote.stdout
src/interfaces/ecpg/test/expected/sql-show.c
src/interfaces/ecpg/test/expected/sql-show.stderr
src/interfaces/ecpg/test/expected/sql-show.stdout
src/interfaces/ecpg/test/sql/quote.pgc
src/interfaces/ecpg/test/sql/show.pgc
src/test/examples/testlibpq3.c
src/test/examples/testlibpq3.sql
src/test/modules/test_regex/expected/test_regex.out
src/test/modules/test_regex/expected/test_regex_utf8.out
src/test/modules/test_regex/sql/test_regex.sql
src/test/modules/test_regex/sql/test_regex_utf8.sql
src/test/regress/expected/plpgsql.out
src/test/regress/expected/regex.out
src/test/regress/expected/strings.out
src/test/regress/sql/plpgsql.sql
src/test/regress/sql/regex.sql
src/test/regress/sql/strings.sql
src/tutorial/syscat.source

index 1836c9acf39af1e3bd316a73597feb3d72de3bb8..acea8806ba47e986ad23d9772345cab14c793297 100644 (file)
@@ -7,7 +7,6 @@ WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid);
 --------+---------
 (0 rows)
 
-set escape_string_warning=off;
 --hstore;
 select ''::hstore;
  hstore 
index efef91292a3372cff75972aea325d07542e040ae..8ae95e8a510549d06e4e11079b4d97e0695374e2 100644 (file)
@@ -5,8 +5,6 @@ SELECT amname, opcname
 FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod
 WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid);
 
-set escape_string_warning=off;
-
 --hstore;
 
 select ''::hstore;
index adc493e9850e44dd8be4af19bf943c473260c24e..4a427533bd88d39bcd684de6038bba7d2945e878 100644 (file)
@@ -2991,9 +2991,6 @@ fill_in_constant_lengths(JumbleState *jstate, const char *query,
                                                         &ScanKeywords,
                                                         ScanKeywordTokens);
 
-       /* we don't want to re-emit any escape string warnings */
-       yyextra.escape_string_warning = false;
-
        /* Search for each constant, in sequence */
        for (int i = 0; i < jstate->clocations_count; i++)
        {
index 04da98170ab15ab0e9dc4c58b1d3f38de4ec7cfb..612625f1fda79a61f365758b7af5429eda42bdd5 100644 (file)
@@ -7,9 +7,6 @@ WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid);
 --------+---------
 (0 rows)
 
---backslash is used in tests below, installcheck will fail if
---standard_conforming_string is off
-set standard_conforming_strings=on;
 -- reduce noise
 set extra_float_digits = 0;
 select show_trgm('');
index 44debced6d581708d327756781e23b56c3cf03b0..49db86caf7d88b8d10ba9b1f55cece1a75894058 100644 (file)
@@ -5,10 +5,6 @@ SELECT amname, opcname
 FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod
 WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid);
 
---backslash is used in tests below, installcheck will fail if
---standard_conforming_string is off
-set standard_conforming_strings=on;
-
 -- reduce noise
 set extra_float_digits = 0;
 
index e104aa5aa6e0c5da415a88443278006b695c19c8..809382880a26826faf7d2e5a78dba4f92b4b6e58 100644 (file)
@@ -474,8 +474,8 @@ pg_decode_filter(LogicalDecodingContext *ctx,
  * Print literal `outputstr' already represented as string of type `typid'
  * into stringbuf `s'.
  *
- * Some builtin types aren't quoted, the rest is quoted. Escaping is done as
- * if standard_conforming_strings were enabled.
+ * Some builtin types aren't quoted, the rest is quoted. Escaping is done
+ * per standard SQL rules.
  */
 static void
 print_literal(StringInfo s, Oid typid, char *outputstr)
index 0fad34da6eb0bed82a98de207782eed8cad3c5fd..5560b95ee603155a427c57f1ccc5a66c2f85b926 100644 (file)
@@ -11390,8 +11390,9 @@ dynamic_library_path = '/usr/local/lib/postgresql:$libdir'
       </term>
       <listitem>
        <para>
-        This controls whether a quote mark can be represented by
-        <literal>\'</literal> in a string literal.  The preferred, SQL-standard way
+        This parameter controls whether a quote mark can be represented by
+        <literal>\'</literal> in the escape string syntax
+        (<literal>E'...'</literal>).  The preferred, SQL-standard way
         to represent a quote mark is by doubling it (<literal>''</literal>) but
         <productname>PostgreSQL</productname> has historically also accepted
         <literal>\'</literal>. However, use of <literal>\'</literal> creates security risks
@@ -11410,34 +11411,9 @@ dynamic_library_path = '/usr/local/lib/postgresql:$libdir'
        </para>
 
        <para>
-        Note that in a standard-conforming string literal, <literal>\</literal> just
-        means <literal>\</literal> anyway.  This parameter only affects the handling of
-        non-standard-conforming literals, including
-        escape string syntax (<literal>E'...'</literal>).
-       </para>
-      </listitem>
-     </varlistentry>
-
-     <varlistentry id="guc-escape-string-warning" xreflabel="escape_string_warning">
-      <term><varname>escape_string_warning</varname> (<type>boolean</type>)
-      <indexterm><primary>strings</primary><secondary>escape warning</secondary></indexterm>
-      <indexterm>
-       <primary><varname>escape_string_warning</varname> configuration parameter</primary>
-      </indexterm>
-      </term>
-      <listitem>
-       <para>
-        When on, a warning is issued if a backslash (<literal>\</literal>)
-        appears in an ordinary string literal (<literal>'...'</literal>
-        syntax) and <varname>standard_conforming_strings</varname> is off.
-        The default is <literal>on</literal>.
-       </para>
-       <para>
-        Applications that wish to use backslash as escape should be
-        modified to use escape string syntax (<literal>E'...'</literal>),
-        because the default behavior of ordinary strings is now to treat
-        backslash as an ordinary character, per SQL standard.  This variable
-        can be enabled to help locate code that needs to be changed.
+        Note that in an ordinary string literal, <literal>\</literal> just
+        means <literal>\</literal> anyway.  This parameter only affects
+        the handling of escape string syntax.
        </para>
       </listitem>
      </varlistentry>
@@ -11493,15 +11469,12 @@ dynamic_library_path = '/usr/local/lib/postgresql:$libdir'
       </term>
       <listitem>
        <para>
-        This controls whether ordinary string literals
-        (<literal>'...'</literal>) treat backslashes literally, as specified in
-        the SQL standard.
-        Beginning in <productname>PostgreSQL</productname> 9.1, the default is
-        <literal>on</literal> (prior releases defaulted to <literal>off</literal>).
-        Applications can 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 (<literal>E'...'</literal>) is supported.
+        Beginning in <productname>PostgreSQL</productname> 19, this
+        parameter is always <literal>on</literal>.  String literals are
+        always parsed as specified in the SQL standard (that is,
+        backslashes are ordinary characters within a string literal).
+        This parameter continues to exist because applications may consult
+        it; but it cannot be set to <literal>off</literal>.
         Escape string syntax (<xref linkend="sql-syntax-strings-escape"/>)
         should be used if an application desires
         backslashes to be treated as escape characters.
index e6e3a82905c077126c73149791ae8156ca2248ea..6203b2518cf0cf75f18e49c012ef9d352da3b52c 100644 (file)
@@ -75,9 +75,7 @@ EXEC SQL ...;
    Embedded <acronym>SQL</acronym> statements likewise use SQL rules, not
    C rules, for parsing quoted strings and identifiers.
    (See <xref linkend="sql-syntax-strings"/> and
-   <xref linkend="sql-syntax-identifiers"/> respectively.  Note that
-   ECPG assumes that <varname>standard_conforming_strings</varname>
-   is <literal>on</literal>.)
+   <xref linkend="sql-syntax-identifiers"/> respectively.)
    Of course, the C part of the program follows C quoting rules.
   </para>
 
index f466860ddb00253789dc750e3c110f6f58b2ac70..b159137f93a38ee53ea2499adb8b059e81f9f063 100644 (file)
     character itself, write two escape characters.
    </para>
 
-   <note>
-    <para>
-     If you have <xref linkend="guc-standard-conforming-strings"/> turned off,
-     any backslashes you write in literal string constants will need to be
-     doubled.  See <xref linkend="sql-syntax-strings"/> for more information.
-    </para>
-   </note>
-
    <para>
     It's also possible to select no escape character by writing
     <literal>ESCAPE ''</literal>.  This effectively disables the
@@ -1156,14 +1148,6 @@ regexp_substr('ABCDEFGHI', '(c..)(...)', 1, 1, 'i', 2)
     An RE cannot end with a backslash (<literal>\</literal>).
    </para>
 
-   <note>
-    <para>
-     If you have <xref linkend="guc-standard-conforming-strings"/> turned off,
-     any backslashes you write in literal string constants will need to be
-     doubled.  See <xref linkend="sql-syntax-strings"/> for more information.
-    </para>
-   </note>
-
    <table id="posix-quantifiers-table">
     <title>Regular Expression Quantifiers</title>
 
index 5f8d1d1ff4303342242088ba849c4e185e5ea3db..780ee224dce1f58e36a1543107b25fcfbe573e4a 100644 (file)
@@ -73,9 +73,7 @@ key =&gt; NULL
    applies <emphasis>before</emphasis> any required quoting or escaping. If you are
    passing an <type>hstore</type> literal via a parameter, then no additional
    processing is needed. But if you're passing it as a quoted literal
-   constant, then any single-quote characters and (depending on the setting of
-   the <varname>standard_conforming_strings</varname> configuration parameter)
-   backslash characters need to be escaped correctly. See
+   constant, then any single-quote characters need to be escaped correctly. See
    <xref linkend="sql-syntax-strings"/> for more on the handling of string
    constants.
   </para>
index c2cc1326081bde79cefa33a0bd050c97bfec4229..21e1ba34a4eb52544c51cc1748bf9ad2fece9db2 100644 (file)
@@ -2889,18 +2889,13 @@ const char *PQparameterStatus(const PGconn *conn, const char *paramName);
        before 16; <varname>search_path</varname> was not reported by releases
        before 18.)
        Note that
-       <varname>server_version</varname>,
-       <varname>server_encoding</varname> and
-       <varname>integer_datetimes</varname>
+       <varname>server_version</varname> and
+       <varname>server_encoding</varname>
        cannot change after startup.
-      </para>
-
-      <para>
-       If no value for <varname>standard_conforming_strings</varname> is reported,
-       applications can assume it is <literal>off</literal>, that is, backslashes
-       are treated as escapes in string literals.  Also, the presence of
-       this parameter can be taken as an indication that the escape string
-       syntax (<literal>E'...'</literal>) is accepted.
+       Also, <varname>integer_datetimes</varname> is
+       always <literal>on</literal> in releases 9.5 and later,
+       and <varname>standard_conforming_strings</varname> is
+       always <literal>on</literal> in releases 19 and later.
       </para>
 
       <para>
@@ -11108,7 +11103,6 @@ main(int argc, char **argv)
  *
  * CREATE SCHEMA testlibpq3;
  * SET search_path = testlibpq3;
- * SET standard_conforming_strings = ON;
  * CREATE TABLE test1 (i int4, t text, b bytea);
  * INSERT INTO test1 values (1, 'joe''s place', '\000\001\002\003\004');
  * INSERT INTO test1 values (2, 'ho there', '\004\003\002\001\000');
index 41c5954a424ac679ea4ec677beac49f8133e0c3f..a2b528c481e8f3c1565c04ef271544eeef16e11b 100644 (file)
@@ -3040,8 +3040,7 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;"
           <para>
            Sets the label of the backup. If none is specified, a backup label
            of <literal>base backup</literal> will be used. The quoting rules
-           for the label are the same as a standard SQL string with
-           <xref linkend="guc-standard-conforming-strings"/> turned on.
+           for the label are the same as for a standard SQL string.
           </para>
          </listitem>
         </varlistentry>
index 34c83880a66e3322114dd5a114939db1cf3d8beb..67482996861dc114a5cfedf5cfc90887f3d04bd6 100644 (file)
@@ -438,30 +438,6 @@ SELECT 'foo'      'bar';
      will check that the character conversion is possible.
     </para>
 
-    <caution>
-    <para>
-     If the configuration parameter
-     <xref linkend="guc-standard-conforming-strings"/> is <literal>off</literal>,
-     then <productname>PostgreSQL</productname> recognizes backslash escapes
-     in both regular and escape string constants.  However, as of
-     <productname>PostgreSQL</productname> 9.1, the default is <literal>on</literal>, meaning
-     that backslash escapes are recognized only in escape string constants.
-     This behavior is more standards-compliant, but might break applications
-     which rely on the historical behavior, where backslash escapes
-     were always recognized.  As a workaround, you can set this parameter
-     to <literal>off</literal>, but it is better to migrate away from using backslash
-     escapes.  If you need to use a backslash escape to represent a special
-     character, write the string constant with an <literal>E</literal>.
-    </para>
-
-    <para>
-     In addition to <varname>standard_conforming_strings</varname>, the configuration
-     parameters <xref linkend="guc-escape-string-warning"/> and
-     <xref linkend="guc-backslash-quote"/> govern treatment of backslashes
-     in string constants.
-    </para>
-    </caution>
-
     <para>
      The character with the code zero cannot be in a string constant.
     </para>
@@ -532,17 +508,6 @@ U&amp;'d!0061t!+000061' UESCAPE '!'
      by one of these escape sequences is converted to the actual server
      encoding; an error is reported if that's not possible.
     </para>
-
-    <para>
-     Also, the Unicode escape syntax for string constants only works
-     when the configuration
-     parameter <xref linkend="guc-standard-conforming-strings"/> is
-     turned on.  This is because otherwise this syntax could confuse
-     clients that parse the SQL statements to the point that it could
-     lead to SQL injections and similar security issues.  If the
-     parameter is set to off, this syntax will be rejected with an
-     error message.
-    </para>
    </sect3>
 
    <sect3 id="sql-syntax-dollar-quoting">
index bda932d4992234ea17713875be1ddf1cc20863f7..4440aff4925cf019c7dfaf95e85cb5d6080ae240 100644 (file)
@@ -1257,3 +1257,18 @@ check_ssl(bool *newval, void **extra, GucSource source)
 #endif
        return true;
 }
+
+bool
+check_standard_conforming_strings(bool *newval, void **extra, GucSource source)
+{
+       if (!*newval)
+       {
+               /* check the GUC's definition for an explanation */
+               GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
+               GUC_check_errmsg("non-standard string literals are not supported");
+
+               return false;
+       }
+
+       return true;
+}
index 731d584106df9f7bda99fc25a759138ee6c2e212..6c162f48342ef7ea2bc5964ba6f8bd8422c5fa27 100644 (file)
@@ -60,14 +60,13 @@ fprintf_to_ereport(const char *fmt, const char *msg)
 }
 
 /*
- * GUC variables.  This is a DIRECT violation of the warning given at the
+ * 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;
- * as such, changing their values can induce very unintuitive behavior.
- * But we shall have to live with it until we can remove these variables.
+ * as such, changing its value can induce very unintuitive behavior.
+ * In practice, backslash_quote is not too awful since it only controls
+ * whether to throw an error: it cannot change non-error results.
  */
 int                    backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING;
-bool           escape_string_warning = true;
-bool           standard_conforming_strings = true;
 
 /*
  * Constant data exported from this file.  This array maps from the
@@ -127,9 +126,6 @@ static void addunicode(char32_t c, yyscan_t yyscanner);
 
 #define lexer_errposition()  scanner_errposition(*(yylloc), yyscanner)
 
-static void check_string_escape_warning(unsigned char ychar, core_yyscan_t yyscanner);
-static void check_escape_warning(core_yyscan_t yyscanner);
-
 %}
 
 %option reentrant
@@ -543,17 +539,12 @@ other                     .
                                }
 
 {xqstart}              {
-                                       yyextra->warn_on_first_escape = true;
                                        yyextra->saw_non_ascii = false;
                                        SET_YYLLOC();
-                                       if (yyextra->standard_conforming_strings)
-                                               BEGIN(xq);
-                                       else
-                                               BEGIN(xe);
+                                       BEGIN(xq);
                                        startlit();
                                }
 {xestart}              {
-                                       yyextra->warn_on_first_escape = false;
                                        yyextra->saw_non_ascii = false;
                                        SET_YYLLOC();
                                        BEGIN(xe);
@@ -561,12 +552,6 @@ other                      .
                                }
 {xusstart}             {
                                        SET_YYLLOC();
-                                       if (!yyextra->standard_conforming_strings)
-                                               ereport(ERROR,
-                                                               (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                                                                errmsg("unsafe use of string constant with Unicode escapes"),
-                                                                errdetail("String constants with Unicode escapes cannot be used when \"standard_conforming_strings\" is off."),
-                                                                lexer_errposition()));
                                        BEGIN(xus);
                                        startlit();
                                }
@@ -642,13 +627,6 @@ other                      .
 <xe>{xeunicode} {
                                        char32_t        c = strtoul(yytext + 2, NULL, 16);
 
-                                       /*
-                                        * For consistency with other productions, issue any
-                                        * escape warning with cursor pointing to start of string.
-                                        * We might want to change that, someday.
-                                        */
-                                       check_escape_warning(yyscanner);
-
                                        /* Remember start of overall string token ... */
                                        PUSH_YYLLOC();
                                        /* ... and set the error cursor to point at this esc seq */
@@ -715,14 +693,12 @@ other                     .
                                                                         errhint("Use '' to write quotes in strings. \\' is insecure in client-only encodings."),
                                                                         lexer_errposition()));
                                        }
-                                       check_string_escape_warning(yytext[1], yyscanner);
                                        addlitchar(unescape_single_char(yytext[1], yyscanner),
                                                           yyscanner);
                                }
 <xe>{xeoctesc}  {
                                        unsigned char c = strtoul(yytext + 1, NULL, 8);
 
-                                       check_escape_warning(yyscanner);
                                        addlitchar(c, yyscanner);
                                        if (c == '\0' || IS_HIGHBIT_SET(c))
                                                yyextra->saw_non_ascii = true;
@@ -730,7 +706,6 @@ other                       .
 <xe>{xehexesc}  {
                                        unsigned char c = strtoul(yytext + 2, NULL, 16);
 
-                                       check_escape_warning(yyscanner);
                                        addlitchar(c, yyscanner);
                                        if (c == '\0' || IS_HIGHBIT_SET(c))
                                                yyextra->saw_non_ascii = true;
@@ -1263,8 +1238,6 @@ scanner_init(const char *str,
        yyext->keyword_tokens = keyword_tokens;
 
        yyext->backslash_quote = backslash_quote;
-       yyext->escape_string_warning = escape_string_warning;
-       yyext->standard_conforming_strings = standard_conforming_strings;
 
        /*
         * Make a scan buffer with special termination needed by flex.
@@ -1420,45 +1393,6 @@ unescape_single_char(unsigned char c, core_yyscan_t yyscanner)
        }
 }
 
-static void
-check_string_escape_warning(unsigned char ychar, core_yyscan_t yyscanner)
-{
-       if (ychar == '\'')
-       {
-               if (yyextra->warn_on_first_escape && yyextra->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'...')."),
-                                        lexer_errposition()));
-               yyextra->warn_on_first_escape = false;  /* warn only once per string */
-       }
-       else if (ychar == '\\')
-       {
-               if (yyextra->warn_on_first_escape && yyextra->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'\\\\'."),
-                                        lexer_errposition()));
-               yyextra->warn_on_first_escape = false;  /* warn only once per string */
-       }
-       else
-               check_escape_warning(yyscanner);
-}
-
-static void
-check_escape_warning(core_yyscan_t yyscanner)
-{
-       if (yyextra->warn_on_first_escape && yyextra->escape_string_warning)
-               ereport(WARNING,
-                               (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
-                                errmsg("nonstandard use of escape in a string literal"),
-                                errhint("Use the escape string syntax for escapes, e.g., E'\\r\\n'."),
-                                lexer_errposition()));
-       yyextra->warn_on_first_escape = false;  /* warn only once per string */
-}
-
 /*
  * Interface functions to make flex use palloc() instead of malloc().
  * It'd be better to make these static, but flex insists otherwise.
index 0aebcc43e5b8b60bfa503858881906c29822a272..d2ef6a9dc0f63d5a4f78dfd23ba2a55993ed895b 100644 (file)
@@ -37,11 +37,9 @@ quote_ident(PG_FUNCTION_ARGS)
  * quote_literal_internal -
  *       helper function for quote_literal and quote_literal_cstr
  *
- * NOTE: think not to make this function's behavior change with
- * standard_conforming_strings.  We don't know where the result
- * literal will be used, and so we must generate a result that
- * will work with either setting.  Take a look at what dblink
- * uses this for before thinking you know better.
+ * NOTE: This must produce output that will work in old servers with
+ * standard_conforming_strings = off.  It's used for example by
+ * dblink, which may send the result to another server.
  */
 static size_t
 quote_literal_internal(char *dst, const char *src, size_t len)
index 033b625f3fc11db98d34c14d0a510f3ca96792fd..b5a7ad9066e7ebe013545792368984d539926227 100644 (file)
@@ -11828,16 +11828,14 @@ simple_quote_literal(StringInfo buf, const char *val)
        const char *valptr;
 
        /*
-        * We form the string literal according to the prevailing setting of
-        * standard_conforming_strings; we never use E''. User is responsible for
-        * making sure result is used correctly.
+        * We always form the string literal according to standard SQL rules.
         */
        appendStringInfoChar(buf, '\'');
        for (valptr = val; *valptr; valptr++)
        {
                char            ch = *valptr;
 
-               if (SQL_STR_DOUBLE(ch, !standard_conforming_strings))
+               if (SQL_STR_DOUBLE(ch, false))
                        appendStringInfoChar(buf, ch);
                appendStringInfoChar(buf, ch);
        }
index 7c60b12556464110e7b0657e832aa8c685004cfd..f0260e6e412cea5c188eb3e22d5a6414921a5eff 100644 (file)
   boot_val => 'true',
 },
 
-{ name => 'escape_string_warning', type => 'bool', context => 'PGC_USERSET', group => 'COMPAT_OPTIONS_PREVIOUS',
-  short_desc => 'Warn about backslash escapes in ordinary string literals.',
-  variable => 'escape_string_warning',
-  boot_val => 'true',
-},
-
 { name => 'event_source', type => 'string', context => 'PGC_POSTMASTER', group => 'LOGGING_WHERE',
   short_desc => 'Sets the application name used to identify PostgreSQL messages in the event log.',
   variable => 'event_source',
   boot_val => '""',
 },
 
+# We removed support for non-conforming string literals in PostgreSQL 19,
+# but this parameter must be kept indefinitely, since client code might
+# consult it or attempt to set it.  We allow it to be explicitly set to true.
 { name => 'standard_conforming_strings', type => 'bool', context => 'PGC_USERSET', group => 'COMPAT_OPTIONS_PREVIOUS',
-  short_desc => 'Causes \'...\' strings to treat backslashes literally.',
-  flags => 'GUC_REPORT',
+  short_desc => 'Nonstandard strings are no longer supported; this can only be true.',
+  flags => 'GUC_REPORT | GUC_NOT_IN_SAMPLE',
   variable => 'standard_conforming_strings',
   boot_val => 'true',
+  check_hook => 'check_standard_conforming_strings',
 },
 
 { name => 'statement_timeout', type => 'int', context => 'PGC_USERSET', group => 'CLIENT_CONN_STATEMENT',
index 73ff6ad0a32ee6a2b300bdb40a95406ff778b949..13c569d8790eb86b43d0575d9de821df0583e9c5 100644 (file)
@@ -529,10 +529,10 @@ bool              row_security;
 bool           check_function_bodies = true;
 
 /*
- * This GUC exists solely for backward compatibility, check its definition for
- * details.
+ * These GUCs exist solely for backward compatibility.
  */
 static bool default_with_oids = false;
+static bool standard_conforming_strings = true;
 
 bool           current_role_is_superuser;
 
index dc9e2255f8a7f8b83c397f882532dac39615edbc..c4f92fcdac88d1db09e02aeb08a486a4188d6a8c 100644 (file)
 
 #array_nulls = on
 #backslash_quote = safe_encoding        # on, off, or safe_encoding
-#escape_string_warning = on
 #lo_compat_privileges = off
 #quote_all_identifiers = off
-#standard_conforming_strings = on
 #synchronize_seqscans = on
 
 # - Other Platforms and Clients -
index 4a63f7392ae89674cb0611a5fbb68a7d42cafa24..18d3822fd824e5a6586bbc41c7b6056159a2cfb2 100644 (file)
@@ -3426,8 +3426,6 @@ _doSetFixedOutputState(ArchiveHandle *AH)
 
        /* Avoid annoying notices etc */
        ahprintf(AH, "SET client_min_messages = warning;\n");
-       if (!AH->public.std_strings)
-               ahprintf(AH, "SET escape_string_warning = off;\n");
 
        /* Adjust row-security state */
        if (ropt && ropt->enable_row_security)
index 687dc98e46db1ce19051547c26e0cc903c5fa455..fff929b26dfb58b1f19885549f1592a64a86b433 100644 (file)
@@ -1429,7 +1429,6 @@ setup_connection(Archive *AH, const char *dumpencoding,
 {
        DumpOptions *dopt = AH->dopt;
        PGconn     *conn = GetConnection(AH);
-       const char *std_strings;
 
        PQclear(ExecuteSqlQueryForSingleRow(AH, ALWAYS_SECURE_SEARCH_PATH_SQL));
 
@@ -1444,15 +1443,27 @@ setup_connection(Archive *AH, const char *dumpencoding,
        }
 
        /*
-        * Get the active encoding and the standard_conforming_strings setting, so
-        * we know how to escape strings.
+        * Force standard_conforming_strings on, just in case we are dumping from
+        * an old server that has it disabled.  Without this, literals in views,
+        * expressions, etc, would be incorrect for modern servers.
+        */
+       ExecuteSqlStatement(AH, "SET standard_conforming_strings = on");
+
+       /*
+        * And reflect that to AH->std_strings.  You might think that we should
+        * just delete that variable and the code that checks it, but that would
+        * be problematic for pg_restore, which at least for now should still cope
+        * with archives containing the other setting (cf. processStdStringsEntry
+        * in pg_backup_archiver.c).
+        */
+       AH->std_strings = true;
+
+       /*
+        * Get the active encoding, so we know how to escape strings.
         */
        AH->encoding = PQclientEncoding(conn);
        setFmtEncoding(AH->encoding);
 
-       std_strings = PQparameterStatus(conn, "standard_conforming_strings");
-       AH->std_strings = (std_strings && strcmp(std_strings, "on") == 0);
-
        /*
         * Set the role if requested.  In a parallel dump worker, we'll be passed
         * use_role == NULL, but AH->use_role is already set (if user specified it
index e85f227d1826b43380813179050c44b4b5dc05f8..30fecd0c252df2b075194f94f93a932fe0be49ca 100644 (file)
@@ -204,7 +204,6 @@ main(int argc, char *argv[])
        bool            tablespaces_only = false;
        PGconn     *conn;
        int                     encoding;
-       const char *std_strings;
        int                     c,
                                ret;
        int                     optindex;
@@ -568,14 +567,17 @@ main(int argc, char *argv[])
        }
 
        /*
-        * Get the active encoding and the standard_conforming_strings setting, so
-        * we know how to escape strings.
+        * Force standard_conforming_strings on, just in case we are dumping from
+        * an old server that has it disabled.  Without this, literals in views,
+        * expressions, etc, would be incorrect for modern servers.
+        */
+       executeCommand(conn, "SET standard_conforming_strings = on");
+
+       /*
+        * Get the active encoding, so we know how to escape strings.
         */
        encoding = PQclientEncoding(conn);
        setFmtEncoding(encoding);
-       std_strings = PQparameterStatus(conn, "standard_conforming_strings");
-       if (!std_strings)
-               std_strings = "off";
 
        /* Set the role if requested */
        if (use_role)
@@ -615,12 +617,10 @@ main(int argc, char *argv[])
        /* Restore will need to write to the target cluster */
        fprintf(OPF, "SET default_transaction_read_only = off;\n\n");
 
-       /* Replicate encoding and std_strings in output */
+       /* Replicate encoding and standard_conforming_strings in output */
        fprintf(OPF, "SET client_encoding = '%s';\n",
                        pg_encoding_to_char(encoding));
-       fprintf(OPF, "SET standard_conforming_strings = %s;\n", std_strings);
-       if (strcmp(std_strings, "off") == 0)
-               fprintf(OPF, "SET escape_string_warning = off;\n");
+       fprintf(OPF, "SET standard_conforming_strings = on;\n");
        fprintf(OPF, "\n");
 
        if (!data_only && !statistics_only && !no_schema)
index d87f1d476f3ba3603d4149c4ab2248d786cc1d97..89ce396ed4f3e0382814c1f568a1798c2fecaec7 100644 (file)
@@ -449,9 +449,9 @@ appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
 
        /*
         * XXX This is a kluge to silence escape_string_warning in our utility
-        * programs.  It should go away someday.
+        * programs.  It can go away once pre-v19 servers are out of support.
         */
-       if (strchr(str, '\\') != NULL && PQserverVersion(conn) >= 80100)
+       if (strchr(str, '\\') != NULL && PQserverVersion(conn) < 190000)
        {
                /* ensure we are not adjacent to an identifier */
                if (buf->len > 0 && buf->data[buf->len - 1] != ' ')
index 70af67086c33d56cec85aa32a9d1e0f48da1ee4d..93bd7c439f864429ec37e67d3877240c5e3d952b 100644 (file)
@@ -52,10 +52,8 @@ typedef enum
        BACKSLASH_QUOTE_SAFE_ENCODING,
 }                      BackslashQuoteType;
 
-/* GUC variables in scan.l (every one of these is a bad idea :-() */
+/* GUC variable in scan.l */
 extern PGDLLIMPORT int backslash_quote;
-extern PGDLLIMPORT bool escape_string_warning;
-extern PGDLLIMPORT bool standard_conforming_strings;
 
 
 /* Primary entry point for the raw parsing functions */
index 2d5904a621450c296c2d72a059af7a9d0aad5c39..8c2de6556883c01f2bce9c0aebd89618735d0af2 100644 (file)
@@ -85,8 +85,6 @@ typedef struct core_yy_extra_type
         * prevailing GUC settings.
         */
        int                     backslash_quote;
-       bool            escape_string_warning;
-       bool            standard_conforming_strings;
 
        /*
         * literalbuf is used to accumulate literal values when multiple rules are
@@ -110,8 +108,7 @@ typedef struct core_yy_extra_type
        /* first part of UTF16 surrogate pair for Unicode escapes */
        int32           utf16_first_part;
 
-       /* state variables for literal-lexing warnings */
-       bool            warn_on_first_escape;
+       /* true if we need to verify valid encoding of current literal string */
        bool            saw_non_ascii;
 } core_yy_extra_type;
 
index f723668da9ec2562d302adf592599d1d98f14276..b6ecb0e769f91299a5feed5e4415e0f55fd5e141 100644 (file)
@@ -134,6 +134,8 @@ extern void assign_session_replication_role(int newval, void *extra);
 extern void assign_stats_fetch_consistency(int newval, void *extra);
 extern bool check_ssl(bool *newval, void **extra, GucSource source);
 extern bool check_stage_log_stats(bool *newval, void **extra, GucSource source);
+extern bool check_standard_conforming_strings(bool *newval, void **extra,
+                                                                                         GucSource source);
 extern bool check_subtrans_buffers(int *newval, void **extra,
                                                                   GucSource source);
 extern bool check_synchronous_standby_names(char **newval, void **extra,
index 05841bd6999d53afe1851632f1f7027ea6736e9b..ddc1e90b1c3fb325a097f776c75c46627130ec60 100644 (file)
@@ -61,7 +61,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 #line 20 "quote.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);
 #line 22 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -84,8 +84,8 @@ if (sqlca.sqlcode < 0) exit (1);}
 
   printf("Standard conforming strings: %s\n", var);
 
-  /* this is a\\b actually */
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
+  /* this is a\\\\b actually */
+  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
 #line 28 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -95,7 +95,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 #line 28 "quote.pgc"
 
   /* this is a\\b */
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
 #line 30 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -105,7 +105,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 #line 30 "quote.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGtrans(__LINE__, NULL, "begin");
 #line 32 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -114,66 +114,22 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
 if (sqlca.sqlcode < 0) exit (1);}
 #line 32 "quote.pgc"
 
-
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT, 
-       ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
-       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 34 "quote.pgc"
-
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
-#line 34 "quote.pgc"
-
-if (sqlca.sqlcode < 0) exit (1);}
-#line 34 "quote.pgc"
-
-  printf("Standard conforming strings: %s\n", var);
-
-  /* this is a\\\\b actually */
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
-#line 38 "quote.pgc"
-
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
-#line 38 "quote.pgc"
-
-if (sqlca.sqlcode < 0) exit (1);}
-#line 38 "quote.pgc"
-
-  /* this is a\\b */
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
-#line 40 "quote.pgc"
-
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
-#line 40 "quote.pgc"
-
-if (sqlca.sqlcode < 0) exit (1);}
-#line 40 "quote.pgc"
-
-
-  { ECPGtrans(__LINE__, NULL, "begin");
-#line 42 "quote.pgc"
-
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
-#line 42 "quote.pgc"
-
-if (sqlca.sqlcode < 0) exit (1);}
-#line 42 "quote.pgc"
-
   /* declare C cursor for select * from \"My_Table\" */
-#line 43 "quote.pgc"
+#line 33 "quote.pgc"
 
 
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
-#line 45 "quote.pgc"
+#line 35 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
-#line 45 "quote.pgc"
+#line 35 "quote.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
-#line 45 "quote.pgc"
+#line 35 "quote.pgc"
 
 
   /* exec sql whenever not found  break ; */
-#line 47 "quote.pgc"
+#line 37 "quote.pgc"
 
 
   for (loopcount = 0; loopcount < 100; loopcount++)
@@ -183,47 +139,47 @@ if (sqlca.sqlcode < 0) exit (1);}
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
        ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 51 "quote.pgc"
+#line 41 "quote.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
-#line 51 "quote.pgc"
+#line 41 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
-#line 51 "quote.pgc"
+#line 41 "quote.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
-#line 51 "quote.pgc"
+#line 41 "quote.pgc"
 
        printf("value: %d %s\n", i, var);
   }
 
   { ECPGtrans(__LINE__, NULL, "rollback");
-#line 55 "quote.pgc"
+#line 45 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
-#line 55 "quote.pgc"
+#line 45 "quote.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
-#line 55 "quote.pgc"
+#line 45 "quote.pgc"
 
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
-#line 56 "quote.pgc"
+#line 46 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
-#line 56 "quote.pgc"
+#line 46 "quote.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
-#line 56 "quote.pgc"
+#line 46 "quote.pgc"
 
 
   { ECPGdisconnect(__LINE__, "ALL");
-#line 58 "quote.pgc"
+#line 48 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
-#line 58 "quote.pgc"
+#line 48 "quote.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
-#line 58 "quote.pgc"
+#line 48 "quote.pgc"
 
 
   return 0;
index 3df8702a8a6b7411f7e04ca5243c057cd1a3760b..5f5bfb8133a2a480af9305f2a4462a2d4aa7c96b 100644 (file)
@@ -10,7 +10,7 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 20: OK: CREATE TABLE
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 22: query: set standard_conforming_strings to off; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 22: query: set standard_conforming_strings to on; with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 22: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 24: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 24: RESULT: off offset: -1; array: no
+[NO_PID]: ecpg_get_data on line 24: RESULT: on offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 28: query: insert into "My_Table" values ( 1 , 'a\\\\b' ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 28: query: insert into "My_Table" values ( 2 , 'a\\\\b' ); with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGnoticeReceiver: nonstandard use of \\ in a string literal
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode 0
-[NO_PID]: sqlca: code: 0, state: 22P06
 [NO_PID]: ecpg_execute on line 28: using PQexec
-[NO_PID]: sqlca: code: 0, state: 22P06
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 28: OK: INSERT 0 1
-[NO_PID]: sqlca: code: 0, state: 22P06
-SQL error: nonstandard use of \\ in a string literal
-[NO_PID]: ecpg_execute on line 30: query: insert into "My_Table" values ( 1 , E'a\\\\b' ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 30: query: insert into "My_Table" values ( 2 , E'a\\\\b' ); with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 30: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 30: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 32: query: set standard_conforming_strings to on; with 0 parameter(s) on connection ecpg1_regression
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 32: using PQexec
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 32: OK: SET
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 34: query: show standard_conforming_strings; with 0 parameter(s) on connection ecpg1_regression
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 34: using PQexec
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 34: correctly got 1 tuples with 1 fields
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 34: RESULT: on offset: -1; array: no
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 38: query: insert into "My_Table" values ( 2 , 'a\\\\b' ); with 0 parameter(s) on connection ecpg1_regression
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 38: using PQexec
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 38: OK: INSERT 0 1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 40: query: insert into "My_Table" values ( 2 , E'a\\\\b' ); with 0 parameter(s) on connection ecpg1_regression
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 40: using PQexec
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 40: OK: INSERT 0 1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans on line 42: action "begin"; connection "ecpg1_regression"
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 45: query: declare C cursor for select * from "My_Table"; with 0 parameter(s) on connection ecpg1_regression
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 45: using PQexec
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 45: OK: DECLARE CURSOR
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection ecpg1_regression
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: using PQexec
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 51: correctly got 1 tuples with 2 fields
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 51: RESULT: 1 offset: -1; array: no
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 51: RESULT: a\\b offset: -1; array: no
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection ecpg1_regression
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: using PQexec
+[NO_PID]: ECPGtrans on line 32: action "begin"; connection "ecpg1_regression"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 51: correctly got 1 tuples with 2 fields
+[NO_PID]: ecpg_execute on line 35: query: declare C cursor for select * from "My_Table"; with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 51: RESULT: 1 offset: -1; array: no
+[NO_PID]: ecpg_execute on line 35: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 51: RESULT: a\\b offset: -1; array: no
+[NO_PID]: ecpg_process_output on line 35: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 41: query: fetch C; with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: using PQexec
+[NO_PID]: ecpg_execute on line 41: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 51: correctly got 1 tuples with 2 fields
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 51: RESULT: 2 offset: -1; array: no
+[NO_PID]: ecpg_get_data on line 41: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 51: RESULT: a\\\\b offset: -1; array: no
+[NO_PID]: ecpg_get_data on line 41: RESULT: a\\\\b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 41: query: fetch C; with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: using PQexec
+[NO_PID]: ecpg_execute on line 41: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 51: correctly got 1 tuples with 2 fields
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 51: RESULT: 2 offset: -1; array: no
+[NO_PID]: ecpg_get_data on line 41: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 51: RESULT: a\\b offset: -1; array: no
+[NO_PID]: ecpg_get_data on line 41: RESULT: a\\b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 41: query: fetch C; with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: using PQexec
+[NO_PID]: ecpg_execute on line 41: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 51: correctly got 0 tuples with 2 fields
+[NO_PID]: ecpg_process_output on line 41: correctly got 0 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode 100 on line 51: no data found on line 51
+[NO_PID]: raising sqlcode 100 on line 41: no data found on line 41
 [NO_PID]: sqlca: code: 100, state: 02000
-[NO_PID]: ECPGtrans on line 55: action "rollback"; connection "ecpg1_regression"
+[NO_PID]: ECPGtrans on line 45: action "rollback"; connection "ecpg1_regression"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 56: query: drop table "My_Table"; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 46: query: drop table "My_Table"; with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: ecpg_execute on line 46: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 56: OK: DROP TABLE
+[NO_PID]: ecpg_process_output on line 46: OK: DROP TABLE
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection ecpg1_regression closed
 [NO_PID]: sqlca: code: 0, state: 00000
index 2f92f994831de5349662528487122ce623843c45..31892d5261e1989e5b97123da3318b0ebae22716 100644 (file)
@@ -1,6 +1,3 @@
-Standard conforming strings: off
 Standard conforming strings: on
-value: 1 a\\b
-value: 1 a\\b
 value: 2 a\\\\b
 value: 2 a\\b
index 1b52d5eaf4e57fdbf6036dd44cbcd9c8aa775f6d..f934dc99feb4dfe1dece3af72aa486b26162c63d 100644 (file)
@@ -90,7 +90,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
   printf("Var: Search path: %s\n", var);
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);
 #line 26 "show.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
index c303a845b25d6181b8c847f9daa3f315c7be341f..e906abad91ea0f03c1f7438e255b945023c46d45 100644 (file)
@@ -30,7 +30,7 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 23: RESULT: public offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 26: query: set standard_conforming_strings to off; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 26: query: set standard_conforming_strings to on; with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 26: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
@@ -42,7 +42,7 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 27: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 27: RESULT: off offset: -1; array: no
+[NO_PID]: ecpg_get_data on line 27: RESULT: on offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 30: query: set time zone PST8PDT; with 0 parameter(s) on connection ecpg1_regression
 [NO_PID]: sqlca: code: 0, state: 00000
index 9319c5d113580faa750ecdb35c0c1aaa5c17d8a6..d5628025a0e4ea3b68675ee82ac21b913da6507e 100644 (file)
@@ -1,5 +1,5 @@
 Var: Search path: public
 Var: Search path: public
-Var: Standard conforming strings: off
+Var: Standard conforming strings: on
 Time Zone: PST8PDT
 Transaction isolation level: read committed
index 9b62b7da90d995f0c9bc35b5048f897dc44c2cd5..5cf4833d05321f7ed044cb24e1725ac8fa98f057 100644 (file)
@@ -19,16 +19,6 @@ int main() {
 
   EXEC SQL CREATE TABLE "My_Table" ( Item1 int, Item2 text );
 
-  EXEC SQL SET standard_conforming_strings TO off;
-
-  EXEC SQL SHOW standard_conforming_strings INTO :var;
-  printf("Standard conforming strings: %s\n", var);
-
-  /* this is a\\b actually */
-  EXEC SQL INSERT INTO "My_Table" VALUES ( 1, 'a\\\\b' );
-  /* this is a\\b */
-  EXEC SQL INSERT INTO "My_Table" VALUES ( 1, E'a\\\\b' );
-
   EXEC SQL SET standard_conforming_strings TO on;
 
   EXEC SQL SHOW standard_conforming_strings INTO :var;
index 339678ae994ca0f915fd940b53e4c90f56c813ab..232b3e7734811fd262e6c4c731b072049bbe263b 100644 (file)
@@ -23,7 +23,7 @@ int main() {
   EXEC SQL SHOW search_path INTO :var;
   printf("Var: Search path: %s\n", var);
 
-  EXEC SQL SET standard_conforming_strings TO off;
+  EXEC SQL SET standard_conforming_strings TO on;
   EXEC SQL SHOW standard_conforming_strings INTO :var;
   printf("Var: Standard conforming strings: %s\n", var);
 
index 4f7b79138897563a160e14fd0d72cf89e7a6e6ca..cf74865ccb96e6c52cc2b8fb93403f781d465338 100644 (file)
@@ -10,7 +10,6 @@
  *
  * CREATE SCHEMA testlibpq3;
  * SET search_path = testlibpq3;
- * SET standard_conforming_strings = ON;
  * CREATE TABLE test1 (i int4, t text, b bytea);
  * INSERT INTO test1 values (1, 'joe''s place', '\000\001\002\003\004');
  * INSERT INTO test1 values (2, 'ho there', '\004\003\002\001\000');
index 35a95ca347b5271a43b3fe6f9d6ab8542c77a7f2..a113849b14bd87713526b9084de08be6478d63d8 100644 (file)
@@ -1,6 +1,5 @@
 CREATE SCHEMA testlibpq3;
 SET search_path = testlibpq3;
-SET standard_conforming_strings = ON;
 CREATE TABLE test1 (i int4, t text, b bytea);
 INSERT INTO test1 values (1, 'joe''s place', '\000\001\002\003\004');
 INSERT INTO test1 values (2, 'ho there', '\004\003\002\001\000');
index c44c717edf4cf7d220446f7f8510ac2426455da3..a3d35fc142cfce0aaf0a7ffea5b1cbbf5307264d 100644 (file)
@@ -5,7 +5,6 @@
 -- Most commented lines below are copied from reg.test.  Each
 -- test case is followed by an equivalent test using test_regex().
 create extension test_regex;
-set standard_conforming_strings = on;
 -- # support functions and preliminary misc.
 -- # This is sensitive to changes in message wording, but we really have to
 -- # test the code->message expansion at least once.
index befd75e96f3e280cb0f33212935960f942326134..329780ef4001bd6581a95cb520c687ac35034ec5 100644 (file)
@@ -8,7 +8,6 @@ SELECT getdatabaseencoding() <> 'UTF8'
 \quit
 \endif
 set client_encoding = utf8;
-set standard_conforming_strings = on;
 -- Run the Tcl test cases that require Unicode
 -- expectMatch 9.44 EMP*       {a[\u00fe-\u0507][\u00ff-\u0300]b} \
 --     "a\u0102\u02ffb"        "a\u0102\u02ffb"
index b2a847577e80591b31caf14e76dc729078029b45..8f80ce0fe1d29f640d1f221bc61c314ebde88b81 100644 (file)
@@ -7,8 +7,6 @@
 
 create extension test_regex;
 
-set standard_conforming_strings = on;
-
 -- # support functions and preliminary misc.
 -- # This is sensitive to changes in message wording, but we really have to
 -- # test the code->message expansion at least once.
index 2aa3e0f1022d39d5745e0a339e022216c9e5ace5..1f69f105fd775bdd33caa085f0d85519f3231451 100644 (file)
@@ -11,8 +11,6 @@ SELECT getdatabaseencoding() <> 'UTF8'
 
 set client_encoding = utf8;
 
-set standard_conforming_strings = on;
-
 
 -- Run the Tcl test cases that require Unicode
 
index 474be478ce8e3ff7c373cf4f21f3e2be6733ce12..b37b2abaf8057bdd23b9bc46c94488176a0af444 100644 (file)
@@ -4576,51 +4576,6 @@ CONTEXT:  PL/pgSQL expression "1/0"
 PL/pgSQL function fail() line 3 at RETURN
 drop function fail();
 -- Test handling of string literals.
-set standard_conforming_strings = off;
-create or replace function strtest() returns text as $$
-begin
-  raise notice 'foo\\bar\041baz';
-  return 'foo\\bar\041baz';
-end
-$$ language plpgsql;
-WARNING:  nonstandard use of \\ in a string literal
-LINE 3:   raise notice 'foo\\bar\041baz';
-                       ^
-HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
-WARNING:  nonstandard use of \\ in a string literal
-LINE 4:   return 'foo\\bar\041baz';
-                 ^
-HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
-WARNING:  nonstandard use of \\ in a string literal
-LINE 4:   return 'foo\\bar\041baz';
-                 ^
-HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
-select strtest();
-NOTICE:  foo\bar!baz
-WARNING:  nonstandard use of \\ in a string literal
-LINE 1: 'foo\\bar\041baz'
-        ^
-HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
-QUERY:  'foo\\bar\041baz'
-   strtest   
--------------
- foo\bar!baz
-(1 row)
-
-create or replace function strtest() returns text as $$
-begin
-  raise notice E'foo\\bar\041baz';
-  return E'foo\\bar\041baz';
-end
-$$ language plpgsql;
-select strtest();
-NOTICE:  foo\bar!baz
-   strtest   
--------------
- foo\bar!baz
-(1 row)
-
-set standard_conforming_strings = on;
 create or replace function strtest() returns text as $$
 begin
   raise notice 'foo\\bar\041baz\';
index ae0de7307db738c5446e24fc7106b523aec78bf3..9fd503ffe78df7a3f76f99b31a5cdb7f83829534 100644 (file)
@@ -1,8 +1,6 @@
 --
 -- Regular expression tests
 --
--- Don't want to have to double backslashes in regexes
-set standard_conforming_strings = on;
 -- Test simple quantified backrefs
 select 'bbbbb' ~ '^([bc])\1*$' as t;
  t 
index 727304f60e740ac0cffca57099016163f89b262b..5f2b5c39173997ba3980d91afbbdb0037c6d3202 100644 (file)
@@ -22,7 +22,6 @@ ERROR:  syntax error at or near "' - third line'"
 LINE 3: ' - third line'
         ^
 -- Unicode escapes
-SET standard_conforming_strings TO on;
 SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061";
  data 
 ------
@@ -142,43 +141,12 @@ SELECT E'wrong: \U002FFFFF';
 ERROR:  invalid Unicode escape value at or near "\U002FFFFF"
 LINE 1: SELECT E'wrong: \U002FFFFF';
                         ^
+-- this is no longer allowed:
 SET standard_conforming_strings TO off;
-SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061";
-ERROR:  unsafe use of string constant with Unicode escapes
-LINE 1: SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061";
-               ^
-DETAIL:  String constants with Unicode escapes cannot be used when "standard_conforming_strings" is off.
-SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061" UESCAPE '*';
-ERROR:  unsafe use of string constant with Unicode escapes
-LINE 1: SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061...
-               ^
-DETAIL:  String constants with Unicode escapes cannot be used when "standard_conforming_strings" is off.
-SELECT U&' \' UESCAPE '!' AS "tricky";
-ERROR:  unsafe use of string constant with Unicode escapes
-LINE 1: SELECT U&' \' UESCAPE '!' AS "tricky";
-               ^
-DETAIL:  String constants with Unicode escapes cannot be used when "standard_conforming_strings" is off.
-SELECT 'tricky' AS U&"\" UESCAPE '!';
-   \    
---------
- tricky
-(1 row)
-
-SELECT U&'wrong: \061';
-ERROR:  unsafe use of string constant with Unicode escapes
-LINE 1: SELECT U&'wrong: \061';
-               ^
-DETAIL:  String constants with Unicode escapes cannot be used when "standard_conforming_strings" is off.
-SELECT U&'wrong: \+0061';
-ERROR:  unsafe use of string constant with Unicode escapes
-LINE 1: SELECT U&'wrong: \+0061';
-               ^
-DETAIL:  String constants with Unicode escapes cannot be used when "standard_conforming_strings" is off.
-SELECT U&'wrong: +0061' UESCAPE '+';
-ERROR:  unsafe use of string constant with Unicode escapes
-LINE 1: SELECT U&'wrong: +0061' UESCAPE '+';
-               ^
-DETAIL:  String constants with Unicode escapes cannot be used when "standard_conforming_strings" is off.
+ERROR:  non-standard string literals are not supported
+-- but this should be acceptable:
+SET standard_conforming_strings TO on;
+-- or this:
 RESET standard_conforming_strings;
 -- bytea
 SET bytea_output TO hex;
@@ -2869,90 +2837,6 @@ SELECT '\x8000000000000000'::bytea::int8 AS "-9223372036854775808",
  -9223372036854775808 | 9223372036854775807
 (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;
-  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
-LINE 1: select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3,...
-               ^
-HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
-WARNING:  nonstandard use of \\ in a string literal
-LINE 1: select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3,...
-                               ^
-HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
-WARNING:  nonstandard use of \\ in a string literal
-LINE 1: select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3,...
-                                                 ^
-HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
-WARNING:  nonstandard use of \\ in a string literal
-LINE 1: ...bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\'  ...
-                                                             ^
-HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
-WARNING:  nonstandard use of \\ in a string literal
-LINE 1: ...'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\'   as f4, 'ab\\\'cd'...
-                                                             ^
-HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
-WARNING:  nonstandard use of \\ in a string literal
-LINE 1: ...'''cd' as f3, 'abcd\\'   as f4, 'ab\\\'cd' as f5, '\\\\' as ...
-                                                             ^
-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)
-
-reset standard_conforming_strings;
 --
 -- Additional string functions
 --
index d413d995d17e0a44867fcc11a060535da7e5335b..ae6b67e3e2271c48b3ba8b44ef203aeeda3ec423 100644 (file)
@@ -3773,28 +3773,6 @@ drop function fail();
 
 -- Test handling of string literals.
 
-set standard_conforming_strings = off;
-
-create or replace function strtest() returns text as $$
-begin
-  raise notice 'foo\\bar\041baz';
-  return 'foo\\bar\041baz';
-end
-$$ language plpgsql;
-
-select strtest();
-
-create or replace function strtest() returns text as $$
-begin
-  raise notice E'foo\\bar\041baz';
-  return E'foo\\bar\041baz';
-end
-$$ language plpgsql;
-
-select strtest();
-
-set standard_conforming_strings = on;
-
 create or replace function strtest() returns text as $$
 begin
   raise notice 'foo\\bar\041baz\';
index 56217104ce63971cb4950683d7c10500345b4edd..a4f99c1f25f9db1169937ffa2b5c8aa5424dbc0c 100644 (file)
@@ -2,9 +2,6 @@
 -- Regular expression tests
 --
 
--- Don't want to have to double backslashes in regexes
-set standard_conforming_strings = on;
-
 -- Test simple quantified backrefs
 select 'bbbbb' ~ '^([bc])\1*$' as t;
 select 'ccc' ~ '^([bc])\1*$' as t;
index 88aa4c2983ba9459634cc361dc95e1fc977727b2..37c0893ae83868b1a23d6cde6dc89fe47e748081 100644 (file)
@@ -17,8 +17,6 @@ SELECT 'first line'
        AS "Illegal comment within continuation";
 
 -- Unicode escapes
-SET standard_conforming_strings TO on;
-
 SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061";
 SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061" UESCAPE '*';
 SELECT U&'a\\b' AS "a\b";
@@ -50,18 +48,11 @@ SELECT E'wrong: \udb99\u0061';
 SELECT E'wrong: \U0000db99\U00000061';
 SELECT E'wrong: \U002FFFFF';
 
+-- this is no longer allowed:
 SET standard_conforming_strings TO off;
-
-SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061";
-SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061" UESCAPE '*';
-
-SELECT U&' \' UESCAPE '!' AS "tricky";
-SELECT 'tricky' AS U&"\" UESCAPE '!';
-
-SELECT U&'wrong: \061';
-SELECT U&'wrong: \+0061';
-SELECT U&'wrong: +0061' UESCAPE '+';
-
+-- but this should be acceptable:
+SET standard_conforming_strings TO on;
+-- or this:
 RESET standard_conforming_strings;
 
 -- bytea
@@ -914,39 +905,6 @@ SELECT '\x80000000'::bytea::int4 AS "-2147483648", '\x7FFFFFFF'::bytea::int4 AS
 SELECT '\x8000000000000000'::bytea::int8 AS "-9223372036854775808",
        '\x7FFFFFFFFFFFFFFF'::bytea::int8 AS "9223372036854775807";
 
---
--- 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;
-
-reset standard_conforming_strings;
-
-
 --
 -- Additional string functions
 --
index eb765c473643d27e2b9cff23a405a691b42b5061..e410228e117d50642172c13e56e460f275206cd1 100644 (file)
 --
 SET search_path TO pg_catalog;
 
--- The LIKE pattern language requires underscores to be escaped, so make
--- sure the backslashes are not misinterpreted.
-SET standard_conforming_strings TO on;
-
 --
 -- lists the names of all database owners and the name of their database(s)
 --
@@ -169,7 +165,6 @@ SELECT am.amname, n.nspname, opf.opfname, opr.oprname
   ORDER BY nspname, amname, opfname, oprname;
 
 --
--- Reset the search path and standard_conforming_strings to their defaults
+-- Reset the search path to default
 --
 RESET search_path;
-RESET standard_conforming_strings;