Vyacheslav Akhmechet <coffeemug@stripped> writes:
> On Fri, May 1, 2009 at 3:31 PM, Ivan Novick <ivan@stripped> wrote:
>> As for blobs, when writing data, you are a passed a pointer to where
>> the blob is and then you can storage that data in your engine.
> Are you talking about the fields, or the buffer? A pointer to the
> memory cannot be in the buffer passed to write_row, so is the blob
> stored in the buffer verbatum?
Why do you think the pointer to the memory cannot be stored in the buffer? In
fact this is exactly how it works, the buffer passed to write_row contains the
blob length and data pointer packed into a suitable number of bytes depending
on max length and pointer size.
Check eg. Field_blob::get_ptr() in sql/field.h.
>> When returning a row, you need to allocate a memory buffer
>> in your engine to store the blob and return the pointer to the
>> blob in the row.
> Ok, but what about update_row? Is there a flag somewhere that tells me
> whether the blob has changed (in which case I would have to store the
> new version)?
I believe you can use the table->write_set for this, if the blob needs to be
updated the corresponding bit in write_set will be set.
(but for write_row(), you need to update the blob always, as this is what
implements REPLACE INTO. REPLACE is DELETE + INSERT, so the old value is never
preserved. An unset bit in write_set for write_row means that the
corresponding field has the default value).
Hope this helps,