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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: udtelco(at)gmail(dot)com
Cc: "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:02:52
Message-ID: CAKFQuwY_oP1R6U-0QLwvbDLyEdZan6LOHMAT76dmLg+Sah+-fA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, May 14, 2015 at 10:12 AM, <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.
>

​​As Tom said.​

​And what is "y" in your argument?​

This is shorthand for:

('2' != '2' OR '2' != '3')​, ('2' = '2' OR '2' = '3')

​​If you define "y" as the expression "any('{2,3}')" then it is not even of
the same type as the scalar '2' so a literal comparison is undefined.
Therefore, PostgreSQL treats it as syntactic sugar for the compound boolean
expression (x op y[1] OR x op y[2] OR ...)

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2015-05-15 05:10:50 Re: BUG #13289: ANY() function produces a paradox
Previous Message Alvaro Herrera 2015-05-15 05:01:15 Re: BUG #13289: ANY() function produces a paradox