standard_conforming_strings vs escape_string_warning

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: standard_conforming_strings vs escape_string_warning
Date: 2006-05-09 20:40:17
Message-ID: 17248.1147207217@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I see that in CVS head, if you turn on standard_conforming_strings,
it still whines about backslashes:

regression=# set standard_conforming_strings to 1;
SET
regression=# select '1234\5678';
WARNING: nonstandard use of escape in a string literal
LINE 1: select '1234\5678';
^
HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
?column?
-----------
1234\5678
(1 row)

regression=#

This seems fairly broken to me. The message is completely off base,
because it's not an "escape", it's a literal backslash, and it's most
certainly not "nonstandard". The HINT is inappropriate too.

The code appears to think that it should warn about backslashes if
escape_string_warning is on, regardless of standard_conforming_strings.
This seems like a pretty dubious decision. I think that as a matter of
policy, we should not be throwing warnings about 100%-SQL-standard
constructs. If someone wants help finding unsafe usages in an old
application, shouldn't they be doing that *before* they turn on
standard_conforming_strings?

So I'd like to suppress the message altogether in this case, but if
we keep it, it needs to be phrased more relevantly.

regards, tom lane

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2006-05-09 20:52:14 Re: [PATCH] Improve EXPLAIN ANALYZE overhead by sampling
Previous Message Cristiano da Cunha Duarte 2006-05-09 20:38:03 BUG #2429: Explain does not report object's schema