Обсуждение: Proposed patch to change "missing FROM" messages

Поиск
Список
Период
Сортировка

Proposed patch to change "missing FROM" messages

От
Tom Lane
Дата:
Attached is a proposed change to create hopefully-more-useful error
messages in the cases where we currently say "missing FROM-clause entry".
Some examples of what it does:

Patch:
regression=# select * from a,b join c on (a.aa = c.cc);
ERROR:  invalid reference to FROM-clause entry for table "a"
HINT:  There is an entry for "a", but it cannot be referenced from this part of the query.
8.1:
regression=# select * from a,b join c on (a.aa = c.cc);
ERROR:  missing FROM-clause entry for table "a"
8.0:
regression=# select * from a,b join c on (a.aa = c.cc);
NOTICE:  adding missing FROM-clause entry for table "a"
ERROR:  JOIN/ON clause refers to "a", which is not part of JOIN

Patch:
regression=# select a.* from a b;
ERROR:  invalid reference to FROM-clause entry for table "a"
HINT:  Perhaps you meant to reference the table alias "b".
8.1:
regression=# select a.* from a b;
ERROR:  missing FROM-clause entry for table "a"

The above happens only because there is a table "a"; 8.1 behaves
differently when there isn't such a table:

Patch:
regression=# select nosuch.* from a b;
ERROR:  missing FROM-clause entry for table "nosuch"
8.1:
regression=# select nosuch.* from a b;
ERROR:  relation "nosuch" does not exist

(This happens because 8.1 tries to create the RTE before it does
warnAutoRange.  This change in behavior is a side-effect of having
to reorder the operations, but it doesn't seem worse to me.)

The same hints are issued as part of the NOTICE when add_missing_from
is ON, but I did not change the main text of the NOTICE messages.
Also, the error message or notice is unchanged from 8.1 if the code
can't find any RTE that the reference plausibly could have been meant
to match.

I'd like to apply this to 8.1 branch as well as HEAD.  This would
create a need for some new message translations, but there should
be time for translators to do that before 8.1.3, if they are so
inclined.

Comments?

            regards, tom lane


Вложения

Re: Proposed patch to change "missing FROM" messages

От
Michael Glaesemann
Дата:
On Jan 10, 2006, at 8:32 , Tom Lane wrote:

> Attached is a proposed change to create hopefully-more-useful error
> messages in the cases where we currently say "missing FROM-clause
> entry".

It's good to have these hints for users. Thanks, Tom.

> Patch:
> regression=# select * from a,b join c on (a.aa = c.cc);
> ERROR:  invalid reference to FROM-clause entry for table "a"
> HINT:  There is an entry for "a", but it cannot be referenced from
> this part of the query.

For clarity, I'd rewrite this hint as
There is an entry for table "a", ...


Michael Glaesemann
grzm myrealbox com




Re: Proposed patch to change "missing FROM" messages

От
Tom Lane
Дата:
Michael Glaesemann <grzm@myrealbox.com> writes:
> For clarity, I'd rewrite this hint as
> There is an entry for table "a", ...

Done.  Anyone have any other suggestions for wording improvements?

            regards, tom lane