From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | udtelco(at)gmail(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #13289: ANY() function produces a paradox |
Date: | 2015-05-15 05:01:15 |
Message-ID: | 20150515050115.GB2523@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
udtelco(at)gmail(dot)com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 13289
> Logged by: Anton
> Email address: udtelco(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2015-05-15 05:02:52 | Re: BUG #13289: ANY() function produces a paradox |
Previous Message | Tom Lane | 2015-05-15 04:54:16 | Re: BUG #13289: ANY() function produces a paradox |