Re: BUG #14512: Backslashes in LIKE

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Vojtěch Rylko <vojta(dot)rylko(at)gmail(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14512: Backslashes in LIKE
Date: 2017-01-24 18:15:08
Message-ID: CAKFQuwacdGqhc8DY6baKqDNSFi1JgUL0Jt24vd0vF9s6P1Yyag@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jan 24, 2017 at 11:02 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> vojta(dot)rylko(at)gmail(dot)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.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2017-01-24 19:32:14 Re: BUG #14512: Backslashes in LIKE
Previous Message Tom Lane 2017-01-24 18:02:25 Re: BUG #14512: Backslashes in LIKE