List:Internals« Previous MessageNext Message »
From:Kristian Nielsen Date:May 6 2009 5:38am
Subject:Re: Questions about write_row and rnd_next
View as plain text  
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,

 - Kristian.
Thread
Questions about write_row and rnd_nextVyacheslav Akhmechet1 May
  • Re: Questions about write_row and rnd_nextIvan Novick1 May
    • Re: Questions about write_row and rnd_nextVyacheslav Akhmechet6 May
      • Re: Questions about write_row and rnd_nextKristian Nielsen6 May
        • Re: Questions about write_row and rnd_nextVyacheslav Akhmechet6 May
          • Re: Questions about write_row and rnd_nextKristian Nielsen6 May
            • Re: Questions about write_row and rnd_nextVyacheslav Akhmechet6 May
              • Re: Questions about write_row and rnd_nextKristian Nielsen6 May
                • Re: Questions about write_row and rnd_nextVyacheslav Akhmechet6 May
  • question on storage engine API rnd_endZhixuan Zhu15 May
  • RE: Questions about write_row and rnd_nextZhixuan Zhu15 May