Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VKVAJ-0001ch-Gz for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Sep 2013 15:20:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VKVAJ-0002Od-0G for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Sep 2013 15:20:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VKVAI-0002OS-CJ for pgsql-bugs@postgresql.org; Fri, 13 Sep 2013 15:20:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VKVAC-0002J7-5y for pgsql-bugs@postgresql.org; Fri, 13 Sep 2013 15:20:10 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id r8DFK0nQ015045; Fri, 13 Sep 2013 11:20:02 -0400 From: Tom Lane To: David Johnston cc: pgsql-bugs@postgresql.org Subject: Re: Re: BUG #8444: ERROR: table name "tblb" specified more than once in subquery In-reply-to: <1379027562361-5770654.post@n5.nabble.com> References: <1379027562361-5770654.post@n5.nabble.com> Comments: In-reply-to David Johnston message dated "Thu, 12 Sep 2013 16:12:42 -0700" Date: Fri, 13 Sep 2013 17:20:00 +0200 Message-ID: <1080.1379085600@sss.pgh.pa.us> X-Pg-Spam-Score: -2.8 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org David Johnston writes: >> Here is a minimal query that demonstrates the problem. In 9.1 it works: >> >> chris=# select * FROM current_user u join (current_user u cross join >> current_user v) x on true; >> >> On 9.3 it fails: >> ERROR: table name "u" specified more than once This is an intentional change that came in with the LATERAL feature. The query is illegal per SQL spec but we used to allow it anyway, on the theory that the table name "u" inside the aliased join "x" wasn't visible anywhere that the other "u" was visible, so the duplicate alias name was harmless. But in the presence of LATERAL it's not harmless; consider select * FROM current_user u join (current_user u cross join LATERAL (select u.x) v) x on true; Which instance of "u" does the lateral reference refer to? (I think there was some discussion of this in the pgsql-hackers list about a year ago, but I couldn't find it in a desultory search.) regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs