Re: warning for subquery that references a table but not its columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Seamus Abshere <seamus(at)abshere(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: warning for subquery that references a table but not its columns
Date: 2018-01-19 03:49:42
Message-ID: 15194.1516333782@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Seamus Abshere <seamus(at)abshere(dot)net> writes:
> Should there be a warning for the first query that you reference "tracks" in a subquery but don't use any columns from it?

Unfortunately, outer references in subqueries are perfectly legal per SQL
standard, and also often essential.

If we were to invent a "SET training_wheels = on" option, it would surely
include some warnings in this area, although I'm not sure exactly what the
triggering conditions ought to be. But there are lots of ways to mess
yourself up in SQL; I don't think subqueries are that much worse than
some other gotchas.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Abhra Kar 2018-01-19 06:58:56 Re: Call sql function in psql
Previous Message Tom Lane 2018-01-19 01:07:18 Re: Possible hang in 10.1 with JSON query over partially indexed partitions