warning for subquery that references a table but not its columns

From: Seamus Abshere <seamus(at)abshere(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: warning for subquery that references a table but not its columns
Date: 2018-01-18 21:05:26
Message-ID: 1516309526.4088210.1240289384.0CDAD7E3@webmail.messagingengine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I almost got bit by this today:

=> select email from subscribed where email not in (select email from tracks);
email
-------
(0 rows)

=> select email from subscribed where email not in (select tracks.email from tracks);
ERROR: column tracks.email does not exist
LINE 1: ... email from subscribed where email not in (select tracks.ema...

(the "tracks" table doesn't have an "email" column, so the first query is just meaningless)

Should there be a warning for the first query that you reference "tracks" in a subquery but don't use any columns from it?

--
Seamus Abshere, SCEA
https://www.faraday.io
https://github.com/seamusabshere
https://linkedin.com/in/seamusabshere

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2018-01-19 01:07:18 Re: Possible hang in 10.1 with JSON query over partially indexed partitions
Previous Message Paul Jones 2018-01-18 19:00:46 Possible hang in 10.1 with JSON query over partially indexed partitions