IN and ANY

From: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: IN and ANY
Date: 2004-03-02 05:57:01
Message-ID: Pine.LNX.4.44.0403020630130.13979-100000@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The IN and ANY constructs works with different kinds of collections to the
right. This is the current situation:

SUB QUERY VALUE LIST ARRAY

IN X X

ANY X X

The SQL standard specifies that = ANY should be equivalent to IN
(including the value list case) but it is not.

Take for example this:

select 'a' = ANY ('{a,b}');

which according to the SQL spec should evaluate to False but in pg
evaluates to True. Look for at this run in pg:

dennis=# select 'a' IN ('{a,b}');
?column?
----------
f
(1 rad)

dennis=# select 'a' = ANY ('{a,b}');
?column?
----------
t

I only have the SQL200x draft to check. And in section 8.4 it's
clearly stated that "rvc IN ipv" is equivalent to "rvc = ANY ipv" and an
ipv is defined to be either a subquery or a value list.

*** some time later ***

Hmm, the draft seems to be broken since I can only find ANY defined for
subqueries in other sections, and not for value lists. Strange but not
uncommon. Now I don't know what the standard says about this. Maybe
someone with the sql99 spec wants to check.

The question is also what makes sense. I'm not too fond of the above
situation, but I'm not sure if anything can be done now.

--
/Dennis Björklund

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-03-02 06:21:32 Re: Pl/Java - next step?
Previous Message Tom Lane 2004-03-02 04:37:02 Re: 7.3.6 bundled ...