Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

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


pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group