Improving "missing FROM-clause entry" message

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Improving "missing FROM-clause entry" message
Date: 2005-12-26 17:09:18
Message-ID: 10406.1135616958@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm thinking about whether we can't improve the message for "missing
FROM-clause entry" to somehow account for situations where the table
does exist in the query but it's referenced from an improper place,
as in bug #2130 (filed a couple hours ago, not yet visible in mail list
archives):

SELECT ... FROM a, b LEFT JOIN c ON (c.task_id=a.task_id ...

This seems to come up often enough in porting MySQL code that we ought
to try to deliver a more specific error message for it.

We can fairly easily modify warnAutoRange() to check whether the target
name exists anywhere in the ParseState's range table. This would not
detect forward references, as in

SELECT ... FROM b LEFT JOIN c ON (c.task_id=a.task_id ...), a ...

but I think this is acceptable since that case isn't going to occur
in ported MySQL code.

What I'm wondering about is how to word the error message. A
minimum-change approach would be to add a HINT, but I'm thinking
it'd be better to replace the message entirely:

ERROR: reference to table "a" is not allowed from this location
HINT: JOIN clauses cannot refer to tables outside the JOIN

Any thoughts about it? Are there any cases where the existing message
wording is preferable even though a matching RTE does exist?

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-12-26 17:39:35 Re: Improving "missing FROM-clause entry" message
Previous Message Tom Lane 2005-12-26 16:07:48 Re: Fixing row comparison semantics