On Thu, May 14, 2015 at 10:01 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
> 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' !=3D any('{2,3}')) , ('2' =3D any('{2,3}'))
> >
> > When !=3D (or <>) operator is applied to any() , results are wrong.
> Thereby,
> > you have a situation where x =3D y AND x !=3D 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 !=3D =
3
> therefore 2 !=3D any ('{2,3}') is true.
>
> Maybe you want !=3D ALL instead of !=3D ANY. With !=3D 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) =3D> NOT (A OR B) =3D (NOT A AND NOT B)=E2=80=8B
(=E2=80=8Bx =3D ANY) =3D> NOT(x =3D ANY) =3D (X !=3D ALL)=E2=80=8B
ANY =3D OR; ALL =3D AND
David J.