Change the default value of standard_conforming_strings to on.

This change should be publicized to driver maintainers at once and
release-noted as an incompatibility with previous releases.
This commit is contained in:
Robert Haas 2010-07-20 00:34:44 +00:00
parent 0b4a0868f9
commit 0839f312e9
5 changed files with 18 additions and 22 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.296 2010/07/16 22:25:47 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.297 2010/07/20 00:34:44 rhaas Exp $ -->
<chapter Id="runtime-config"> <chapter Id="runtime-config">
<title>Server Configuration</title> <title>Server Configuration</title>
@ -5237,11 +5237,8 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
This controls whether ordinary string literals This controls whether ordinary string literals
(<literal>'...'</>) treat backslashes literally, as specified in (<literal>'...'</>) treat backslashes literally, as specified in
the SQL standard. the SQL standard.
The default is currently <literal>off</>, causing Beginning in <productname>PostgreSQL</productname> 9.1, the default is
<productname>PostgreSQL</productname> to have its historical <literal>on</> (prior releases defaulted to <literal>off</>).
behavior of treating backslashes as escape characters.
The default will change to <literal>on</> in a future release
to improve compatibility with the SQL standard.
Applications can check this Applications can check this
parameter to determine how string literals will be processed. parameter to determine how string literals will be processed.
The presence of this parameter can also be taken as an indication The presence of this parameter can also be taken as an indication

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.147 2010/07/03 02:57:46 rhaas Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.148 2010/07/20 00:34:44 rhaas Exp $ -->
<chapter id="sql-syntax"> <chapter id="sql-syntax">
<title>SQL Syntax</title> <title>SQL Syntax</title>
@ -445,16 +445,15 @@ SELECT 'foo' 'bar';
If the configuration parameter If the configuration parameter
<xref linkend="guc-standard-conforming-strings"> is <literal>off</>, <xref linkend="guc-standard-conforming-strings"> is <literal>off</>,
then <productname>PostgreSQL</productname> recognizes backslash escapes then <productname>PostgreSQL</productname> recognizes backslash escapes
in both regular and escape string constants. This is for backward in both regular and escape string constants. However, as of
compatibility with the historical behavior, where backslash escapes <productname>PostgreSQL</> 9.1, the default is <literal>on</>, meaning
were always recognized. that backslash escapes are recognized only in escape string constants.
Although <varname>standard_conforming_strings</> currently defaults to This behavior is more standards-compliant, but might break applications
<literal>off</>, the default will change to <literal>on</> in a future which rely on the historical behavior, where backslash escapes
release for improved standards compliance. Applications are therefore were always recognized. As a workaround, you can set this parameter
encouraged to migrate away from using backslash escapes. If you need to <literal>off</>, but it is better to migrate away from using backslash
to use a backslash escape to represent a special character, write the escapes. If you need to use a backslash escape to represent a special
string constant with an <literal>E</> to be sure it will be handled the same character, write the string constant with an <literal>E</>.
way in future releases.
</para> </para>
<para> <para>

View File

@ -24,7 +24,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.167 2010/05/30 18:10:41 tgl Exp $ * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.168 2010/07/20 00:34:44 rhaas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -52,7 +52,7 @@
*/ */
int backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING; int backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING;
bool escape_string_warning = true; bool escape_string_warning = true;
bool standard_conforming_strings = false; bool standard_conforming_strings = true;
/* /*
* Set the type of YYSTYPE. * Set the type of YYSTYPE.

View File

@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.562 2010/07/16 22:25:50 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.563 2010/07/20 00:34:44 rhaas Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
@ -1211,7 +1211,7 @@ static struct config_bool ConfigureNamesBool[] =
GUC_REPORT GUC_REPORT
}, },
&standard_conforming_strings, &standard_conforming_strings,
false, NULL, NULL true, NULL, NULL
}, },
{ {

View File

@ -511,7 +511,7 @@
#escape_string_warning = on #escape_string_warning = on
#lo_compat_privileges = off #lo_compat_privileges = off
#sql_inheritance = on #sql_inheritance = on
#standard_conforming_strings = off #standard_conforming_strings = on
#synchronize_seqscans = on #synchronize_seqscans = on
# - Other Platforms and Clients - # - Other Platforms and Clients -