Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fhxi5-0002CE-Pl for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Jul 2018 13:50:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fhxi3-00083v-4r for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Jul 2018 13:50:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fhxi2-00083o-V1 for pgsql-bugs@lists.postgresql.org; Tue, 24 Jul 2018 13:50:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fhxi0-0004TO-6X for pgsql-bugs@lists.postgresql.org; Tue, 24 Jul 2018 13:50:38 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w6ODoXMv001236; Tue, 24 Jul 2018 09:50:33 -0400 From: Tom Lane To: kadek.marek@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15291: Lateral join has different/suprising semantics (with impure function) In-reply-to: <153241622629.1395.7281368493830784815@wrigleys.postgresql.org> References: <153241622629.1395.7281368493830784815@wrigleys.postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Tue, 24 Jul 2018 07:10:26 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1234.1532440233.1@sss.pgh.pa.us> Date: Tue, 24 Jul 2018 09:50:33 -0400 Message-ID: <1235.1532440233@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= writes: > [ LATERAL is ignored when sub-select has no actual lateral references ] > I can understand why it's happening what is happening, yet I still find it > to be problematic. In my opinion those two selects should yield same > results. Hence for impure functions lateral semantics should be preserved > and not optimized away. I believe this behavior is effectively required by the SQL spec. In any case, removing it would pessimize many queries in which writing an unnecessary LATERAL has no bad side-effects today, so I'm disinclined to change a behavior that's stood for half a dozen releases now. regards, tom lane