X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 83B319DC9CD for ; Tue, 7 Feb 2006 13:01:35 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01072-01 for ; Tue, 7 Feb 2006 13:01:34 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 5F8009DC99F for ; Tue, 7 Feb 2006 13:01:33 -0400 (AST) Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) by svr4.postgresql.org (Postfix) with ESMTP id 404CC5AF024 for ; Tue, 7 Feb 2006 17:01:32 +0000 (GMT) Received: (from smtp@localhost) by ll.mit.edu (8.12.10/8.8.8) id k17H1TGV008327 for ; Tue, 7 Feb 2006 12:01:29 -0500 (EST) Received: from UNKNOWN( ), claiming to be "sty.llan" via SMTP by llmail, id smtpdAAA2uaisp; Tue Feb 7 12:01:11 2006 Date: Tue, 7 Feb 2006 12:01:10 -0500 From: george young To: pgsql-sql@postgresql.org Subject: trecherous subselect needs warning? Message-Id: <20060207120110.5d5f3c44.gry@ll.mit.edu> Reply-To: gry@ll.mit.edu Organization: MIT Lincoln Laboratory X-Mailer: Sylpheed version 2.0.1 (GTK+ 2.8.0; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.041 required=5 tests=[AWL=0.040, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 0.041 X-Spam-Level: X-Archive-Number: 200602/66 X-Sequence-Number: 24076 [PostgreSQL 8.1.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.1] This query returns zero rows: newschm3=# select run_id from s_bake where opset_id not in (select opset_id from opset_steps); run_id -------- (0 rows) But, by my mistake, table opset_steps has no column "opset_id"! Surely it should return an error, or at least a warning, not just an empty rowset. "s_bake" *does* have an "opset_id" column, so that's what it uses. The "from opset_steps" is useless. I can understand it might be inappropriate to make such illegal, but wouldn't a warning be appropriate? It seems like postgres should know immediately that there is a useless "from" clause. Even trickier would be: select run_id from s_bake where opset_id in (select opset_id from opset_steps); which would return all rows from s_bake IFF opset_steps has any rows! Eeek! I suppose the moral of the story is to ALWAYS, absolutely ALWAYS qualify a correlation name (table alias). Of course, what I meant in the original query was: select s.run_id from s_bake s where s.opset_id not in (select os.opset_id from old_opset_steps os); Sigh. Am I missing something here? -- George Young -- "Are the gods not just?" "Oh no, child. What would become of us if they were?" (CSL)