Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 0BD4C9FB31E for ; Sun, 1 Jul 2007 15:52:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 35315-01 for ; Sun, 1 Jul 2007 15:52:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 66FE09FB2FD for ; Sun, 1 Jul 2007 15:52:22 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l61IqKHx016024; Sun, 1 Jul 2007 14:52:20 -0400 (EDT) To: "Harry Jackson" cc: pgsql-general@postgresql.org Subject: Re: Is this a bug? In-reply-to: <45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.com> References: <45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.com> Comments: In-reply-to "Harry Jackson" message dated "Sun, 01 Jul 2007 19:44:47 +0100" Date: Sun, 01 Jul 2007 14:52:20 -0400 Message-ID: <16023.1183315940@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/13 X-Sequence-Number: 116614 "Harry Jackson" writes: > If I made a mistake and changed the "id" column to "user_id" then from > some the statement executes. > =# delete from map_users_roles where user_id = (select user_id from > users WHERE username = 'blah'); This is a standard "outer reference" construction, ie, user_id refers to the field exposed in the outer-level query if there's no match in the inner query. Possibly the SQL spec authors should have made it a little harder to invoke an outer reference, but they didn't. regards, tom lane