Re: DELETE with LIMIT (or my first hack) - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: DELETE with LIMIT (or my first hack)
Date
Msg-id 4CF4F8560200002500037FA4@gw.wicourts.gov
Whole thread Raw
In response to Re: DELETE with LIMIT (or my first hack)  (Daniel Loureiro <daniel@termasa.com.br>)
Responses Re: DELETE with LIMIT (or my first hack)
List pgsql-hackers
Daniel Loureiro <daniel@termasa.com.br> wrote:
> to me the key its security - its a anti-DBA-with-lack-of-attention
> feature.
Well, it seems pretty weak to me for that purpose.  You still trash
data, and you don't have any immediate clue as to what.  If you
wanted protection from that you'd want more of an "assert limit"
that would fail if the affected row count was above what you
specified.
For me the best solution is to develop good habits.  I first type my
statement as "SELECT * FROM ..." and after reviewing the results
arrow up and replace "SELECT *" with "DELETE".  If there's enough
volatility or complexity to make that insufficient insurance, I
begin a transaction.  That way I can not only review row counts but
run queries against the modified data to confirm correct
modification before issuing a COMMIT (or ROLLBACK).
The batching of updates so that vacuums can make space available for
re-use is more compelling to me, but still pretty iffy, since the
work-arounds aren't that hard to find.
-Kevin


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] column-level update privs + lock table
Next
From: Andrew Dunstan
Date:
Subject: Re: DELETE with LIMIT (or my first hack)