From: Tom Lane <tgl@sss.pgh.pa.us>
To: Harry Jackson <harryjackson@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Is this a bug?
Date: Sun, 01 Jul 2007 14:52:20 -0400
Message-ID: <16023.1183315940@sss.pgh.pa.us> (raw)
In-Reply-To: <45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.com>
References: <45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.com>
"Harry Jackson" <harryjackson@gmail.com> 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
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: tgl@sss.pgh.pa.us, harryjackson@gmail.com
Subject: Re: Is this a bug?
In-Reply-To: <16023.1183315940@sss.pgh.pa.us>
References: <45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.com> <16023.1183315940@sss.pgh.pa.us>
* 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