Navigation Menu

Skip to content

Commit

Permalink
[wrapper] extract fulltext index existence check method.
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 20, 2011
1 parent 7f55d88 commit efab1a3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
38 changes: 21 additions & 17 deletions ha_mroonga.cc
Expand Up @@ -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;
Expand All @@ -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);
}

Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions ha_mroonga.h
Expand Up @@ -262,6 +262,7 @@ class ha_mroonga: public handler
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);
Expand Down

0 comments on commit efab1a3

Please sign in to comment.