Re: BUG #13289: ANY() function produces a paradox

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: udtelco(at)gmail(dot)com, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13289: ANY() function produces a paradox
Date: 2015-05-15 05:10:50
Message-ID: CAKFQuwbGesuhR-zKJtj0ddNxooSY-gDM-L5o-VNX0+gcGCGi-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, May 14, 2015 at 10:01 PM, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
wrote:

> 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.
>

Using de Morgan::

http://en.wikipedia.org/wiki/De_Morgan%27s_laws

(A OR B) => NOT (A OR B) = (NOT A AND NOT B)​
(​x = ANY) => NOT(x = ANY) = (X != ALL)​

ANY = OR; ALL = AND

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message rodrigomiranda 2015-05-15 14:06:55 BUG #13295: help
Previous Message David G. Johnston 2015-05-15 05:02:52 Re: BUG #13289: ANY() function produces a paradox