Re: BUG #14512: Backslashes in LIKE

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Vojtěch Rylko <vojta(dot)rylko(at)gmail(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14512: Backslashes in LIKE
Date: 2017-01-24 17:48:09
Message-ID: CAKFQuwYGaV2B48sc2HAPkOhN=FgocA4o543K0ZjJjYX8ygneAQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jan 24, 2017 at 10:40 AM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Tue, Jan 24, 2017 at 10:32 AM, David G. Johnston <
> david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
>> On Tue, Jan 24, 2017 at 10:25 AM, <vojta(dot)rylko(at)gmail(dot)com> wrote:
>>
>>> The following bug has been logged on the website:
>>>
>>> Bug reference: 14512
>>> Logged by: Vojtěch Rylko
>>> Email address: vojta(dot)rylko(at)gmail(dot)com
>>> PostgreSQL version: 9.5.5
>>> Operating system: Linux 3.19.0-32-generic x86_64
>>> Description:
>>>
>>> Hi, LIKE behaves differently depending on left side.
>>>
>>>
>> ​???​
>>
>>
>>> > select 1 where '\' like '\\\'; -- one and three backslashes
>>> ?column?
>>> ----------
>>> (0 rows)
>>>
>>> > select 1 where '\\' like '\\\'; -- two and three backslashes
>>> ERROR: LIKE pattern must not end with escape character
>>>
>>>
>> ​The right-hand side is the "pattern" - i.e., <\\\> - which ends with the
>> escape...
>>
>
> ​Never mind - I was multi-tasking and mis-read what you wrote...
>
> I'll give it more attention when I have a moment if no one else chimes in
> first.
>
>
​Not a hacker but I'd say that the '\' LIKE '\\\' expression is
encountering an invalid optimization that determines that the LIKE cannot
succeed (due to string length differences, probably) - it too should fail
like the other '\\' LIKE '\\\' example.

So, it is a "failure to fail" type of bug. Confirmed using a 9.3.12
instance.

David J.​

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2017-01-24 18:02:25 Re: BUG #14512: Backslashes in LIKE
Previous Message Adrian Klaver 2017-01-24 17:48:06 Re: BUG #14511: Set timezone to local