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 ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org