null+****@clear*****
null+****@clear*****
2012年 4月 26日 (木) 00:19:04 JST
Kentoku 2012-04-26 00:19:04 +0900 (Thu, 26 Apr 2012) New Revision: 57e5550e1271369b4f5543263d4f9eafe0302959 Log: Fix error at first inserting using Spider and mroonga with auto_increment column. refs #1319 Modified files: ha_mroonga.cpp test/sql/suite/mroonga_storage/r/show_table_status.result test/sql/suite/mroonga_storage/t/show_table_status.test Modified: ha_mroonga.cpp (+16 -0) =================================================================== --- ha_mroonga.cpp 2012-04-19 00:08:06 +0900 (7b8643d) +++ ha_mroonga.cpp 2012-04-26 00:19:04 +0900 (b27379f) @@ -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); } Modified: test/sql/suite/mroonga_storage/r/show_table_status.result (+10 -0) =================================================================== --- test/sql/suite/mroonga_storage/r/show_table_status.result 2012-04-19 00:08:06 +0900 (98af2e9) +++ test/sql/suite/mroonga_storage/r/show_table_status.result 2012-04-26 00:19:04 +0900 (ebfba35) @@ -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; Modified: test/sql/suite/mroonga_storage/t/show_table_status.test (+9 -0) =================================================================== --- test/sql/suite/mroonga_storage/t/show_table_status.test 2012-04-19 00:08:06 +0900 (f47df39) +++ test/sql/suite/mroonga_storage/t/show_table_status.test 2012-04-26 00:19:04 +0900 (38461ae) @@ -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 @@ -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