Hi!
On Mar 01, ciccettino@stripped wrote:
> Hi,
> I'm getting mad with some aspects that aren't so clear just reading
> the source code and the documentation available (to me, MySQL
> Internals documentation could and should be more comprehensive,
> deepening many other aspects and details; is there any project
> documentation as uml and so on?): I hope you can explain some of these
> and help me figure out the point from where to start my modifications.
> First of all, in a table struct what are "fields" and what are
> "records"? How do they relates with each other and with the so named
> "items"? Which of these structures stores a row?
fields are columns of the table, represented by a Field class.
record[] are buffers to store one row of a table in the internal MySQL
format. "items" are expressions, every expression is an item, everything
that can have a value is an item - field, literal, function, subquery.
Neither from the above should really matter for your implementation,
because fields and items belong to the upper, SQL, layer, while you're
working in the lower, storage engine, layer.
> Secondly: I'm analyzing sql_insert.cc, just as a starting point. I've
> followed all the code from "mysql_insert" on and I've found that the
> junction point with the handler is the instruction: "write_record(thd,
> table ,&info)"; in fact, following "write_record()", it can be found
> that in the simpliest of the situations, the handler instruction
> invoked is ha_write_row(table->record[0]), which seems to just write
> out a buffer (the "table->record[0]" that I didn't understand what
> precisely is) in a custom way that depends on the storage engine. Now
> my main question is: if, as said, a blob is stored in memory as a
> lenght and a pointer (in a blob field there is the "String value"
> which stores the real data, isn't it?), how and where the pointed data
> is inserted in the buffer that then the handler writes out (when, of
> course, the storage engine supports blobs)?
In the storage engine. For example in MyISAM it's done in
_mi_rec_pack(), in InnoDB - row_mysql_store_col_in_innobase_format().
In HEAP, you probably don't want to do it at all.
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Senior Software Developer
/_/ /_/\_, /___/\___\_\___/ MySQL GmbH, Radlkoferstr. 2, D-81373 München
<___/ Geschäftsführer: Hans von Bell, Kaj Arnö - HRB
München 162140