List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:May 16 2008 11:05am
Subject:re: Safe to modify table->read_set?
View as plain text  

>>>>> "Timothy" == Timothy P Clark <Timothy> writes:

Timothy> In certain circumstances I would like my storage engine to override the
Timothy> current setting of table->read_set. For example, if an UPDATE is being
Timothy> performed or if row-based binlogging is on, the engines needs to read all
Timothy> of the columns, regardless of the read_set state.

If all columns needs to be read, MySQL will mark those columns to be
readable. (If not, it's a bug).

Timothy> It would be handy if I could (as necessary) overwrite the read_set at the
Timothy> beginning of each operation (i.e. in rnd_init and index_init) or when
Timothy> column_bitmaps_signal() is called. And this seems to be what the comment in
Timothy> front of handler::column_bitmaps_signal() is guaranteeing: "[after these
Timothy> functions] MySQL will not use the bitmap for any program logic checking".
Timothy> However, I notice that prepare_record_for_error_message() in
Timothy> references both the read_set and the write_set, presumably after I would
Timothy> have overwritten the bitmaps. So, I'm wondering whether the comment for
Timothy> column_bitmaps_signal() is correct. Can I safely modify table->read_set in
Timothy> rnd_int, index_init, and column_bitmaps_signal? Do I have to save off the
Timothy> old version and restore it at some point (e.g. rnd_end?)

Why would you like to modify the read/write set ?
There is normally no advantage at all in extending the read set.
The read set is mostly a way for MySQL to inform the engine which
columns you need to read (except in some error conditions).

Chaning the masks are likely to make things slower, as MySQL will
then have to do more work in some cases:

- Comparing which columns actually changed value
- Storing columns that are needed later in temporary tables / row caches.

The engine is free to read any column outside of the read set when
reading a row. It can then use this 

Note that the 'original' row that you get as part of handler::update()
will include all column values from the read row, even if they where
not part of the read bitmap set.

To conclude:

- It's not safe to modify the read set, but there shouldn't ever be a
  need to do that.

Safe to modify table->read_set?Timothy P Clark15 May
  • re: Safe to modify table->read_set?Michael Widenius16 May
    • re: Safe to modify table->read_set?Timothy P Clark16 May
      • re: Safe to modify table->read_set?Michael Widenius16 May
      • Re: re: Safe to modify table->read_set?Sergei Golubchik17 May