Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "lxndrkrlv(at)gmail(dot)com" <lxndrkrlv(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause
Date: 2022-08-19 02:07:02
Message-ID: Yv7wRmKX01Q2gfPo@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Aug 18, 2022 at 05:52:08PM -0400, Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> 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 referenced 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.

My error text was written based on the email report and was just a test
to see what queries trigger it.

> 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 referenced from this part of the query.
> HINT: To reference that column, you must mark this subquery with LATERAL.

Yes, the problem is that I don't think we want to just be making a
suggestion when we have other cases where LATERAL would not help.

> 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.

Yeah, I think someone will have to have a new idea to improve this.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

Indecision is a decision. Inaction is an action. Mark Batterson

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2022-08-19 14:21:00 Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause
Previous Message Tom Lane 2022-08-18 21:52:08 Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause