Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 3E9B7242D56 for ; Sat, 24 Mar 2012 01:05:12 -0300 (ADT) Received: from mail.mystoragebox.com ([64.27.7.19]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SBIE3-0000PP-QB for pgsql-bugs@postgresql.org; Sat, 24 Mar 2012 04:05:12 +0000 Received: from cpe-67-240-79-210.nycap.res.rr.com ([67.240.79.210] helo=[192.168.35.110]) by mail.mystoragebox.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1SBHtH-0006Sh-Rf for pgsql-bugs@postgresql.org; Fri, 23 Mar 2012 23:43:44 -0400 Message-ID: <4F6D47E8.2040209@intellasoft.net> Date: Sat, 24 Mar 2012 00:04:56 -0400 From: Mark Murawski User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Subquery with toplevel reference used to work in pg 8.4 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/169 X-Sequence-Number: 32730 I agree the query is a little odd, but I like backwards compatibility! Postgres 8.4.1 ---------------------- CREATE VIEW v_members AS SELECT 1 as member_id, 100 as tenant_id, 3732 as conference_id, 200 as uid FROM (select 1 as uid_user, 2 as uid_contact) as m; SELECT u.tenant_id, u.uid FROM (select 100 as tenant_id, 200 as uid) u LEFT JOIN v_members m ON (m.uid = u.uid AND m.conference_id = 3732) WHERE ( SELECT 1 FROM (select 3732 as conference_id) c WHERE (c.conference_id = 3732) AND (m.uid IS NOT NULL) ) = 1; tenant_id | uid -----------+----- 100 | 200 (1 row) postgres 9.1.3 -------------------------- CREATE VIEW v_members AS SELECT 1 as member_id, 100 as tenant_id, 3732 as conference_id, 200 as uid FROM (select 1 as uid_user, 2 as uid_contact) as m; SELECT u.tenant_id, u.uid FROM (select 100 as tenant_id, 200 as uid) u LEFT JOIN v_members m ON (m.uid = u.uid AND m.conference_id = 3732) WHERE ( SELECT 1 FROM (select 3732 as conference_id) c WHERE (c.conference_id = 3732) AND (m.uid IS NOT NULL) ) = 1; ERROR: Upper-level PlaceHolderVar found where not expected