Re: DELETE with LIMIT (or my first hack)

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, "Daniel Loureiro" <daniel(at)termasa(dot)com(dot)br>
Cc: "Jaime Casanova" <jaime(at)2ndquadrant(dot)com>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Csaba Nagy" <ncslists(at)googlemail(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: DELETE with LIMIT (or my first hack)
Date: 2010-11-30 19:12:54
Message-ID: 4CF4F8560200002500037FA4@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Daniel Loureiro <daniel(at)termasa(dot)com(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2010-11-30 19:20:00 Re: DELETE with LIMIT (or my first hack)
Previous Message Radosław Smogura 2010-11-30 18:49:03 Improved JDBC driver part 2