Re: sql disaster - subquery error but delete continues

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: sql disaster - subquery error but delete continues
Date: 2010-09-10 10:07:37
Message-ID: i6d019$gto$1@dough.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Greg Caulton, 10.09.2010 11:46:
> delete from form_record_details where form_record_id in (select form_record_id from forms where form_id= 40003656)
>
> Seems fine at 1am.
>
> However the subquery has a typo in it - there is no form_record_id in the forms table
>
> But rather than psql throwing an error...
>
> it deletes every row in the form_record_details table
>
> please tell me this is fixed since 8.3

This is not a bug.

I assume there is a form_record_id in the table form_record_details. As you have not used table prefixes or aliases, you are simply referencing the form_record_id from the "outer" table in the subquery.

Thomas

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Steve 2010-09-11 12:29:23 Question regarding indices
Previous Message Greg Caulton 2010-09-10 09:46:35 sql disaster - subquery error but delete continues