Re: Restore deleted rows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Anton Egorov <anton(dot)egoroff(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Restore deleted rows
Date: 2009-04-27 15:17:42
Message-ID: 29358.1240845462@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Anton Egorov escribi:
>> I need to recover deleted rows from table. After I delete those rows I
>> stopped postgres immediately and create tar archive of database. I found
>> solution http://archives.postgresql.org/pgsql-hackers/2005-03/msg00965.php,
>> but is there another (easyer) way to do it?

> I guess you could figure out the Xid of the transaction that deleted the
> tuples, and mark it as aborted in pg_clog; you'd also need to reset the
> hint bits on the tuples themselves. Not necessarily any easier than the
> above, but at least you don't have to patch Postgres code.

The solution recommended in that message doesn't work anyway --- it will
consider *all* tuples visible, even ones you don't want. Reversing a
single transaction, or small number of transactions, as Alvaro suggests
is much less likely to create a huge mess.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Werner Echezuria 2009-04-27 15:19:33 Re: To know what a macro does
Previous Message Simon Riggs 2009-04-27 15:17:20 True Blue