null+****@clear*****
null+****@clear*****
2011年 6月 20日 (月) 16:25:53 JST
Kouhei Sutou 2011-06-20 07:25:53 +0000 (Mon, 20 Jun 2011) New Revision: efab1a37d51d3fe370846e7f6f9500663d1608d8 Log: [wrapper] extract fulltext index existence check method. Modified files: ha_mroonga.cc ha_mroonga.h Modified: ha_mroonga.cc (+21 -17) =================================================================== --- ha_mroonga.cc 2011-06-20 07:05:31 +0000 (de30ae3) +++ ha_mroonga.cc 2011-06-20 07:25:53 +0000 (5bebde5) @@ -2552,6 +2552,26 @@ int ha_mroonga::extra_opt(enum ha_extra_function operation, ulong cache_size) DBUG_RETURN(mrn_extra(operation)); } +bool ha_mroonga::wrapper_have_fulltext_index() +{ + MRN_DBUG_ENTER_METHOD(); + + bool have_fulltext_index = FALSE; + + uint i; + uint n_keys = table->s->keys; + for (i = 0; i < n_keys; i++) { + KEY key_info = table->key_info[i]; + + if (key_info.algorithm == HA_KEY_ALG_FULLTEXT) { + have_fulltext_index = TRUE; + break; + } + } + + DBUG_RETURN(have_fulltext_index); +} + int ha_mroonga::wrapper_write_row(uchar *buf) { int error; @@ -2565,7 +2585,7 @@ int ha_mroonga::wrapper_write_row(uchar *buf) MRN_SET_BASE_SHARE_KEY(share, table->s); MRN_SET_BASE_TABLE_KEY(this, table); - if (!error) { + if (!error && wrapper_have_fulltext_index()) { error = wrapper_write_row_index(buf); } @@ -2578,22 +2598,6 @@ int ha_mroonga::wrapper_write_row_index(uchar *buf) int error = 0; - bool have_fulltext_index = FALSE; - - uint i; - uint n_keys = table->s->keys; - for (i = 0; i < n_keys; i++) { - KEY key_info = table->key_info[i]; - - if (key_info.algorithm == HA_KEY_ALG_FULLTEXT) { - have_fulltext_index = TRUE; - break; - } - } - if (!have_fulltext_index) { - DBUG_RETURN(error); - } - grn_obj key; GRN_TEXT_INIT(&key, 0); Modified: ha_mroonga.h (+1 -0) =================================================================== --- ha_mroonga.h 2011-06-20 07:05:31 +0000 (18cf64b) +++ ha_mroonga.h 2011-06-20 07:25:53 +0000 (3eea1e1) @@ -262,6 +262,7 @@ private: void default_start_bulk_insert(ha_rows rows); int wrapper_end_bulk_insert(); int default_end_bulk_insert(); + bool wrapper_have_fulltext_index(); int wrapper_write_row(uchar *buf); int wrapper_write_row_index(uchar *buf); int default_write_row(uchar *buf);