Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecNgg-00068x-86 for pgsql-general@arkaria.postgresql.org; Fri, 19 Jan 2018 03:49:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecNge-00008S-Qm for pgsql-general@arkaria.postgresql.org; Fri, 19 Jan 2018 03:49:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ecNge-00008H-JA for pgsql-general@lists.postgresql.org; Fri, 19 Jan 2018 03:49:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ecNgZ-00074A-UO for pgsql-general@postgresql.org; Fri, 19 Jan 2018 03:49:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w0J3ngvU015195; Thu, 18 Jan 2018 22:49:42 -0500 From: Tom Lane To: Seamus Abshere cc: pgsql-general@postgresql.org 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> Comments: In-reply-to Seamus Abshere message dated "Thu, 18 Jan 2018 18:05:26 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15193.1516333782.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 18 Jan 2018 22:49:42 -0500 Message-ID: <15194.1516333782@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Seamus Abshere 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 =3D on" option, it would surel= y 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