From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Alex Malek <magicagent@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14512: Backslashes in LIKE
Date: Fri, 17 Mar 2017 16:04:45 -0400
Message-ID: <28169.1489781085@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZdk0zQKKMDiYTNU4P5vx0D=CUbkPG8c1=RMdq+uDfvvQ@mail.gmail.com>
References: <CAGH8cccDiRCwUeh4OMRsMEDWEc8aQWJsORw4O05nQgUkO7p7Yw@mail.gmail.com>
<CAKFQuwZdk0zQKKMDiYTNU4P5vx0D=CUbkPG8c1=RMdq+uDfvvQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Fri, Mar 17, 2017 at 11:16 AM, Alex Malek <magicagent@gmail.com> wrote:
>> Given the current behavior the same query will work or raise on error
>> based on context.
> Recently discussed here:
> https://www.postgresql.org/message-id/flat/20170124172505.1431.56735%40wrigleys.postgresql.org#20170...
> In short - preventing a "fails-to-fail" scenario here doesn't seem worthy
> of the effort and run-time cost doing so would entail.
BTW, looking again at the patch I suggested in
https://www.postgresql.org/message-id/10287.1485286334%40sss.pgh.pa.us
it strikes me that the check logic was unnecessarily stupid. What
we need to check is that there's not an odd number of backslashes at
the end of the pattern. Since we know that backend encodings are
ASCII-safe, the test logic could be changed to scan backwards,
something like
p += plen;
nbackslash = 0;
while (plen-- > 0)
{
if (*(--p) == '\\')
nbackslash++;
else
break;
}
if (nbackslash & 1)
ereport(ERROR, ...);
For patterns of practical interest this would be of small and nearly
constant cost. Maybe it is worth doing, especially since we've now
had two independent complaints about it.
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, magicagent@gmail.com
Subject: Re: BUG #14512: Backslashes in LIKE
In-Reply-To: <28169.1489781085@sss.pgh.pa.us>
References: <CAGH8cccDiRCwUeh4OMRsMEDWEc8aQWJsORw4O05nQgUkO7p7Yw@mail.gmail.com> <CAKFQuwZdk0zQKKMDiYTNU4P5vx0D=CUbkPG8c1=RMdq+uDfvvQ@mail.gmail.com> <28169.1489781085@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