Subject Re: [IBO] BLOBs and Interbase 7
Author Helen Borrie
At 12:04 PM 4/03/2003 +0200, you wrote:
>i understand what you mean, but think about it for a moment, if the field is
>a blob, then why does it care what i pass in, blob means binary means
>anything i want to, so if it is a string so what it should just store it as
>binary, why does it try and convert it, i can understand if the field is a
>string, which is indexed and interbase needs to check and handle it if you
>then pass in binary it cannot index it as string , but blob it should do
>nothing, just store it.
>
>I am not trying to sound clever i would actually like someone to explain
>why.

A blob isn't a string and a string isn't a blob.

String types are stored as an array of bytes + 1 or 2 extra bytes to store
the length characteristics - a varchar needing the second extra byte to
store the number of significant characters. String types have other
restrictions, too, such as requiring escape characters to mark where syntax
characters like a single quote are to be treated as literals.

A blob is an ordered stream of bits, which is laid down in the database in
segments of a certain size. If you don't specify the size, it will be 80
bytes. Blob sub_type 0 is unfiltered - no attempt is made to make any
sense of the stream of bits.

Unlike strings, which are always stored on the same database page as other
non-binary types, blobs are stored apart from the row they belong to, and
"place-held" on the row page by way of a blobID. Another difference is
that blobs are never updated. When you "edit" a blob, you are really
created a brand-new blob which will replace the one that was there
before. You cannot concatenate blobs, either.

In the case of a text blob (blob sub_type 1), the blob filter will make
some sort of meaning out of the bits, based on its character set, and store
the stream in such a way that segments of it can be searched for
substrings. The change that was done in Firebird was to have the DSQL
parser convert a string to a text blob automatically, by invoking the
internal blob filter, if it encounters a string instead of a blob.

Ask on IB-Support, and Ann Harrison will probably provide an exact,
bit-by-bit explanation.

Helen