Proposed patch to change "missing FROM" messages

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-patches(at)postgreSQL(dot)org
Subject: Proposed patch to change "missing FROM" messages
Date: 2006-01-09 23:32:48
Message-ID: 22842.1136849568@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

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

Attachment Content-Type Size
missing-from.patch application/octet-stream 6.2 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Joachim Wieland 2006-01-10 00:03:11 TODO-item: Add sleep() function, remove from regress.c
Previous Message Tom Lane 2006-01-09 18:45:40 Re: CREATEUSER == SUPERUSER?