pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #18218: NOT LIKE ANY returns same result as LIKE ANY when array items are wrapped into E''
4+ messages / 4 participants
[nested] [flat]

* BUG #18218: NOT LIKE ANY returns same result as LIKE ANY when array items are wrapped into E''
@ 2023-11-30 10:54  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 2 replies; 4+ messages in thread

From: PG Bug reporting form @ 2023-11-30 10:54 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: baurzhansahariev@gmail.com

The following bug has been logged on the website:

Bug reference:      18218
Logged by:          Baurzhan Sakhariyev
Email address:      baurzhansahariev@gmail.com
PostgreSQL version: 15.0
Operating system:   MacOS
Description:        

https://www.db-fiddle.com/f/cpNjWRLmQT6UFb2wEo2LoG/0

select 'TextToMatch' like any (array[E'Te\%tch', E'nomatch']); -- true,
correct
select 'TextToMatch' NOT like any (array[E'Te\%tch', E'nomatch']); -- true
but must be false because it's a negated version of the expression above

Please note, that versions without E'' work as expected. 
select 'TextToMatch' like any (array['Te\%tch', 'nomatch']); -- false
select 'TextToMatch' NOT like any (array['Te\%tch', 'nomatch']); -- true



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* RE: BUG #18218: NOT LIKE ANY returns same result as LIKE ANY when array items are wrapped into E''
@ 2023-11-30 12:50  Orlov Aleksej <al.orlov@cft.ru>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 4+ messages in thread

From: Orlov Aleksej @ 2023-11-30 12:50 UTC (permalink / raw)
  To: baurzhansahariev@gmail.com <baurzhansahariev@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi, Baurzhan!

I've checked the requests and here's what I think about it. 
There is no mistake here. 

Here's how I tested 

1. select 'TextToMatch' like E'Te\%tch' returns true.
2. select 'TextToMatch' like E'nomatch'  returns false. 
3. select 'TextToMatch' not like E'Te\%tch' returns false.
4. select 'TextToMatch' not like E'nomatch' returns true.

LIKE ANY 1, 2 equals true. 
LIKE NOT ANY 3, 4 equals true.  

Maybe you need to use NOT ALL?


>The following bug has been logged on the website:

>Bug reference:      18218
>Logged by:          Baurzhan Sakhariyev
>Email address:      baurzhansahariev@gmail.com
>PostgreSQL version: 15.0
>Operating system:   MacOS
>Description:        

>https://www.db-fiddle.com/f/cpNjWRLmQT6UFb2wEo2LoG/0

>select 'TextToMatch' like any (array[E'Te\%tch', E'nomatch']); -- true, correct select 'TextToMatch' NOT like any (array[E'Te\%>tch', E'nomatch']); -- true but must be false because it's a negated version of the expression above

>Please note, that versions without E'' work as expected. 
>select 'TextToMatch' like any (array['Te\%tch', 'nomatch']); -- false select 'TextToMatch' NOT like any (array['Te\%tch', >'nomatch']); -- true



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #18218: NOT LIKE ANY returns same result as LIKE ANY when array items are wrapped into E''
@ 2023-11-30 13:06  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 1 reply; 4+ messages in thread

From: Tom Lane @ 2023-11-30 13:06 UTC (permalink / raw)
  To: baurzhansahariev@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> select 'TextToMatch' like any (array[E'Te\%tch', E'nomatch']); -- true,
> correct
> select 'TextToMatch' NOT like any (array[E'Te\%tch', E'nomatch']); -- true
> but must be false because it's a negated version of the expression above

No, it is not.  "NOT LIKE" is the operator to apply in this context,
so the second expression returns true if the test string is NOT LIKE
either of the array elements.  You could write

NOT ('TextToMatch' like any (array[E'Te\%tch', E'nomatch']))

to get the behavior you are after.  Or write NOT LIKE ALL,
as Orlov suggests.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #18218: NOT LIKE ANY returns same result as LIKE ANY when array items are wrapped into E''
@ 2023-11-30 13:20  Bauyrzhan Sakhariyev <baurzhansahariev@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Bauyrzhan Sakhariyev @ 2023-11-30 13:20 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org

Oh, you right, sorry for the noise and thanks for the clarification!

On Thu, Nov 30, 2023 at 2:06 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> PG Bug reporting form <noreply@postgresql.org> writes:
> > select 'TextToMatch' like any (array[E'Te\%tch', E'nomatch']); -- true,
> > correct
> > select 'TextToMatch' NOT like any (array[E'Te\%tch', E'nomatch']); --
> true
> > but must be false because it's a negated version of the expression above
>
> No, it is not.  "NOT LIKE" is the operator to apply in this context,
> so the second expression returns true if the test string is NOT LIKE
> either of the array elements.  You could write
>
> NOT ('TextToMatch' like any (array[E'Te\%tch', E'nomatch']))
>
> to get the behavior you are after.  Or write NOT LIKE ALL,
> as Orlov suggests.
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2023-11-30 13:20 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30 10:54 BUG #18218: NOT LIKE ANY returns same result as LIKE ANY when array items are wrapped into E'' PG Bug reporting form <noreply@postgresql.org>
2023-11-30 12:50 ` Orlov Aleksej <al.orlov@cft.ru>
2023-11-30 13:06 ` Tom Lane <tgl@sss.pgh.pa.us>
2023-11-30 13:20   ` Bauyrzhan Sakhariyev <baurzhansahariev@gmail.com>

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