I was writing this in an email to a co-worker today, could possibly interest people in the outside world as well. It’s a good idea to look at the source at the same time as reading this :)
In ha_ndbcluster::write_row(byte*),
if (table_share->primary_key != MAX_KEY)
{
/*
* Increase any auto_incremented primary key
*/
if (has_auto_increment)
{
THD *thd= table->in_use;
m_skip_auto_increment= FALSE;
update_auto_increment();
/* Ensure that handler is always called for auto_increment values
*/
thd->next_insert_id= 0;
m_skip_auto_increment= !auto_increment_column_changed;
}
}
We set next_insert_id to 0 so that in handler::update_auto_increment() we end calling the handler and never doing it just inside the server.
The handler function that we end up in is: …
[Read more]