Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 99390B5DC5E for ; Fri, 16 Sep 2011 08:06:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 51375-04 for ; Fri, 16 Sep 2011 11:06:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from exprod7og125.obsmtp.com (exprod7og125.obsmtp.com [64.18.2.28]) by mail.postgresql.org (Postfix) with ESMTP id 69200B5DC5B for ; Fri, 16 Sep 2011 08:06:06 -0300 (ADT) Received: from mail-fx0-f43.google.com ([209.85.161.43]) (using TLSv1) by exprod7ob125.postini.com ([64.18.6.12]) with SMTP ID DSNKTnMtnfzgS6QSqIxWEUbqniKdROjWCVDU@postini.com; Fri, 16 Sep 2011 04:06:07 PDT Received: by fxh19 with SMTP id 19so2005760fxh.2 for ; Fri, 16 Sep 2011 04:06:04 -0700 (PDT) Received: by 10.223.88.200 with SMTP id b8mr716013fam.25.1316171164343; Fri, 16 Sep 2011 04:06:04 -0700 (PDT) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi. [88.195.122.240]) by mx.google.com with ESMTPS id o16sm10092836fag.21.2011.09.16.04.06.02 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Sep 2011 04:06:03 -0700 (PDT) Message-ID: <4E732D99.7050307@enterprisedb.com> Date: Fri, 16 Sep 2011 14:06:01 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.21) Gecko/20110831 Icedove/3.1.13 MIME-Version: 1.0 To: Marc Mamin CC: pgsql-bugs@postgresql.org Subject: Re: BUG #6209: Invalid subquery is accepted within a IN() clause References: <201109160959.p8G9xBDu036900@wwwmaster.postgresql.org> In-Reply-To: <201109160959.p8G9xBDu036900@wwwmaster.postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/95 X-Sequence-Number: 31112 On 16.09.2011 12:59, Marc Mamin wrote: > This is not valid, but is accepted. > > > EXPLAIN analyze > select * from test_f_files_steps where id in > (select id from > ( > select file_id,class_id from test_f_files_steps > EXCEPT > select id,class_id from test_f_files_status > )foo > ) It is valid, it just doesn't do what you might expect. The "id" in "select id from (..." refers to the id field in the outer query. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com