On 2001 Jun 28, DAVE THOMAS <DAVET@stripped> wrote:
> What is the byte *buf variable that gets passed into this function used for?
This is where the record is stored. You will need to take your
data, make it fit MySQL's record format, and put it into buf.
You don't need to allocate buf - buf is always pointing at a
buffer big enough to hold the record in question.
If you need to know the record format, look at how BDB or InnoDB
does it. BDB is probably a bit simpler to follow. Look at the
unpack_row() function - this is what takes the Berkeley DB data
and converts it into the record format that MySQL uses.
Think of it this way: each table handler obviously uses its own
internal structure for storing the data. MySQL doesn't know
anything about it. So there is a translation between the format
the table handler uses and the format MySQL uses. MySQL, above
the table handler level, always uses one record format. When you
are writing data out, you will get a buffer that is in the MySQL
record format, and you will need to call your own pack_row()
function to convert it into the table handler's format. When you
are reading data from the handler, MySQL will pass an empty buffer
and you will need to take the data that is the table handler's
format and call unpack_row() on it, to convert it into MySQL's
You'll notice in different places that there are three record
buffers (table->record[0..2]). record is the main buffer that
is used for reading and writing. During an update, record
holds the new row and record holds the old row, so the handler
can write only the values that are changed. record is used as
a temporary buffer in a lot of places.
I hope that gives you something to go on.
P.S.: Yes, this *should* be in a permanent document somewhere....
So should a lot more. Dave, if you are keeping notes of what
you have to do to get this working, please consider writing up
a summary, or sending your notes to docs@stripped, so we can use
them as the basis for some MySQL internals documentation. Thanks!
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Tim Smith <tim@stripped>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-time Developer
/_/ /_/\_, /___/\___\_\___/ Boone, NC USA