Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nduur-0007pu-8J for pgsql-general@arkaria.postgresql.org; Mon, 11 Apr 2022 14:21:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ndutr-0000LZ-LY for pgsql-general@arkaria.postgresql.org; Mon, 11 Apr 2022 14:20:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ndutr-0000JH-Aa for pgsql-general@lists.postgresql.org; Mon, 11 Apr 2022 14:20:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ndutm-0002Dl-Gj for pgsql-general@postgresql.org; Mon, 11 Apr 2022 14:20:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 23BEK6W7267696; Mon, 11 Apr 2022 10:20:06 -0400 From: Tom Lane To: PALAYRET Jacques cc: "David G. Johnston" , pgsql-general Subject: Re: PostgreSQL : error hint for LATERAL join In-reply-to: <1512389835.55848519.1649664015407.JavaMail.zimbra@meteo.fr> References: <472671960.55252257.1649406546838.JavaMail.zimbra@meteo.fr> <1512389835.55848519.1649664015407.JavaMail.zimbra@meteo.fr> Comments: In-reply-to PALAYRET Jacques message dated "Mon, 11 Apr 2022 10:00:15 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <267694.1649686806.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 11 Apr 2022 10:20:06 -0400 Message-ID: <267695.1649686806@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PALAYRET Jacques writes: > For me, one of the two following things should be true : either the hint= (in case of a lateral error) is incomplete or the possibility of " cross = join lateral " should be removed. = The reason the hint is worded the way it is is a practical one: the other possibilities are not drop-in syntactic replacements. Given CREATE TABLE t (x float8); all five of these are syntactically legal (with or without the implied LATERAL): SELECT * FROM t, sin(x); SELECT * FROM t CROSS JOIN sin(x); SELECT * FROM t JOIN sin(x) ON true; SELECT * FROM t INNER JOIN sin(x) ON true; SELECT * FROM t LEFT JOIN sin(x) ON true; The only way to get to the error in question is to write something like SELECT * FROM t FULL JOIN sin(x) ON true; If that's what you have, then changing FULL to INNER or LEFT will produce a syntactically legal query; changing it to CROSS will not unless you make additional changes (which'd be hard if the ON condition were nontrivial). Also, if we were trying to be completionist, we'd have to somehow work in the comma and implicit-INNER syntaxes, which would surely make the hint a confusing mess. Another way to look at it is that there are only two allowed semantic behaviors here: INNER and LEFT joins. The fact that there's more than one way to spell an inner join is a historical accident. regards, tom lane