Re: BUG #4220: delete statement deleted too many rows - Mailing list pgsql-bugs

From hubert depesz lubaczewski
Subject Re: BUG #4220: delete statement deleted too many rows
Date
Msg-id 20080604192931.GA3447@depesz.com
Whole thread Raw
In response to BUG #4220: delete statement deleted too many rows  ("Lon Varscsak" <varscsak@smarthealth.com>)
Responses Re: BUG #4220: delete statement deleted too many rows
List pgsql-bugs
On Wed, Jun 04, 2008 at 06:46:42PM +0000, Lon Varscsak wrote:
> delete from customer_transactions_detail where transaction_id in (select
> transaction_id from test);
> The transaction_id column does NOT exist in the temporary table named
> 'test').  I would think this would just result in an error, instead it
> delete all rows in the customer_transactions_detail table.

what you got is so called "correlated subquery", and is perfectly valid
- even if it's surprising sometimes.

i wrote about it in more details in here:

http://www.depesz.com/index.php/2007/09/06/postgresql-gotchas/

anyway - it's definitely not a bug.

depesz

pgsql-bugs by date:

Previous
From: "Lon Varscsak"
Date:
Subject: BUG #4220: delete statement deleted too many rows
Next
From: Tom Lane
Date:
Subject: Re: BUG #4220: delete statement deleted too many rows