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 1oOnR2-0004Hj-OY for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Aug 2022 21:52:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oOnR0-0004zg-Lq for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Aug 2022 21:52:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOnR0-0004zW-Dl for pgsql-bugs@lists.postgresql.org; Thu, 18 Aug 2022 21:52:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOnQx-000622-MP for pgsql-bugs@lists.postgresql.org; Thu, 18 Aug 2022 21:52:14 +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 27ILq8TS2792106; Thu, 18 Aug 2022 17:52:08 -0400 From: Tom Lane To: Bruce Momjian cc: "David G. Johnston" , "lxndrkrlv@gmail.com" , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause In-reply-to: References: <17233-afb9d806aaa64b17@postgresql.org> <1409812.1634481258@sss.pgh.pa.us> Comments: In-reply-to Bruce Momjian message dated "Thu, 18 Aug 2022 17:39:06 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2792104.1660859528.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 18 Aug 2022 17:52:08 -0400 Message-ID: <2792105.1660859528@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bruce Momjian writes: > Feedback? > -- test some error cases where LATERAL should have been used but wasn't > select f1,g from int4_tbl a, (select f1 as g) ss; > ERROR: column "f1" does not exist > LINE 1: select f1,g from int4_tbl a, (select f1 as g) ss; > ^ > -HINT: There is a column named "f1" in table "a", but it cannot be refe= renced from this part of the query. > +HINT: There is a column named "f1" in table "a" and another table so a= table-qualified column reference is required. That one has gone from accurate to completely wrong. First, it's not the case that there's more than one possible referent, and second, table-qualifying the reference wouldn't help. What *would* help here is adding LATERAL, but I'm not sure if we can easily tell whether that is the case. I think perhaps the existing message is mislabeled: it's not a hint as written, but errdetail, because it's entirely factual. For this particular example, what would be on-point is DETAIL: There is a column named "f1" in table "a", but it cannot be refer= enced from this part of the query. HINT: To reference that column, you must mark this subquery with LATERAL. While we don't insist that hints be 100% accurate, it's not good if they're wildly unhelpful. So I'm not sure if we can determine whether or not it's likely to be on-point. I didn't look too closely at your other examples. regards, tom lane