Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3331B1337B51 for ; Tue, 22 Feb 2011 13:45:12 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 79394-06 for ; Tue, 22 Feb 2011 17:45:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 7D3F91337B4E for ; Tue, 22 Feb 2011 13:45:04 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p1MHj3Yp003315; Tue, 22 Feb 2011 12:45:03 -0500 (EST) To: "Scott Dunbar" cc: pgsql-bugs@postgresql.org Subject: Re: BUG #5898: Nested "in" clauses hide bad column names In-reply-to: <201102221726.p1MHQPDh069580@wwwmaster.postgresql.org> References: <201102221726.p1MHQPDh069580@wwwmaster.postgresql.org> Comments: In-reply-to "Scott Dunbar" message dated "Tue, 22 Feb 2011 17:26:25 +0000" Date: Tue, 22 Feb 2011 12:45:03 -0500 Message-ID: <3314.1298396703@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/195 X-Sequence-Number: 29467 "Scott Dunbar" writes: > I have a nested in clause like: > select respondent_id from respondent where respondent_id in (select > respondent_id from chat_session where project_id in (select project_id from > project where company_id = 4)); > However, in this example, there is no column named respondent_id in the > chat_session table. Probably there is one in respondent, though? This behavior is not a bug --- what you have there is an outer reference, and it is working exactly as specified by the SQL standard. Sub-selects would be a whole lot less useful if they couldn't refer to variables of the outer query. regards, tom lane