ha_innodb.cc:

  Fix bug #12973 : set the table handle field auto_increment_value if ::info() is called with the flag HA_STATUS_AUTO
parent 70badb79
......@@ -5537,6 +5537,33 @@ ha_innobase::info(
trx_get_error_info(prebuilt->trx));
}
if (flag & HA_STATUS_AUTO && table->found_next_number_field) {
longlong auto_inc;
int ret;
/* The following function call can the first time fail in
a lock wait timeout error because it reserves the auto-inc
lock on the table. If it fails, then someone has already inited
the auto-inc counter, and the second call is guaranteed to
succeed. */
ret = innobase_read_and_init_auto_inc(&auto_inc);
if (ret != 0) {
ret = innobase_read_and_init_auto_inc(&auto_inc);
if (ret != 0) {
ut_print_timestamp(stderr);
sql_print_error("Cannot get table %s auto-inc"
"counter value in ::info\n",
ib_table->name);
auto_inc = 0;
}
}
auto_increment_value = auto_inc;
}
prebuilt->trx->op_info = (char*)"";
DBUG_VOID_RETURN;
......@@ -6845,8 +6872,13 @@ ha_innobase::innobase_read_and_init_auto_inc(
goto func_exit;
}
} else {
/* Initialize to max(col) + 1 */
auto_inc = (longlong) table->next_number_field->
/* Initialize to max(col) + 1; we use
'found_next_number_field' below because MySQL in SHOW TABLE
STATUS does not seem to set 'next_number_field'. The comment
in table.h says that 'next_number_field' is set when it is
'active'. */
auto_inc = (longlong) table->found_next_number_field->
val_int_offset(table->s->rec_buff_length) + 1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment