List:Internals« Previous MessageNext Message »
From:Kristian Nielsen Date:May 6 2009 5:34pm
Subject:Re: Questions about write_row and rnd_next
View as plain text  
Vyacheslav Akhmechet <coffeemug@stripped> writes:

> Ok, I understand now, thank you very much! I just have one more
> question about this. How are variable-sized rows handled? Are they
> still recorded in this buffer (the record buffer passed to write_row),
> or do I have to go through the fields manually, one by one? If
> variable length rows are recorded into this buffer, how can I
> determine its length without looking at every field?

For variable-length fields, space is reserved in the record for the maximum
size of the field plus 1 or 2 bytes for the length. So yes, you can access
a variable-length field without going through all fields. And you can
determine the length using methods on the Field object (or directly by reading
the first 1 or 2 bytes though that's probably a bad idea). There are two
different lengths: the reserved space (max length) and the actual lenght
(which can be smaller).

>>From what I understand if the table contains no blobs and has fixed
> size records, I can dump the buffer passed to write_row into the file
> as is (this is what I'm doing now). If it has blobs, I have to go

Yes, I guess this is more or less what MyISAM does (not sure).


> through the fields to handle blobs properly. Now, variable-sized rows
> and I'm completely unclear about.

You can also just dump for variable-sized fields, but that will be quite
space-inefficient if the actual lenght is much smaller than the maximum.

 - 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