Skip site navigation (1) Skip section navigation (2)

Re: BUG #4220: delete statement deleted too many rows

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Lon Varscsak <varscsak(at)smarthealth(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4220: delete statement deleted too many rows
Date: 2008-06-04 19:29:31
Message-ID: 20080604192931.GA3447@depesz.com (view raw or flat)
Thread:
Lists: 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

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2008-06-04 20:08:09
Subject: Re: BUG #4220: delete statement deleted too many rows
Previous:From: Tom LaneDate: 2008-06-04 18:48:20
Subject: Re: BUG #4219: fseeko test failure in configure script

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group