From: Tom Lane <tgl@sss.pgh.pa.us>
To: takaram71@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17767: psql: tab-completion causes warnings when standard_conforming_strings = off
Date: Wed, 01 Feb 2023 15:01:34 -0500
Message-ID: <1409309.1675281694@sss.pgh.pa.us> (raw)
In-Reply-To: <1366329.1675262563@sss.pgh.pa.us>
References: <17767-e5c80c3e56ded85c@postgresql.org>
<1366329.1675262563@sss.pgh.pa.us>
I wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
>> Step to reproduce:
>> 1. Set standard_conforming_strings = off
>> 2. Type `\d _` and press Tab key
>> Actual result:
>> Got `WARNING: nonstandard use of \\ in a string literal`
> Yeah, that should be coded a bit more robustly. Will fix, thanks
> for the report!
Actually, that seems to be considerably more easily said than done.
I'd thought it'd only require a localized fix, but the issue is
that tab-complete.c is depending on PQescapeStringConn which
only cares about generating a legal literal, not about avoiding
the escape_string_warning warning. To fix, we'd need to
(1) modify what tab-complete.c's escape_string() does, which isn't hard;
(2) modify every query string that incorporates an escape_string result,
along the lines of
-" WHERE d.datname LIKE '%s' "\
+" WHERE d.datname LIKE E'%s' "\
It might be better to change to
+" WHERE d.datname LIKE %s "\
and make escape_string() responsible for adding the E and quotes,
so that it's less likely someone forgets the E. In any case,
step (2) is going to be enormously invasive to tab-complete.c,
and there'd be substantial risk of introducing new bugs.
This problem has been there a long time, though it doesn't manifest
in exactly this way before v15 changed tab-complete's implementation
of name matching. In v14, I can get it to happen with
\d a\b<TAB>
which is less likely to be something somebody would try.
I'm having a hard time getting excited about making such a change,
TBH. Why is it that you are running with
standard_conforming_strings = off and escape_string_warning = on
anyway? If you haven't yet converted your apps to support
standard-conforming strings, you probably aren't intent on
doing so in the near future, so you might as well turn off
escape_string_warning. We last worried about silencing such
warnings in our client programs more than a dozen years ago;
I'm not sure we should still be worried in 2023.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, takaram71@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17767: psql: tab-completion causes warnings when standard_conforming_strings = off
In-Reply-To: <1409309.1675281694@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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