On 4/6/21 4:25 PM, Bert Herngreen via Firebird-devel wrote:
Hi,
I do understand that this is not a NOT a user support forum, however I
hope to find some support by being pointed out in a direction by you
devs about the IB and FB file format.
I have an Interbase XE3 database with 'Blob not found' errors.
I did retrieve the raw bytes of the original record on the data page
(0x05), did a RLE-decode
(https://firebirdsql.org/manual/fbint-page-5.html
<https://firebirdsql.org/manual/fbint-page-5.html>) and found out that
the BlobId in that case is e.g.:
4C 01 00 00|EC F0 AF 00
In which 4C 01 00 00 is the RDB$RELATION_ID (332 in decimal, verified)
and EC F0 AF 00 the BlobId referencing the blob stored on the blob
data page.
The blobs from surrounding records, that can be found, are on the same
page (page type 0x0C, not a known type in FB, I know).
There's also a page type 0x0B that seems to be a pointer page for the
different 0x0C pages that can exist.
I did scan the 0x0C page and this page exists of:
- a header
- for each blob an offset (2 bytes) and a length (2 bytes) reference
at the upper part of the page
- the real blob data and the bottom part of the page.
I do understand the inner working of the 0x0C page, but can you help
me out how to get from the BlobId (e.g. EC F0 AF 00) to the correct
(0x0C) page?
I guess FB uses some mechanism that works the same.
Not exactly - at least in current versions. In firebird 5 bytes in
BlobId represent record number (and used to find page where blob is
located), 3 bytes - represent relation and also needed to find pagespace
where a page with blob to be found. Bytes are packed in 8-byte BlobId
depending upon CPU endianess.
But if you take very old FB sources (1.5 should be OK) and find
DPM_get_blob() in dpm.epp - looks like it works with format you've
described here.
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel