diff options
Diffstat (limited to 'storage/innobase/fts/fts0fts.cc')
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 109 |
1 files changed, 30 insertions, 79 deletions
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 104700bc913..d5ce2f30ab4 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -22,8 +22,6 @@ this program; if not, write to the Free Software Foundation, Inc., Full Text Search interface ***********************************************************************/ -#include "ha_prototypes.h" - #include "trx0roll.h" #include "row0mysql.h" #include "row0upd.h" @@ -40,7 +38,6 @@ Full Text Search interface #include "dict0stats.h" #include "btr0pcur.h" #include "sync0sync.h" -#include "ut0new.h" static const ulint FTS_MAX_ID_LEN = 32; @@ -67,7 +64,7 @@ ulong fts_max_total_cache_size; /** This is FTS result cache limit for each query and would be a configurable variable */ -ulong fts_result_cache_limit; +size_t fts_result_cache_limit; /** Variable specifying the maximum FTS max token size */ ulong fts_max_token_size; @@ -1513,8 +1510,8 @@ fts_rename_one_aux_table( table_new_name_len - new_db_name_len); fts_table_new_name[table_new_name_len] = 0; - return(row_rename_table_for_mysql( - fts_table_old_name, fts_table_new_name, trx, false)); + return row_rename_table_for_mysql( + fts_table_old_name, fts_table_new_name, trx, false, false); } /****************************************************************//** @@ -1744,7 +1741,7 @@ fts_create_in_mem_aux_table( { dict_table_t* new_table = dict_mem_table_create( aux_table_name, NULL, n_cols, 0, table->flags, - table->space->id == TRX_SYS_SPACE + table->space_id == TRX_SYS_SPACE ? 0 : table->space->purpose == FIL_TYPE_TEMPORARY ? DICT_TF2_TEMPORARY : DICT_TF2_USE_FILE_PER_TABLE); @@ -1773,7 +1770,7 @@ fts_create_one_common_table( const char* fts_suffix, mem_heap_t* heap) { - dict_table_t* new_table = NULL; + dict_table_t* new_table; dberr_t error; bool is_config = strcmp(fts_suffix, "CONFIG") == 0; @@ -1826,11 +1823,13 @@ fts_create_one_common_table( } if (error != DB_SUCCESS) { - trx->error_state = error; dict_mem_table_free(new_table); new_table = NULL; ib::warn() << "Failed to create FTS common table " << fts_table_name; + trx->error_state = DB_SUCCESS; + row_drop_table_for_mysql(fts_table_name, trx, SQLCOM_DROP_DB); + trx->error_state = error; } return(new_table); } @@ -1971,7 +1970,7 @@ fts_create_one_index_table( mem_heap_t* heap) { dict_field_t* field; - dict_table_t* new_table = NULL; + dict_table_t* new_table; char table_name[MAX_FULL_NAME_LEN]; dberr_t error; CHARSET_INFO* charset; @@ -2035,11 +2034,13 @@ fts_create_one_index_table( } if (error != DB_SUCCESS) { - trx->error_state = error; dict_mem_table_free(new_table); new_table = NULL; ib::warn() << "Failed to create FTS index table " << table_name; + trx->error_state = DB_SUCCESS; + row_drop_table_for_mysql(table_name, trx, SQLCOM_DROP_DB); + trx->error_state = error; } return(new_table); @@ -3242,15 +3243,10 @@ fts_fetch_doc_from_rec( documents */ { dict_index_t* index; - dict_table_t* table; const rec_t* clust_rec; - ulint num_field; const dict_field_t* ifield; - const dict_col_t* col; ulint clust_pos; - ulint i; ulint doc_len = 0; - ulint processed_doc = 0; st_mysql_ftparser* parser; if (!get_doc) { @@ -3258,19 +3254,15 @@ fts_fetch_doc_from_rec( } index = get_doc->index_cache->index; - table = get_doc->index_cache->index->table; parser = get_doc->index_cache->index->parser; clust_rec = btr_pcur_get_rec(pcur); ut_ad(!page_rec_is_comp(clust_rec) || rec_get_status(clust_rec) == REC_STATUS_ORDINARY); - num_field = dict_index_get_n_fields(index); - - for (i = 0; i < num_field; i++) { + for (ulint i = 0; i < index->n_fields; i++) { ifield = dict_index_get_nth_field(index, i); - col = dict_field_get_col(ifield); - clust_pos = dict_col_get_clust_pos(col, clust_index); + clust_pos = dict_col_get_clust_pos(ifield->col, clust_index); if (!get_doc->index_cache->charset) { get_doc->index_cache->charset = fts_get_charset( @@ -3281,7 +3273,7 @@ fts_fetch_doc_from_rec( doc->text.f_str = btr_rec_copy_externally_stored_field( clust_rec, offsets, - dict_table_page_size(table), + btr_pcur_get_block(pcur)->page.size, clust_pos, &doc->text.f_len, static_cast<mem_heap_t*>( doc->self_heap->arg)); @@ -3299,13 +3291,12 @@ fts_fetch_doc_from_rec( continue; } - if (processed_doc == 0) { + if (!doc_len) { fts_tokenize_document(doc, NULL, parser); } else { fts_tokenize_document_next(doc, doc_len, NULL, parser); } - processed_doc++; doc_len += doc->text.f_len + 1; } } @@ -3713,13 +3704,6 @@ fts_get_max_doc_id( if (!page_is_empty(btr_pcur_get_page(&pcur))) { const rec_t* rec = NULL; - ulint offsets_[REC_OFFS_NORMAL_SIZE]; - ulint* offsets = offsets_; - mem_heap_t* heap = NULL; - ulint len; - const void* data; - - rec_offs_init(offsets_); do { rec = btr_pcur_get_rec(&pcur); @@ -3729,18 +3713,11 @@ fts_get_max_doc_id( } } while (btr_pcur_move_to_prev(&pcur, &mtr)); - if (!rec) { + if (!rec || rec_is_metadata(rec, *index)) { goto func_exit; } - ut_ad(!rec_is_default_row(rec, index)); - offsets = rec_get_offsets( - rec, index, offsets, true, ULINT_UNDEFINED, &heap); - - data = rec_get_nth_field(rec, offsets, 0, &len); - - doc_id = static_cast<doc_id_t>(fts_read_doc_id( - static_cast<const byte*>(data))); + doc_id = fts_read_doc_id(rec); } func_exit: @@ -5222,49 +5199,23 @@ fts_get_doc_id_from_row( } /** Extract the doc id from the record that belongs to index. -@param[in] table table -@param[in] rec record contains FTS_DOC_ID +@param[in] rec record containing FTS_DOC_ID @param[in] index index of rec -@param[in] heap heap memory +@param[in] offsets rec_get_offsets(rec,index) @return doc id that was extracted from rec */ doc_id_t fts_get_doc_id_from_rec( - dict_table_t* table, const rec_t* rec, const dict_index_t* index, - mem_heap_t* heap) + const ulint* offsets) { - ulint len; - const byte* data; - ulint col_no; - doc_id_t doc_id = 0; - ulint offsets_[REC_OFFS_NORMAL_SIZE]; - ulint* offsets = offsets_; - mem_heap_t* my_heap = heap; - - ut_a(table->fts->doc_col != ULINT_UNDEFINED); - - rec_offs_init(offsets_); - - offsets = rec_get_offsets( - rec, index, offsets, true, ULINT_UNDEFINED, &my_heap); - - col_no = dict_col_get_index_pos( - &table->cols[table->fts->doc_col], index); - - ut_ad(col_no != ULINT_UNDEFINED); - - data = rec_get_nth_field(rec, offsets, col_no, &len); - - ut_a(len == 8); - ut_ad(8 == sizeof(doc_id)); - doc_id = static_cast<doc_id_t>(mach_read_from_8(data)); - - if (my_heap && !heap) { - mem_heap_free(my_heap); - } - - return(doc_id); + ulint f = dict_col_get_index_pos( + &index->table->cols[index->table->fts->doc_col], index); + ulint len; + doc_id_t doc_id = mach_read_from_8( + rec_get_nth_field(rec, offsets, f, &len)); + ut_ad(len == 8); + return doc_id; } /*********************************************************************//** @@ -6232,7 +6183,7 @@ fts_rename_one_aux_table_to_hex_format( } error = row_rename_table_for_mysql(aux_table->name, new_name, trx, - FALSE); + false, false); if (error != DB_SUCCESS) { ib::warn() << "Failed to rename aux table '" @@ -6371,7 +6322,7 @@ fts_rename_aux_tables_to_hex_format_low( DICT_TF2_FLAG_UNSET(table, DICT_TF2_FTS_AUX_HEX_NAME); err = row_rename_table_for_mysql(table->name.m_name, aux_table->name, - trx_bg, FALSE); + trx_bg, false, false); trx_bg->dict_operation_lock_mode = 0; dict_table_close(table, TRUE, FALSE); |