Subject Re: [firebird-support] Dump blobs from GDB File - Part II
Author Ann Harrison
Pierre Y. wrote:

>Now I can dump the blobs that are in BLOB Pages even if they are fragmented in two or more pages.

> But when I look the database file using IB Surgeon, I see that most of my blobs are lesser than the pagefile size so they are stored in "standard" data pages.

> How can I read a blob stored in a data page ?
Here's part of the answer. Blobs can be stored in up to three levels.
Level 0 blobs contain the blob data. In that case, the bytes following
the blob header are actual data, complete with the length words we
talked about earlier. Level 1 blobs are arrays of page numbers of level
0 blob pages. Level 2 blobs are arrays of page numbers of level 1
blobs. So, if your header says level 0, just read the data. If it says
level 1, then you've got a multi-page blob, and you'll find it the way
you've been doing.

>I found in the dmp.c file an algorithm to read the data pages but there are no indication on to get the blob datas :
Dmp is really only intested in structurally significant information, so
it makes no attempt to handle either record or blob data.

>static void dmp_data (register DPG page)
> /* .... */
> header = (RHD) ((SCHAR*) page + index->dpg_offset);
> fragment = (RHDF) header;
> if (header->rhd_flags & rhd_blob)
> {
> blob = (BLH) header;
if (blob->blh_level == 0)
char * p = index->dpg_offset + sizeof (struct
char * end = index->dpg_offset + index->dpg_length;
read from p to end.

Give or take some formatting and casts and an actually read loop, that
should do it.