Re: accidental drop table recoverable?

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Paul Libbrecht" <paul(at)activemath(dot)org>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-admin(at)postgresql(dot)org
Subject: Re: accidental drop table recoverable?
Date: 2008-07-14 17:09:39
Message-ID: dcc563d10807141009y422ce863v38d45a40ab720962@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Mon, Jul 14, 2008 at 9:29 AM, Paul Libbrecht <paul(at)activemath(dot)org> wrote:
>
> Le 14-juil.-08 à 16:47, Tom Lane a écrit :
>
>> You can't really "rollback" a DROP TABLE --- that corresponds directly
>> to a filesystem remove() call, and no amount of fooling around with the
>> database state will undo that.
>
> That is dark.
> I read yesterday night that actually a vacuum was advised everyday since
> otherwise there was no actual deletion. So you are telling me that, however,
> drop-table does really go to deletion right away?
>
> I'm running 7.4.5 btw.

First off, if you're gonna run 7.4.x then you should REALLY be running
the latest 7.4 version, which is 7.4.21. You are missing almost 4
years worth of updates, and there ARE dataloss bugs in 7.4.5 which
could bite you. But that's not the core of your issue here.

When you delete tuples in a table, postgresql doesn't delete the
actual row, it just marks it as deleted / not visible anymore. Same
goes for the corresponding entries in an index.

Dropping or truncating a table is something else. Now, if you do:

begin;
drop table yada;
rollback;

you'll still have your table. Same thing goes for truncate. But once
you commit such a transaction, the table is gone. Keep in mind that
if you don't start a transaction explicitly, then each command you
type in is a transaction unto itself, and that means that a simple
drop table statement commits as soon as it finishes.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Marlowe 2008-07-14 18:10:46 Re: How to setup tablespace and table partitioning in a template?
Previous Message Carol Walter 2008-07-14 16:54:46 Re: accidental drop table recoverable?