pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Changed behaviour of \'
8+ messages / 5 participants
[nested] [flat]

* Changed behaviour of \'
@ 2011-05-10 16:20  Martin Pitt <mpitt@debian.org>
  0 siblings, 1 reply; 8+ messages in thread

From: Martin Pitt @ 2011-05-10 16:20 UTC (permalink / raw)
  To: pgsql-bugs

Hello again,

sorry for spamming you today, but I promise that this is the last
mail; it's the one remaining test case failure for me.

I have some test cases to verify the handling of the obsolete \'
escaping in different locales (cf. CVE-2006-2313).

Up to 9.0, \' was still allowed in safe locales, but not in unsafe ones (sorry
for German error messages, but they just complain about unsafe usage of \'):

----------------------- 8< ----------------
$ printf "set client_encoding='SJIS'; select '\\\\'a'" | psql -Atq template1
FEHLER:  unsichere Verwendung von \' in Zeichenkettenkonstante
LINE 1: select '\'a'
               ^
HINT:  Verwenden Sie '', um Quotes in Zeichenketten zu schreiben. \' ist in bestimmten Client-seitigen Kodierungen unsicher.

$ printf "set client_encoding='UTF8'; select '\\\\'a'" | psql -Atq template1
WARNUNG:  nicht standardkonforme Verwendung von \' in Zeichenkettenkonstante
LINE 1: select '\'a'
               ^
HINT:  Verwenden Sie '', um Quotes in Zeichenketten zu schreiben, oder verwenden Sie die Syntax für Escape-Zeichenketten (E'...').
'a
----------------------- 8< ----------------

(Note the last line here, where it outputs 'a).

9.1 still rejects \' in SJIS, but it now also rejects \' in
UTF-8:

----------------------- 8< ----------------
$ printf "set client_encoding='SJIS'; select '\\\\'a'" | psql -Atq template1
ERROR:  unterminated quoted string at or near "'"
LINE 1: select '\'a'

$ printf "set client_encoding='UTF8'; select '\\\\'a'" | psql -Atq template1
ERROR:  unterminated quoted string at or near "'"
LINE 1: select '\'a'
----------------------- 8< ----------------

Since HISTORY does not mention this, is that an explicit decision to
finally deprecate the old \' syntax (which would be great, as it makes
this thing a lot more robust and deterministic, but it might be worth
mentioning it in HISTORY), or an unintended side effect?

Thanks,

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

Attachments:

  signature.asc (application/pgp-signature, 835B) download

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Changed behaviour of \'
@ 2011-05-10 16:37  hubert depesz lubaczewski <depesz@depesz.com>
  parent: Martin Pitt <mpitt@debian.org>
  0 siblings, 2 replies; 8+ messages in thread

From: hubert depesz lubaczewski @ 2011-05-10 16:37 UTC (permalink / raw)
  To: pgsql-bugs

On Tue, May 10, 2011 at 06:20:23PM +0200, Martin Pitt wrote:
> Since HISTORY does not mention this, is that an explicit decision to
> finally deprecate the old \' syntax (which would be great, as it makes
> this thing a lot more robust and deterministic, but it might be worth
> mentioning it in HISTORY), or an unintended side effect?

release notes clearly mentions is:
http://developer.postgresql.org/pgdocs/postgres/release-9-1.html
>> - Change the default value of standard_conforming_strings to on (Robert Haas)
>> This removes a long-standing incompatibility with the SQL standard;
>> escape_string_warning has produced warnings about this usage for years. E''
>> strings are the proper way to embed escapes in strings and are unaffected by
>> this change. 

Best regards,

depesz

-- 
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Changed behaviour of \'
@ 2011-05-10 16:44  Tom Lane <tgl@sss.pgh.pa.us>
  parent: hubert depesz lubaczewski <depesz@depesz.com>
  1 sibling, 1 reply; 8+ messages in thread

From: Tom Lane @ 2011-05-10 16:44 UTC (permalink / raw)
  To: depesz@depesz.com; +Cc: Martin Pitt <mpitt@debian.org>; pgsql-bugs

hubert depesz lubaczewski <depesz@depesz.com> writes:
> On Tue, May 10, 2011 at 06:20:23PM +0200, Martin Pitt wrote:
>> Since HISTORY does not mention this, is that an explicit decision to
>> finally deprecate the old \' syntax (which would be great, as it makes
>> this thing a lot more robust and deterministic, but it might be worth
>> mentioning it in HISTORY), or an unintended side effect?

> release notes clearly mentions is:
> http://developer.postgresql.org/pgdocs/postgres/release-9-1.html
> - Change the default value of standard_conforming_strings to on (Robert Haas)
> This removes a long-standing incompatibility with the SQL standard;
> escape_string_warning has produced warnings about this usage for years. E''
> strings are the proper way to embed escapes in strings and are unaffected by
> this change. 

Hmm ... considering that's the first thing in the release notes, I'm
surprised Martin missed it.  Maybe he was looking for something
mentioning backslashes ... should we add a bit that specifically says
that backslashes are now no-ops by default?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Changed behaviour of \'
@ 2011-05-10 21:11  Martin Pitt <mpitt@debian.org>
  parent: hubert depesz lubaczewski <depesz@depesz.com>
  1 sibling, 0 replies; 8+ messages in thread

From: Martin Pitt @ 2011-05-10 21:11 UTC (permalink / raw)
  To: pgsql-bugs

hubert depesz lubaczewski [2011-05-10 18:37 +0200]:
> release notes clearly mentions is:
> http://developer.postgresql.org/pgdocs/postgres/release-9-1.html
> >> - Change the default value of standard_conforming_strings to on (Robert Haas)
> [...]

Ah, of course. Thanks!

(grep failure, sorry)

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Changed behaviour of \'
@ 2011-05-11 00:57  Bruce Momjian <bruce@momjian.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Bruce Momjian @ 2011-05-11 00:57 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: depesz@depesz.com; Martin Pitt <mpitt@debian.org>; pgsql-bugs

Tom Lane wrote:
> hubert depesz lubaczewski <depesz@depesz.com> writes:
> > On Tue, May 10, 2011 at 06:20:23PM +0200, Martin Pitt wrote:
> >> Since HISTORY does not mention this, is that an explicit decision to
> >> finally deprecate the old \' syntax (which would be great, as it makes
> >> this thing a lot more robust and deterministic, but it might be worth
> >> mentioning it in HISTORY), or an unintended side effect?
> 
> > release notes clearly mentions is:
> > http://developer.postgresql.org/pgdocs/postgres/release-9-1.html
> > - Change the default value of standard_conforming_strings to on (Robert Haas)
> > This removes a long-standing incompatibility with the SQL standard;
> > escape_string_warning has produced warnings about this usage for years. E''
> > strings are the proper way to embed escapes in strings and are unaffected by
> > this change. 
> 
> Hmm ... considering that's the first thing in the release notes, I'm
> surprised Martin missed it.  Maybe he was looking for something
> mentioning backslashes ... should we add a bit that specifically says
> that backslashes are now no-ops by default?

I added the word "backslash" before escapes in the attached applied
patch.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +

Attachments:

/rtmp/diff (text/x-diff, 908B) download diff --git a/doc/src/sgml/release-9.1.sgml b/doc/src/sgml/release-9.1.sgml new file mode 100644 index d70c806..7737381 *** a/doc/src/sgml/release-9.1.sgml --- b/doc/src/sgml/release-9.1.sgml *************** *** 62,68 **** standard; <link linkend="guc-escape-string-warning"><varname>escape_string_warning</></link> has produced warnings about this usage for years. <literal>E''</> ! strings are the proper way to embed escapes in strings and are unaffected by this change. </para> </listitem> --- 62,68 ---- standard; <link linkend="guc-escape-string-warning"><varname>escape_string_warning</></link> has produced warnings about this usage for years. <literal>E''</> ! strings are the proper way to embed backslash escapes in strings and are unaffected by this change. </para> </listitem>
^ permalink raw reply [nested|flat] 8+ messages in thread

* Re: Changed behaviour of \'
@ 2011-05-11 03:46  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2011-05-11 03:46 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: depesz@depesz.com; Martin Pitt <mpitt@debian.org>; pgsql-bugs

Bruce Momjian <bruce@momjian.us> writes:
> Tom Lane wrote:
>> Hmm ... considering that's the first thing in the release notes, I'm
>> surprised Martin missed it.  Maybe he was looking for something
>> mentioning backslashes ... should we add a bit that specifically says
>> that backslashes are now no-ops by default?

> I added the word "backslash" before escapes in the attached applied
> patch.

Actually, I had something more like this in mind ...

commit ea964a451e51a32b71d004d261874adb1e135066
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date:   Tue May 10 23:44:33 2011 -0400

    Be more explicit about the meaning of the change in standard_conforming_strings.

inline patch 1: doc/src/sgml/release-9.1.sgml (+3/-2 lines) download inline-1.patchdiff --git a/doc/src/sgml/release-9.1.sgml b/doc/src/sgml/release-9.1.sgml index 7737381..280e0bb 100644 --- a/doc/src/sgml/release-9.1.sgml +++ b/doc/src/sgml/release-9.1.sgml @@ -58,8 +58,9 @@ </para> <para> - This removes a long-standing incompatibility with the SQL - standard; <link + By default, backslashes are now ordinary characters in string literals, + not escape characters. This change removes a long-standing + incompatibility with the SQL standard. <link linkend="guc-escape-string-warning"><varname>escape_string_warning</></link> has produced warnings about this usage for years. <literal>E''</> strings are the proper way to embed backslash escapes in strings and are
regards, tom lane ^ permalink raw reply [nested|flat] 8+ messages in thread

* Re: Changed behaviour of \'
@ 2011-05-11 14:25  Bruce Momjian <bruce@momjian.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Bruce Momjian @ 2011-05-11 14:25 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: depesz@depesz.com; Martin Pitt <mpitt@debian.org>; pgsql-bugs

Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Tom Lane wrote:
> >> Hmm ... considering that's the first thing in the release notes, I'm
> >> surprised Martin missed it.  Maybe he was looking for something
> >> mentioning backslashes ... should we add a bit that specifically says
> >> that backslashes are now no-ops by default?
> 
> > I added the word "backslash" before escapes in the attached applied
> > patch.
> 
> Actually, I had something more like this in mind ...

Great.

---------------------------------------------------------------------------


> 
> commit ea964a451e51a32b71d004d261874adb1e135066
> Author: Tom Lane <tgl@sss.pgh.pa.us>
> Date:   Tue May 10 23:44:33 2011 -0400
> 
>     Be more explicit about the meaning of the change in standard_conforming_strings.
> 
> diff --git a/doc/src/sgml/release-9.1.sgml b/doc/src/sgml/release-9.1.sgml
> index 7737381..280e0bb 100644
> --- a/doc/src/sgml/release-9.1.sgml
> +++ b/doc/src/sgml/release-9.1.sgml
> @@ -58,8 +58,9 @@
>        </para>
>  
>        <para>
> -       This removes a long-standing incompatibility with the SQL
> -       standard;  <link
> +       By default, backslashes are now ordinary characters in string literals,
> +       not escape characters.  This change removes a long-standing
> +       incompatibility with the SQL standard.  <link
>         linkend="guc-escape-string-warning"><varname>escape_string_warning</></link>
>         has produced warnings about this usage for years.  <literal>E''</>
>         strings are the proper way to embed backslash escapes in strings and are
> 
> 
> 			regards, tom lane

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Changed behaviour of \'
@ 2011-05-11 18:57  Magnus Hagander <magnus@hagander.net>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Magnus Hagander @ 2011-05-11 18:57 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; depesz@depesz.com; Martin Pitt <mpitt@debian.org>; pgsql-bugs

On Wed, May 11, 2011 at 16:25, Bruce Momjian <bruce@momjian.us> wrote:
> Tom Lane wrote:
>> Bruce Momjian <bruce@momjian.us> writes:
>> > Tom Lane wrote:
>> >> Hmm ... considering that's the first thing in the release notes, I'm
>> >> surprised Martin missed it.  Maybe he was looking for something
>> >> mentioning backslashes ... should we add a bit that specifically says
>> >> that backslashes are now no-ops by default?
>>
>> > I added the word "backslash" before escapes in the attached applied
>> > patch.
>>
>> Actually, I had something more like this in mind ...
>
> Great.

I wonder if this is something that's going to hit so many people that
we need to be even more clear than that. Like specifically saying that
changing it back to "off" will make legacy applicatoins work again.
Given that *so* many apps use it... And people don't look at warnings
;)


-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/



^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2011-05-11 18:57 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-05-10 16:20 Changed behaviour of \' Martin Pitt <mpitt@debian.org>
2011-05-10 16:37 ` hubert depesz lubaczewski <depesz@depesz.com>
2011-05-10 16:44   ` Tom Lane <tgl@sss.pgh.pa.us>
2011-05-11 00:57     ` Bruce Momjian <bruce@momjian.us>
2011-05-11 03:46       ` Tom Lane <tgl@sss.pgh.pa.us>
2011-05-11 14:25         ` Bruce Momjian <bruce@momjian.us>
2011-05-11 18:57           ` Magnus Hagander <magnus@hagander.net>
2011-05-10 21:11   ` Martin Pitt <mpitt@debian.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox