Re: Help needed with standard_conforming_strings

"Greg Sabino Mullane" <greg-738XdyZ4GzZWk0Htik3J/[email protected]>
Newsgroups gmane.comp.db.postgresql.dbdpg
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


Jon Jensen wrote:

>> No, we can't leave backslashes unescaped: that's a compatiblity can of
>> worms I don't want to open. Consider the result of a $dbh->quote()
>> that's stored by the app and then reused - but with a different SCS
>> setting!

> That seems like something that Shouldn't Be Done. $dbh->quote() is a
> contextual operation anyway that depends on the database handle in
> question, and as discussed here, possibly the particular connection. It
> seems it should be documented that quote()d strings should not be stored;
> strings should be quoted immediately before being used.

Well, I've not heard of anyone actually doing that, but never underestimate
the ability of people to misuse the tools they have in strange and
interesting ways. To be fair, up until now, the output has been completely
consistent across all connections and versions.

>> In reviewing this, I think I've overcomplicated matters. We don't need
>> to consider the status of standard_conforming_strings at all, we simply
>> need to always use E'' if 1) the string contain a backslash and 2) the
>> server can handle the E syntax.

> Why not *always* use E'' if the server can handle it? I'd rather see that
> consistently applied than only when there's a backslash, so people aren't
> scratching their heads about the occasional odd E'' quote (which many
> assume is a mistake until they learn about it). It'd be simpler as well.

I considered this route, and the consistency is a very strong argument. The
one counter-argument is that using E only when needed is the way Postgres
itself does it, via the internal quote_literal function. Would a large
notice in the docs for quote() be enough to dispel the potential
head scratching if we made it E-as-needed? The other counter-argument is
that E'' is pretty ugly and noisy if not needed, and it won't be 99% of the
time. I'm still on the fence, but leaning towards "as needed".

- --
Greg Sabino Mullane greg-738XdyZ4GzZWk0Htik3J/[email protected]
End Point Corporation
PGP Key: 0x14964AC8 200805082032
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkgjnCMACgkQvJuQZxSWSsiUwgCfZ57elT76iIAPOC3UYJbaYk1M
9EAAoPL50Jn4UAb8V0VddQTelrzp5JMQ
=ozd3
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.