pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #13736: pg_dump should use E'' quotes
9+ messages / 6 participants
[nested] [flat]
* BUG #13736: pg_dump should use E'' quotes
@ 2015-10-26 20:48 felipe@felipegasper.com
0 siblings, 1 reply; 9+ messages in thread
From: felipe@felipegasper.com @ 2015-10-26 20:48 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 13736
Logged by: Felipe Gasper
Email address: felipe@felipegasper.com
PostgreSQL version: 9.4.5
Operating system: Linux
Description:
When dumping a DB whose name has a backslash in it, I get a warning like:
------
pg_dump: WARNING: nonstandard use of \\ in a string literal
LINE 1: ...) AS description FROM pg_database WHERE datname = 'i have / ...
^
HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
------
pg_dump should be using PostgreSQL’s own recommended syntax, should it not?
Is there anything that would break from making this change?
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #13736: pg_dump should use E'' quotes
@ 2015-10-26 21:33 Tom Lane <tgl@sss.pgh.pa.us>
parent: felipe@felipegasper.com
0 siblings, 2 replies; 9+ messages in thread
From: Tom Lane @ 2015-10-26 21:33 UTC (permalink / raw)
To: felipe@felipegasper.com; +Cc: pgsql-bugs
felipe@felipegasper.com writes:
> When dumping a DB whose name has a backslash in it, I get a warning like:
> ------
> pg_dump: WARNING: nonstandard use of \\ in a string literal
> LINE 1: ...) AS description FROM pg_database WHERE datname = 'i have / ...
> ^
> HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
> ------
It took me some time to reproduce that, but I eventually realized that
you must have standard_conforming_strings turned off in your database
settings. This has been a deprecated setting since 9.1.
> pg_dump should be using PostgreSQL’s own recommended syntax, should it not?
> Is there anything that would break from making this change?
Yes. For one thing, there would immediately be zero chance of loading
view definitions produced by pg_dump into any other DBMS, or even into old
versions of PG, without painstaking hand-editing to remove all the E's
(and then also fix the string contents, which would likely be actively
wrong without E).
We could avoid the problem by having pg_dump force
standard_conforming_strings to ON rather than adopting the prevailing
database setting, but again that would complicate back-porting its output
to older PG versions. It might also annoy people who are accustomed to
seeing old-style strings in their dumps; presumably people who are still
using standard_conforming_strings = OFF are a bit set in their ways.
Basically there are a number of tradeoffs here and avoiding a purely
cosmetic warning is the consideration that loses out.
At some point we might decide that backward compatibility to old PG
versions is no longer of interest; but what we'd probably do then is have
pg_dump force standard_conforming_strings to ON, not adopt E'' syntax.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #13736: pg_dump should use E'' quotes
@ 2015-10-26 21:55 David G. Johnston <david.g.johnston@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 2 replies; 9+ messages in thread
From: David G. Johnston @ 2015-10-26 21:55 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Felipe Gasper <felipe@felipegasper.com>; pgsql-bugs
On Mon, Oct 26, 2015 at 5:33 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> felipe@felipegasper.com writes:
> > When dumping a DB whose name has a backslash in it, I get a warning like:
>
> > ------
> > pg_dump: WARNING: nonstandard use of \\ in a string literal
> > LINE 1: ...) AS description FROM pg_database WHERE datname = 'i have /
> ...
> > ^
> > HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
> > ------
>
> It took me some time to reproduce that, but I eventually realized that
> you must have standard_conforming_strings turned off in your database
> settings.
[...]
>
> Yes. For one thing, there would immediately be zero chance of loading
> view definitions produced by pg_dump into any other DBMS,
Ironic...we cannot write a standard conforming string out because we are
concerned other databases will be unable to read it.
The OP is advised to set "escape_string_warning" to "off" if they also wish
to have "standard_conforming_strings" set to "off". The question then is
whether we should do so during restore regardless of whether the user has
done so.
David J.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #13736: pg_dump should use E'' quotes
@ 2015-10-26 22:05 Tom Lane <tgl@sss.pgh.pa.us>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 1 reply; 9+ messages in thread
From: Tom Lane @ 2015-10-26 22:05 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Felipe Gasper <felipe@felipegasper.com>; pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, Oct 26, 2015 at 5:33 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Yes. For one thing, there would immediately be zero chance of loading
>> view definitions produced by pg_dump into any other DBMS,
> Ironic...we cannot write a standard conforming string out because we are
> concerned other databases will be unable to read it.
Hm? The E'' syntax would specifically *not* be standard conforming.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #13736: pg_dump should use E'' quotes
@ 2015-10-26 22:06 Felipe Gasper <felipe@felipegasper.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 1 reply; 9+ messages in thread
From: Felipe Gasper @ 2015-10-26 22:06 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
On 26 Oct 2015 4:55 PM, David G. Johnston wrote:
> On Mon, Oct 26, 2015 at 5:33 PM, Tom Lane <tgl@sss.pgh.pa.us
> <mailto:tgl@sss.pgh.pa.us>>wrote:
>
> felipe@felipegasper.com <mailto:felipe@felipegasper.com> writes:
> > When dumping a DB whose name has a backslash in it, I get a warning like:
>
> > ------
> > pg_dump: WARNING: nonstandard use of \\ in a string literal
> > LINE 1: ...) AS description FROM pg_database WHERE datname = 'i have / ...
> > ^
> > HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
> > ------
>
> It took me some time to reproduce that, but I eventually realized that
> you must have standard_conforming_strings turned off in your database
> settings.
>
>
> [...]
>
>
>
> Yes. For one thing, there would immediately be zero chance of loading
> view definitions produced by pg_dump into any other DBMS,
>
>
> Ironic...we cannot write a standard conforming string out because we
> are concerned other databases will be unable to read it.
>
> The OP is advised to set "escape_string_warning" to "off" if they also
> wish to have "standard_conforming_strings" set to "off". The question
> then is whether we should do so during restore regardless of whether the
> user has done so.
The problem is that I don’t control the DB server...
-FG
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #13736: pg_dump should use E'' quotes
@ 2015-10-26 22:08 Andres Freund <andres@anarazel.de>
parent: Felipe Gasper <felipe@felipegasper.com>
0 siblings, 1 reply; 9+ messages in thread
From: Andres Freund @ 2015-10-26 22:08 UTC (permalink / raw)
To: Felipe Gasper <felipe@felipegasper.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
On 2015-10-26 17:06:04 -0500, Felipe Gasper wrote:
> The problem is that I don’t control the DB server...
PGOPTIONS='-c standard_conforming_strings=on -c escape_string_warning=off' pg_dump
ought to do the trick.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #13736: pg_dump should use E'' quotes
@ 2015-10-26 22:15 David G. Johnston <david.g.johnston@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 9+ messages in thread
From: David G. Johnston @ 2015-10-26 22:15 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Felipe Gasper <felipe@felipegasper.com>; pgsql-bugs
On Mon, Oct 26, 2015 at 6:05 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
> > On Mon, Oct 26, 2015 at 5:33 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> Yes. For one thing, there would immediately be zero chance of loading
> >> view definitions produced by pg_dump into any other DBMS,
>
> > Ironic...we cannot write a standard conforming string out because we are
> > concerned other databases will be unable to read it.
>
> Hm? The E'' syntax would specifically *not* be standard conforming.
>
I apparently always mis-understood what it was getting at...
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #13736: pg_dump should use E'' quotes
@ 2015-10-26 22:17 Felipe Gasper <felipe@felipegasper.com>
parent: Andres Freund <andres@anarazel.de>
0 siblings, 0 replies; 9+ messages in thread
From: Felipe Gasper @ 2015-10-26 22:17 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
On 26 Oct 2015 5:08 PM, Andres Freund wrote:
> On 2015-10-26 17:06:04 -0500, Felipe Gasper wrote:
>> The problem is that I don’t control the DB server...
>
> PGOPTIONS='-c standard_conforming_strings=on -c escape_string_warning=off' pg_dump
>
> ought to do the trick.
>
Confirmed -- thank you! :)
-F
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #13736: pg_dump should use E'' quotes
@ 2015-11-02 18:56 Peter Eisentraut <peter_e@gmx.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 9+ messages in thread
From: Peter Eisentraut @ 2015-11-02 18:56 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; felipe@felipegasper.com; +Cc: pgsql-bugs
On 10/26/15 5:33 PM, Tom Lane wrote:
> We could avoid the problem by having pg_dump force
> standard_conforming_strings to ON rather than adopting the prevailing
> database setting,
It does do that.
What it doesn't do is set escape_string_warning, which is really what
the reporter would need. (There is code in pg_dump to do it, but it
apparently only runs when standard_confirming_string is not set. I
haven't traced what that code is really meant to do.)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2015-11-02 18:56 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 20:48 BUG #13736: pg_dump should use E'' quotes felipe@felipegasper.com
2015-10-26 21:33 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-10-26 21:55 ` David G. Johnston <david.g.johnston@gmail.com>
2015-10-26 22:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-10-26 22:15 ` David G. Johnston <david.g.johnston@gmail.com>
2015-10-26 22:06 ` Felipe Gasper <felipe@felipegasper.com>
2015-10-26 22:08 ` Andres Freund <andres@anarazel.de>
2015-10-26 22:17 ` Felipe Gasper <felipe@felipegasper.com>
2015-11-02 18:56 ` Peter Eisentraut <peter_e@gmx.net>
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