Re: [BUGS] BUG #14512: Backslashes in LIKE - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: [BUGS] BUG #14512: Backslashes in LIKE
Date
Msg-id CAKFQuwacdGqhc8DY6baKqDNSFi1JgUL0Jt24vd0vF9s6P1Yyag@mail.gmail.com
Whole thread Raw
In response to Re: [BUGS] BUG #14512: Backslashes in LIKE  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [BUGS] BUG #14512: Backslashes in LIKE  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [BUGS] BUG #14512: Backslashes in LIKE  (Vojtěch Rylko <vojta.rylko@gmail.com>)
List pgsql-bugs
On Tue, Jan 24, 2017 at 11:02 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
vojta.rylko@gmail.com writes:
> 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

I see no bug here.  The pattern is wrong, but it happens not to notice in
the first case because it never reaches the buggy part of the pattern.

Then consider a feature request that a malformed pattern be detected and fail independent of the data being checked. Such non-deterministic failure is at least a POLA violation and makes what should be a basically compile-time error into a run-time one.

I will agree that It is not a back-patchable bug (unless we decide to never fail and instead have a malformed pattern always return false - we'd at least be consistent - though probably not in a desirable way)  but would say it is a defect that should be addressed in v10.

David J.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: [BUGS] BUG #14512: Backslashes in LIKE
Next
From: Tom Lane
Date:
Subject: Re: [BUGS] BUG #14512: Backslashes in LIKE