Subject Re: [firebird-support] Re: Recovering deleted data
Author Ann W. Harrison
yaedos2000 wrote:
>
> What is the garbage that is left behind after deletion? Is is possible
> to recovery anything from this garbage (incase a forensic accountant
> wants to recover any data after a deletion)?

When you delete a record, Firebird creates a new record version called a
"deleted stub", which says that the record was deleted and which
transaction deleted it. The most recent copy of the record is preserved
as a back version until the delete is "mature". A mature record version
is one that can be read by any active transaction.

Once the deleted record is mature, the next transaction that stumbles on
it will mark the space used by the deleted stub and the back version as
released and available. The next transaction that tries to store a new
record or record version will overwrite the deleted data.

So, for some period of time after a record is deleted, the data stays in
the database. Someone with a good understanding of the internals and a
tool for probing databases* can recover deleted data. However, there's
no guarantee that all records deleted by a particular transaction will
disappear at the same time. So recovering deleted data is an absolute
last ditch way to recover.

If you regularly obsolete data that you need to recover, I'd recommend
using post-delete triggers and a backup table rather than a tag field on
the main table. Filling the indexes on the primary table with old data
that nobody cares about will slow down your application.


Regards,


Ann



*ibsurgeon.com for example. Or me.