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

From: Anton Pavlov <udtelco(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(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 18:06:07
Message-ID: CAF4G80NX44tOkib564-5UmnFUHLJ4J8rw15vdh55MYH7i8q2fg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I understand now - thank you. It still rubs me the wrong way that both a OP
b and a not OP b can be equal - STL would go berserk. I guess it was not so
clear to me that ANY / ALL aren't pure functions, more of a control
structure .

Thank you,
Anton.

On Fri, May 15, 2015 at 1:02 AM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> 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 Alvaro Herrera 2015-05-15 18:20:01 Re: BUG #13295: help
Previous Message rodrigomiranda 2015-05-15 14:06:55 BUG #13295: help