diff options
author | Nikita Malyavin <nikitamalyavin@gmail.com> | 2020-03-23 17:51:46 +1000 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-03-31 17:42:34 +0200 |
commit | 045510cb92448ab54ff8832b1947707287975bae (patch) | |
tree | 45044ca4e303328ac1f73cbf4866db5d5c1a4262 | |
parent | db6f02bb988f5b3c57f3d9fb67a3d82f5a2b7592 (diff) | |
download | mariadb-git-045510cb92448ab54ff8832b1947707287975bae.tar.gz |
fix mroonga: change field's table as well as ptr for ad-hoc // fixes ptr_in_record usage
-rw-r--r-- | storage/mroonga/ha_mroonga.cpp | 31 | ||||
-rw-r--r-- | storage/mroonga/lib/mrn_table_fields_offset_mover.cpp | 28 | ||||
-rw-r--r-- | storage/mroonga/lib/mrn_table_fields_offset_mover.hpp | 10 |
3 files changed, 26 insertions, 43 deletions
diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 728fd8acd7c..c58c3c39125 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -6530,17 +6530,10 @@ int ha_mroonga::wrapper_update_row_index(const uchar *old_data, grn_id old_record_id; my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(old_data, table->record[0]); - for (uint j = 0; j < KEY_N_KEY_PARTS(key_info); j++) { - Field *field = key_info->key_part[j].field; - field->move_field_offset(ptr_diff); - } + error = wrapper_get_record_id((uchar *)old_data, &old_record_id, "failed to get old record ID " "for updating from groonga"); - for (uint j = 0; j < KEY_N_KEY_PARTS(key_info); j++) { - Field *field = key_info->key_part[j].field; - field->move_field_offset(-ptr_diff); - } if (error) { DBUG_RETURN(0); } @@ -6852,8 +6845,6 @@ int ha_mroonga::storage_update_row_index(const uchar *old_data, GRN_TEXT_INIT(&new_key, 0); GRN_TEXT_INIT(&new_encoded_key, 0); - my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(old_data, table->record[0]); - mrn::DebugColumnAccess debug_column_access(table, table->read_set); uint i; uint n_keys = table->s->keys; @@ -6877,18 +6868,10 @@ int ha_mroonga::storage_update_row_index(const uchar *old_data, GRN_BULK_REWIND(&old_key); grn_bulk_space(ctx, &old_key, key_info->key_length); - for (uint j = 0; j < KEY_N_KEY_PARTS(key_info); j++) { - Field *field = key_info->key_part[j].field; - field->move_field_offset(ptr_diff); - } key_copy((uchar *)(GRN_TEXT_VALUE(&old_key)), (uchar *)old_data, key_info, key_info->key_length); - for (uint j = 0; j < KEY_N_KEY_PARTS(key_info); j++) { - Field *field = key_info->key_part[j].field; - field->move_field_offset(-ptr_diff); - } GRN_BULK_REWIND(&old_encoded_key); grn_bulk_reserve(ctx, &old_encoded_key, MRN_MAX_KEY_SIZE); uint old_encoded_key_length; @@ -14841,9 +14824,7 @@ bool ha_mroonga::wrapper_inplace_alter_table( need_fill_index = true; } if (!error && need_fill_index) { - my_ptrdiff_t diff = - PTR_BYTE_DIFF(table->record[0], altered_table->record[0]); - mrn::TableFieldsOffsetMover mover(altered_table, diff); + mrn::FieldTableChanger changer(altered_table, table); error = wrapper_fill_indexes(ha_thd(), altered_table->key_info, index_columns, ha_alter_info->key_count); } @@ -14996,9 +14977,7 @@ bool ha_mroonga::storage_inplace_alter_table_add_index( } } if (!error && have_multiple_column_index) { - my_ptrdiff_t diff = - PTR_BYTE_DIFF(table->record[0], altered_table->record[0]); - mrn::TableFieldsOffsetMover mover(altered_table, diff); + mrn::FieldTableChanger changer(altered_table, table); error = storage_add_index_multiple_columns(altered_table->key_info, ha_alter_info->key_count, index_tables, @@ -15181,9 +15160,7 @@ bool ha_mroonga::storage_inplace_alter_table_add_column( bitmap_set_bit(&generated_column_bitmap, field->field_index); # endif - my_ptrdiff_t diff = - PTR_BYTE_DIFF(table->record[0], altered_table->record[0]); - mrn::TableFieldsOffsetMover mover(altered_table, diff); + mrn::FieldTableChanger changer(altered_table, table); error = storage_rnd_init(true); if (error) { diff --git a/storage/mroonga/lib/mrn_table_fields_offset_mover.cpp b/storage/mroonga/lib/mrn_table_fields_offset_mover.cpp index f230900dd65..bc2d2f258ed 100644 --- a/storage/mroonga/lib/mrn_table_fields_offset_mover.cpp +++ b/storage/mroonga/lib/mrn_table_fields_offset_mover.cpp @@ -20,22 +20,28 @@ #include "mrn_table_fields_offset_mover.hpp" namespace mrn { - TableFieldsOffsetMover::TableFieldsOffsetMover(TABLE *table, - my_ptrdiff_t diff) - : table_(table), - diff_(diff) { - uint n_columns = table_->s->fields; + FieldTableChanger::FieldTableChanger(TABLE *table, + TABLE *new_table) + : old_table_(table), + new_table_(new_table) { + my_ptrdiff_t diff = + PTR_BYTE_DIFF(new_table_->record[0], old_table_->record[0]); + uint n_columns = old_table_->s->fields; for (uint i = 0; i < n_columns; ++i) { - Field *field = table_->field[i]; - field->move_field_offset(diff_); + Field *field = old_table_->field[i]; + field->move_field_offset(diff); + field->table = new_table; } } - TableFieldsOffsetMover::~TableFieldsOffsetMover() { - uint n_columns = table_->s->fields; + FieldTableChanger::~FieldTableChanger() { + my_ptrdiff_t diff = + PTR_BYTE_DIFF(new_table_->record[0], old_table_->record[0]); + uint n_columns = old_table_->s->fields; for (uint i = 0; i < n_columns; ++i) { - Field *field = table_->field[i]; - field->move_field_offset(-diff_); + Field *field = old_table_->field[i]; + field->move_field_offset(-diff); + field->table = old_table_; } } } diff --git a/storage/mroonga/lib/mrn_table_fields_offset_mover.hpp b/storage/mroonga/lib/mrn_table_fields_offset_mover.hpp index 49311b8df47..94f967728c0 100644 --- a/storage/mroonga/lib/mrn_table_fields_offset_mover.hpp +++ b/storage/mroonga/lib/mrn_table_fields_offset_mover.hpp @@ -22,12 +22,12 @@ #include <mrn_mysql.h> namespace mrn { - class TableFieldsOffsetMover { + class FieldTableChanger { public: - TableFieldsOffsetMover(TABLE *table, my_ptrdiff_t diff); - ~TableFieldsOffsetMover(); + FieldTableChanger(TABLE *table, TABLE *new_table); + ~FieldTableChanger(); private: - TABLE *table_; - my_ptrdiff_t diff_; + TABLE *old_table_; + TABLE *new_table_; }; } |