Navigation Menu

Skip to content

Commit

Permalink
Fix error at first inserting using Spider and mroonga with auto_incre…
Browse files Browse the repository at this point in the history
…ment column. refs #1319
  • Loading branch information
Kentoku committed Apr 25, 2012
1 parent 26e78ff commit 57e5550
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ha_mroonga.cpp
Expand Up @@ -3804,6 +3804,22 @@ int ha_mroonga::storage_info(uint flag)
errkey = dup_key;
}

if ((flag & HA_STATUS_AUTO) && table->found_next_number_field) {
THD *thd = ha_thd();
struct system_variables *variables = &thd->variables;
ulonglong nb_reserved_values;
bool next_number_field_is_null = !table->next_number_field;
if (next_number_field_is_null) {
table->next_number_field = table->found_next_number_field;
}
storage_get_auto_increment(variables->auto_increment_offset,
variables->auto_increment_increment, 1,
&stats.auto_increment_value,
&nb_reserved_values);
if (next_number_field_is_null) {
table->next_number_field = NULL;
}
}
DBUG_RETURN(0);
}

Expand Down
10 changes: 10 additions & 0 deletions test/sql/suite/mroonga_storage/r/show_table_status.result
Expand Up @@ -12,3 +12,13 @@ show table status like 't2';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t2 mroonga 10 Fixed 0 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
drop table t1,t2;
create table t1 (c1 int auto_increment, primary key(c1));
show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 mroonga 10 Fixed 0 0 0 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL
drop table t1;
create table t1 (c1 int, primary key(c1));
show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 mroonga 10 Fixed 0 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
drop table t1;
9 changes: 9 additions & 0 deletions test/sql/suite/mroonga_storage/t/show_table_status.test
@@ -1,4 +1,5 @@
# Copyright(C) 2010 Tetsuro IKEDA
# Copyright(C) 2012 Kentoku SHIBA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -30,4 +31,12 @@ show table status like 't2';

drop table t1,t2;

create table t1 (c1 int auto_increment, primary key(c1));
show table status like 't1';
drop table t1;

create table t1 (c1 int, primary key(c1));
show table status like 't1';
drop table t1;

--source include/have_mroonga_deinit.inc

0 comments on commit 57e5550

Please sign in to comment.