Re: BUG #13289: ANY() function produces a paradox - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #13289: ANY() function produces a paradox
Date
Msg-id 20150515050115.GB2523@alvh.no-ip.org
Whole thread Raw
In response to BUG #13289: ANY() function produces a paradox  (udtelco@gmail.com)
Responses Re: BUG #13289: ANY() function produces a paradox  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
udtelco@gmail.com wrote:
> The following bug has been logged on the website:
>
> Bug reference:      13289
> Logged by:          Anton
> Email address:      udtelco@gmail.com
> PostgreSQL version: 9.3.2
> Operating system:   Solaris 11.2
> Description:
>
> select ('2' != any('{2,3}')) , ('2' = any('{2,3}'))
>
> When != (or <>) operator is applied to any() , results are wrong. Thereby,
> you have a situation where x = y AND x != y both evaluating as true.

There is no paradox here.  When you specify "op ANY array", the operator is
applied to each element in the array and the whole construct returns
true if the operator yields true with any of the array elements.  2 != 3
therefore 2 != any ('{2,3}') is true.

Maybe you want != ALL instead of != ANY.  With != ALL, the element would
be compared to every element and the whole construct would yield true
only if all the operations yield true.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #13289: ANY() function produces a paradox
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #13289: ANY() function produces a paradox