pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Seamus Abshere <seamus@abshere.net>
To: pgsql-general@postgresql.org
Subject: warning for subquery that references a table but not its columns
Date: Thu, 18 Jan 2018 18:05:26 -0300
Message-ID: <1516309526.4088210.1240289384.0CDAD7E3@webmail.messagingengine.com> (raw)

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




view thread (2+ messages)  latest in thread

Message-ID: <1516309526.4088210.1240289384.0CDAD7E3@webmail.messagingengine.com>
Permalink:  ../1516309526.4088210.1240289384.0CDAD7E3@webmail.messagingengine.com/
Also on:    postgresql.org/message-id/1516309526.4088210.1240289384.0CDAD7E3@webmail.messagingengine.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: seamus@abshere.net
  Subject: Re: warning for subquery that references a table but not its columns
  In-Reply-To: <1516309526.4088210.1240289384.0CDAD7E3@webmail.messagingengine.com>
  References: <1516309526.4088210.1240289384.0CDAD7E3@webmail.messagingengine.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox