Hi, MARK!
On Feb 02, MARK CALLAGHAN wrote:
> What is the contract for handler::change_table_ptr()? It may be called
> from the following in 5.0.37: reopen_table(),
> create_myisam_from_heap(). handler::change_table_ptr() isn't virtual,
> so storage engines cannot add any code here. There are no debug only
> checks to confirm that the new table is the same or similar to the
> previous table.
>
> This is a bit more confusing for 5.1. There are still no comments
> although the method is now virtual and ha_partition implements it.
> Calls are also made from ha_delete_table() and
> close_handle_and_leave_table_as_lock().
>
> virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share)
> {
> table= table_arg;
> table_share= share;
> }
>
> These args (table, table_share) are fundamental to the state of the
> handler instance. It seems odd that they can be swapped, especially
> with no error checks.
Agree.
This method is wrong. It's here, as far as I can see, because handler
itself is a odd object with a fuzzy semantics. It mostly corresponds to
an instance of an open table - but not always. For example, it's used to
drop (a closed, not open) table (in ha_delete_table())- and this drop
fails, a dummy TABLE and TABLE_SHARE are created to call
handler::print_error. Of course, ::delete_table() shouldn't be in the
handler class in the first place.
create_myisam_from_heap() is ok, don't bother about it, It does tricks
like memcpy'ing a TABLE object and replacing a table->file with a new
handler, it calls mi_create() directly, etc. It only works with HEAP and
MyISAM, and it's their headache, other engines aren't affected.
close_handle_and_leave_table_as_lock() and reopen_table() - again, it's
because of a fuzziness of handler class. If it would be an instance of
an open table, it would dissapear when a table is closed.
We plan to fix it, but unfortunately I don't see an easy fix for that
(esp. for ha_delete_table()) - so it'll take time.
Regards / Mit vielen Grüßen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Engineer/Server Architect
/_/ /_/\_, /___/\___\_\___/ Sun Microsystems GmbH, HRB München 161028
<___/ Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Häring