New warning code for missing FROM relations

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: New warning code for missing FROM relations
Date: 2000-06-03 04:40:48
Message-ID: 200006030440.AAA01918@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I have committed new warning code to alert users who auto-create
relations without knowing it.

The new code does not throw a warning for:

SELECT pg_language.*;

but does throw one for:

SELECT pg_language.* FROM pg_class

The code issues the warning if it auto-creates a range table entry, and
there is already a range table entry identified as coming from a FROM
clause. Correlated subqueries should not be a problem because they are
not auto-created.

The regression tests run fine, except for:

SELECT *
INTO TABLE tmp1
FROM tmp
WHERE onek.unique1 < 2;
NOTICE: Adding missing FROM-clause entry for table onek
DROP TABLE tmp1;
SELECT *
INTO TABLE tmp1
FROM tmp
WHERE onek2.unique1 < 2;
NOTICE: Adding missing FROM-clause entry for table onek2

Seems those warnings are justified. In fact, I am not even sure what
these queries are trying to do. I have modified the expected files so
they now expect to see the warnings.

A bigger question is whether we should issue ERROR for these queries.
If they have already used a FROM clause, why would they have other
relations not specified there?

If people have other suggestions about this, I would be glad to modify
the code. A new function warnAutoRange() does the checking.

--
Bruce Momjian | http://www.op.net/~candle
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-06-03 07:34:10 Re: New warning code for missing FROM relations
Previous Message SAKAIDA Masaaki 2000-06-03 03:28:56 trim() spec