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

> The way I've been doing ? That means that Level 1 blobs and Level 2
> blobs are stored in "BLOBS PAGES" ?

Level 2 blobs are (I think) always stored on data pages. Level 1 blobs
are stored on data pages if they fit and if not, the engine creates a
level 2 blob and puts that on a data page and puts the level 1 blobs on
blob pages.

Let me see if I can be more clear. All blobs have some level 0 data.
That may be on a data page (if it fits), or on one or more blob pages.
If the level 0 blob is stored on blob pages, then there is a level 1
blob that contains an array of the page numbers for the blob. The level
1 blob is also stored on a data page unless it is to large to fit. If
it is too large, then there is a level 2 blob that contains an array of
the page numbers of the level 1 blob pages.

The blob id stored in the record has the same format as a db_key. It
decomposes into a relation id, a pointer page sequence number, an offset
on the pointer page which contains the number of the data page, and an
index on the data page.
So the record MUST point to something on a data page.

> Now I can read blobs level 0 from data pages. Great :) But I've tested
> my dump tool on a functionnal database and with a SELECT COUNT(*) FROM
> TABLE I get 123326 records (with a blob per record). With my tool I'm
> able to retrieve 121572 interesting blobs either in blobs pages or in
> data pages (level 0). Does that mean that there are 2000 blobs with
> level 1 or 2 stored elsewhere ?

No, I don't think so. My guess is that you're missing some blobs on
data pages, but maybe not. Finding more blobs than records would make
sense if some blob were multi-page and got counted twice. But fewer
doesn't make a lot of sense to me. Perhaps asking the question again in
slightly different way would help.