diff options
author | Kentoku <kentokushiba@gmail.com> | 2019-05-20 02:05:22 +0900 |
---|---|---|
committer | Kentoku <kentokushiba@gmail.com> | 2019-05-20 03:15:32 +0900 |
commit | ae106f13922079d3f97210a73104087447958257 (patch) | |
tree | 2c5359110a95ffd309ef8f3a05a35a2c1a4b8733 | |
parent | 8feb78ef53d254539caa0ede374acf2d4db13d2b (diff) | |
download | mariadb-git-bb-10.4-MDEV-19002.tar.gz |
MDEV-19002 Partition performance optimizationbb-10.4-MDEV-19002
Add the partition options of the following function for batch call instead o
- store_lock
- external_lock
- start_stmt
- extra
- cond_push
- info_push
- top_table
-rw-r--r-- | sql/ha_partition.cc | 311 | ||||
-rw-r--r-- | sql/ha_partition.h | 2 | ||||
-rw-r--r-- | sql/handler.cc | 55 | ||||
-rw-r--r-- | sql/handler.h | 10 | ||||
-rw-r--r-- | storage/spider/ha_spider.cc | 2846 | ||||
-rw-r--r-- | storage/spider/ha_spider.h | 69 | ||||
-rw-r--r-- | storage/spider/spd_conn.cc | 43 | ||||
-rw-r--r-- | storage/spider/spd_copy_tables.cc | 16 | ||||
-rw-r--r-- | storage/spider/spd_db_conn.cc | 358 | ||||
-rw-r--r-- | storage/spider/spd_db_include.h | 1 | ||||
-rw-r--r-- | storage/spider/spd_db_mysql.cc | 214 | ||||
-rw-r--r-- | storage/spider/spd_db_oracle.cc | 140 | ||||
-rw-r--r-- | storage/spider/spd_group_by_handler.cc | 20 | ||||
-rw-r--r-- | storage/spider/spd_include.h | 112 | ||||
-rw-r--r-- | storage/spider/spd_table.cc | 487 | ||||
-rw-r--r-- | storage/spider/spd_table.h | 26 | ||||
-rw-r--r-- | storage/spider/spd_trx.cc | 126 | ||||
-rw-r--r-- | storage/spider/spd_trx.h | 4 |
18 files changed, 2793 insertions, 2047 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 9dcd57a5f82..707845075ad 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3598,7 +3598,11 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) maximum number locks needed, only some minor over allocation of memory in get_lock_data(). */ - m_num_locks*= m_tot_parts; + if (!(m_file[0]->table_flags_for_partition() & + HA_PT_CALL_AT_ONCE_STORE_LOCK)) + { + m_num_locks*= m_tot_parts; + } file= m_file; ref_length= get_open_file_sample()->ref_length; @@ -3914,21 +3918,33 @@ int ha_partition::external_lock(THD *thd, int lock_type) else used_partitions= &(m_part_info->lock_partitions); - first_used_partition= bitmap_get_first_set(used_partitions); - - for (i= first_used_partition; - i < m_tot_parts; - i= bitmap_get_next_set(used_partitions, i)) + if (m_file[0]->table_flags_for_partition() & + HA_PT_CALL_AT_ONCE_EXTERNAL_LOCK) { - DBUG_PRINT("info", ("external_lock(thd, %d) part %u", lock_type, i)); - if (unlikely((error= m_file[i]->ha_external_lock(thd, lock_type)))) + if (unlikely((error= m_file[0]->ha_external_lock(thd, lock_type)))) { if (lock_type != F_UNLCK) goto err_handler; } - DBUG_PRINT("info", ("external_lock part %u lock %d", i, lock_type)); - if (lock_type != F_UNLCK) - bitmap_set_bit(&m_locked_partitions, i); + } + else + { + first_used_partition= bitmap_get_first_set(used_partitions); + + for (i= first_used_partition; + i < m_tot_parts; + i= bitmap_get_next_set(used_partitions, i)) + { + DBUG_PRINT("info", ("external_lock(thd, %d) part %u", lock_type, i)); + if (unlikely((error= m_file[i]->ha_external_lock(thd, lock_type)))) + { + if (lock_type != F_UNLCK) + goto err_handler; + } + DBUG_PRINT("info", ("external_lock part %u lock %d", i, lock_type)); + if (lock_type != F_UNLCK) + bitmap_set_bit(&m_locked_partitions, i); + } } if (lock_type == F_UNLCK) { @@ -3940,14 +3956,18 @@ int ha_partition::external_lock(THD *thd, int lock_type) bitmap_union(&m_partitions_to_reset, used_partitions); } - if (m_added_file && m_added_file[0]) + if (!(m_file[0]->table_flags_for_partition() & + HA_PT_CALL_AT_ONCE_EXTERNAL_LOCK)) { - handler **file= m_added_file; - DBUG_ASSERT(lock_type == F_UNLCK); - do + if (m_added_file && m_added_file[0]) { - (void) (*file)->ha_external_lock(thd, lock_type); - } while (*(++file)); + handler **file= m_added_file; + DBUG_ASSERT(lock_type == F_UNLCK); + do + { + (void) (*file)->ha_external_lock(thd, lock_type); + } while (*(++file)); + } } if (lock_type == F_WRLCK) { @@ -3959,12 +3979,16 @@ int ha_partition::external_lock(THD *thd, int lock_type) DBUG_RETURN(0); err_handler: - uint j; - for (j= first_used_partition; - j < i; - j= bitmap_get_next_set(&m_locked_partitions, j)) + if (!(m_file[0]->table_flags_for_partition() & + HA_PT_CALL_AT_ONCE_EXTERNAL_LOCK)) { - (void) m_file[j]->ha_external_lock(thd, F_UNLCK); + uint j; + for (j= first_used_partition; + j < i; + j= bitmap_get_next_set(&m_locked_partitions, j)) + { + (void) m_file[j]->ha_external_lock(thd, F_UNLCK); + } } bitmap_clear_all(&m_locked_partitions); DBUG_RETURN(error); @@ -4025,6 +4049,10 @@ THR_LOCK_DATA **ha_partition::store_lock(THD *thd, DBUG_ENTER("ha_partition::store_lock"); DBUG_ASSERT(thd == current_thd); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_STORE_LOCK) + { + DBUG_RETURN(m_file[0]->store_lock(thd, to, lock_type)); + } /* This can be called from get_lock_data() in mysql_lock_abort_for_thread(), even when thd != table->in_use. In that case don't use partition pruning, @@ -4086,14 +4114,24 @@ int ha_partition::start_stmt(THD *thd, thr_lock_type lock_type) &m_locked_partitions)); DBUG_ENTER("ha_partition::start_stmt"); - for (i= bitmap_get_first_set(&(m_part_info->lock_partitions)); - i < m_tot_parts; - i= bitmap_get_next_set(&m_part_info->lock_partitions, i)) + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_START_STMT) { - if (unlikely((error= m_file[i]->start_stmt(thd, lock_type)))) - break; - /* Add partition to be called in reset(). */ - bitmap_set_bit(&m_partitions_to_reset, i); + if (likely(!(error= m_file[0]->start_stmt(thd, lock_type)))) + { + bitmap_union(&m_partitions_to_reset, &m_part_info->lock_partitions); + } + } + else + { + for (i= bitmap_get_first_set(&(m_part_info->lock_partitions)); + i < m_tot_parts; + i= bitmap_get_next_set(&m_part_info->lock_partitions, i)) + { + if (unlikely((error= m_file[i]->start_stmt(thd, lock_type)))) + break; + /* Add partition to be called in reset(). */ + bitmap_set_bit(&m_partitions_to_reset, i); + } } if (lock_type == F_WRLCK && m_part_info->part_expr) m_part_info->part_expr->walk(&Item::register_field_in_read_map, 1, 0); @@ -8819,11 +8857,17 @@ int ha_partition::extra(enum ha_extra_function operation) switch (operation) { /* Category 1), used by most handlers */ case HA_EXTRA_NO_KEYREAD: - DBUG_RETURN(loop_partitions(end_keyread_cb, NULL)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(end_keyread_cb, NULL)); + else + DBUG_RETURN(loop_partitions(end_keyread_cb, NULL)); case HA_EXTRA_KEYREAD: case HA_EXTRA_FLUSH: case HA_EXTRA_PREPARE_FOR_FORCED_CLOSE: - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); case HA_EXTRA_PREPARE_FOR_RENAME: case HA_EXTRA_FORCE_REOPEN: DBUG_RETURN(loop_extra_alter(operation)); @@ -8835,7 +8879,12 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_KEYREAD_PRESERVE_FIELDS: { if (!m_myisam) - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + { + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); + } } break; @@ -8862,7 +8911,10 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_REMEMBER_POS: case HA_EXTRA_RESTORE_POS: { - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); } case HA_EXTRA_NO_READCHECK: { @@ -8894,7 +8946,10 @@ int ha_partition::extra(enum ha_extra_function operation) m_extra_cache_size= 0; m_extra_prepare_for_update= FALSE; m_extra_cache_part_id= NO_CURRENT_PART_ID; - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); } case HA_EXTRA_IGNORE_NO_KEY: case HA_EXTRA_NO_IGNORE_NO_KEY: @@ -8915,11 +8970,17 @@ int ha_partition::extra(enum ha_extra_function operation) At this time, this is safe by limitation of ha_partition */ - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); } /* Category 7), used by federated handlers */ case HA_EXTRA_INSERT_WITH_UPDATE: - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); /* Category 8) Operations only used by NDB */ case HA_EXTRA_DELETE_CANNOT_BATCH: case HA_EXTRA_UPDATE_CANNOT_BATCH: @@ -8929,30 +8990,54 @@ int ha_partition::extra(enum ha_extra_function operation) } /* Category 9) Operations only used by MERGE */ case HA_EXTRA_ADD_CHILDREN_LIST: - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); case HA_EXTRA_ATTACH_CHILDREN: { int result; uint num_locks; handler **file; - if ((result= loop_partitions(extra_cb, &operation))) - DBUG_RETURN(result); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + { + if ((result= first_partition(extra_cb, &operation))) + DBUG_RETURN(result); + } + else + { + if ((result= loop_partitions(extra_cb, &operation))) + DBUG_RETURN(result); + } /* Recalculate lock count as each child may have different set of locks */ num_locks= 0; file= m_file; - do + if ((*file)->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_STORE_LOCK) { num_locks+= (*file)->lock_count(); - } while (*(++file)); + } + else + { + do + { + num_locks+= (*file)->lock_count(); + } while (*(++file)); + } m_num_locks= num_locks; break; } case HA_EXTRA_IS_ATTACHED_CHILDREN: - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); case HA_EXTRA_DETACH_CHILDREN: - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); case HA_EXTRA_MARK_AS_LOG_TABLE: /* http://dev.mysql.com/doc/refman/5.1/en/partitioning-limitations.html @@ -8964,7 +9049,10 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_BEGIN_ALTER_COPY: case HA_EXTRA_END_ALTER_COPY: case HA_EXTRA_FAKE_START_STMT: - DBUG_RETURN(loop_partitions(extra_cb, &operation)); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(extra_cb, &operation)); + else + DBUG_RETURN(loop_partitions(extra_cb, &operation)); default: { /* Temporary crash to discover what is wrong */ @@ -9037,6 +9125,9 @@ int ha_partition::extra_opt(enum ha_extra_function operation, ulong arg) switch (operation) { case HA_EXTRA_KEYREAD: + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + DBUG_RETURN(first_partition(start_keyread_cb, &arg)); + else DBUG_RETURN(loop_partitions(start_keyread_cb, &arg)); case HA_EXTRA_CACHE: prepare_extra_cache(arg); @@ -9097,18 +9188,43 @@ int ha_partition::loop_extra_alter(enum ha_extra_function operation) if (m_new_file != NULL) { - for (file= m_new_file; *file; file++) - if ((tmp= (*file)->extra(operation))) + if (m_new_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + { + if ((tmp= (*m_new_file)->extra(operation))) result= tmp; + } + else + { + for (file= m_new_file; *file; file++) + if ((tmp= (*file)->extra(operation))) + result= tmp; + } } if (m_reorged_file != NULL) { - for (file= m_reorged_file; *file; file++) - if ((tmp= (*file)->extra(operation))) + if (m_reorged_file[0]-> + table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + { + if ((tmp= (*m_reorged_file)->extra(operation))) result= tmp; + } + else + { + for (file= m_reorged_file; *file; file++) + if ((tmp= (*file)->extra(operation))) + result= tmp; + } + } + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_EXTRA) + { + if ((tmp= first_partition(extra_cb, &operation))) + result= tmp; + } + else + { + if ((tmp= loop_partitions(extra_cb, &operation))) + result= tmp; } - if ((tmp= loop_partitions(extra_cb, &operation))) - result= tmp; DBUG_RETURN(result); } @@ -9148,6 +9264,29 @@ int ha_partition::loop_partitions(handler_callback callback, void *param) } +/** + Call callback(part, param) on first partitions + + @param callback a callback to call for each partition + @param param a void*-parameter passed to callback + + @return Operation status + @retval >0 Error code + @retval 0 Success +*/ + +int ha_partition::first_partition(handler_callback callback, void *param) +{ + int result; + DBUG_ENTER("ha_partition::first_partition"); + result= callback(m_file[0], param); + + /* Add lock partitions to be called in reset(). */ + bitmap_union(&m_partitions_to_reset, &m_part_info->lock_partitions); + DBUG_RETURN(result); +} + + /* Call extra(HA_EXTRA_CACHE) on next partition_id @@ -11009,17 +11148,27 @@ const COND *ha_partition::cond_push(const COND *cond) We want to do this in a separate loop to not come into a situation where we have only done cond_push() to some of the tables */ - do + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_TOP_TABLE) { if (((*file)->set_top_table_and_fields(top_table, top_table_field, top_table_fields))) DBUG_RETURN(cond); // Abort cond push, no error - } while (*(++file)); - file= m_file; + } + else + { + do + { + if (((*file)->set_top_table_and_fields(top_table, + top_table_field, + top_table_fields))) + DBUG_RETURN(cond); // Abort cond push, no error + } while (*(++file)); + file= m_file; + } } - do + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_COND_PUSH) { if ((*file)->pushed_cond != cond) { @@ -11028,7 +11177,20 @@ const COND *ha_partition::cond_push(const COND *cond) else (*file)->pushed_cond= cond; } - } while (*(++file)); + } + else + { + do + { + if ((*file)->pushed_cond != cond) + { + if ((*file)->cond_push(cond)) + res_cond= (COND *) cond; + else + (*file)->pushed_cond= cond; + } + } while (*(++file)); + } DBUG_RETURN(res_cond); } @@ -11043,10 +11205,17 @@ void ha_partition::cond_pop() handler **file= m_file; DBUG_ENTER("ha_partition::cond_pop"); - do + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_COND_PUSH) { (*file)->cond_pop(); - } while (*(++file)); + } + else + { + do + { + (*file)->cond_pop(); + } while (*(++file)); + } DBUG_VOID_RETURN; } @@ -11626,12 +11795,19 @@ int ha_partition::info_push(uint info_type, void *info) handler **file= m_file; DBUG_ENTER("ha_partition::info_push"); - do + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_INFO_PUSH) { - int tmp; - if ((tmp= (*file)->info_push(info_type, info))) - error= tmp; - } while (*(++file)); + error= (*file)->info_push(info_type, info); + } + else + { + do + { + int tmp; + if ((tmp= (*file)->info_push(info_type, info))) + error= tmp; + } while (*(++file)); + } DBUG_RETURN(error); } @@ -11647,8 +11823,15 @@ void ha_partition::clear_top_table_fields() top_table= NULL; top_table_field= NULL; top_table_fields= 0; - for (file= m_file; *file; file++) - (*file)->clear_top_table_fields(); + if (m_file[0]->table_flags_for_partition() & HA_PT_CALL_AT_ONCE_TOP_TABLE) + { + m_file[0]->clear_top_table_fields(); + } + else + { + for (file= m_file; *file; file++) + (*file)->clear_top_table_fields(); + } } DBUG_VOID_RETURN; } diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 5913b3d2aa8..737813fb31e 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -404,6 +404,7 @@ public: } Partition_share *get_part_share() { return part_share; } handler *clone(const char *name, MEM_ROOT *mem_root); + ha_partition *get_clone_source() { return m_is_clone_of; } virtual void set_part_info(partition_info *part_info) { m_part_info= part_info; @@ -882,6 +883,7 @@ private: handler *file, uint *n); static const uint NO_CURRENT_PART_ID= NOT_A_PARTITION_ID; int loop_partitions(handler_callback callback, void *param); + int first_partition(handler_callback callback, void *param); int loop_extra_alter(enum ha_extra_function operations); void late_extra_cache(uint partition_id); void late_extra_no_cache(uint partition_id); diff --git a/sql/handler.cc b/sql/handler.cc index edd6e40b8ec..02e56fe559c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2800,7 +2800,7 @@ int handler::ha_rnd_next(uchar *buf) int result; DBUG_ENTER("handler::ha_rnd_next"); DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); DBUG_ASSERT(inited == RND); do @@ -2834,7 +2834,7 @@ int handler::ha_rnd_pos(uchar *buf, uchar *pos) int result; DBUG_ENTER("handler::ha_rnd_pos"); DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); DBUG_ASSERT(inited == RND); TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, MAX_KEY, 0, @@ -2859,7 +2859,7 @@ int handler::ha_index_read_map(uchar *buf, const uchar *key, int result; DBUG_ENTER("handler::ha_index_read_map"); DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); DBUG_ASSERT(inited==INDEX); TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, active_index, 0, @@ -2888,7 +2888,7 @@ int handler::ha_index_read_idx_map(uchar *buf, uint index, const uchar *key, int result; DBUG_ASSERT(inited==NONE); DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); DBUG_ASSERT(end_range == NULL); TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, index, 0, { result= index_read_idx_map(buf, index, key, keypart_map, find_flag); }) @@ -2909,7 +2909,7 @@ int handler::ha_index_next(uchar * buf) int result; DBUG_ENTER("handler::ha_index_next"); DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); DBUG_ASSERT(inited==INDEX); TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, active_index, 0, @@ -2930,7 +2930,7 @@ int handler::ha_index_prev(uchar * buf) int result; DBUG_ENTER("handler::ha_index_prev"); DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); DBUG_ASSERT(inited==INDEX); TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, active_index, 0, @@ -2950,7 +2950,7 @@ int handler::ha_index_first(uchar * buf) { int result; DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); DBUG_ASSERT(inited==INDEX); TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, active_index, 0, @@ -2970,7 +2970,7 @@ int handler::ha_index_last(uchar * buf) { int result; DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); DBUG_ASSERT(inited==INDEX); TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, active_index, 0, @@ -2990,7 +2990,7 @@ int handler::ha_index_next_same(uchar *buf, const uchar *key, uint keylen) { int result; DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); DBUG_ASSERT(inited==INDEX); TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, active_index, 0, @@ -3589,7 +3589,7 @@ void handler::ha_release_auto_increment() { DBUG_ENTER("ha_release_auto_increment"); DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK || + m_lock_type != F_UNLCK || table->file != this || (!next_insert_id && !insert_id_for_cur_row)); release_auto_increment(); insert_id_for_cur_row= 0; @@ -4160,7 +4160,8 @@ err: */ uint handler::get_dup_key(int error) { - DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK); + DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || + m_lock_type != F_UNLCK || table->file != this); DBUG_ENTER("handler::get_dup_key"); if (table->s->long_unique_table && table->file->errkey < table->s->keys) DBUG_RETURN(table->file->errkey); @@ -4273,7 +4274,7 @@ int handler::ha_check(THD *thd, HA_CHECK_OPT *check_opt) { int error; DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); if ((table->s->mysql_version >= MYSQL_VERSION_ID) && (check_opt->sql_flags & TT_FOR_UPGRADE)) @@ -4359,7 +4360,7 @@ handler::ha_bulk_update_row(const uchar *old_data, const uchar *new_data, ha_rows *dup_key_found) { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_WRLCK); + m_lock_type == F_WRLCK || table->file != this); mark_trx_read_write(); return bulk_update_row(old_data, new_data, dup_key_found); @@ -4376,7 +4377,7 @@ int handler::ha_delete_all_rows() { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_WRLCK); + m_lock_type == F_WRLCK || table->file != this); mark_trx_read_write(); return delete_all_rows(); @@ -4393,7 +4394,7 @@ int handler::ha_truncate() { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_WRLCK); + m_lock_type == F_WRLCK || table->file != this); mark_trx_read_write(); return truncate(); @@ -4410,7 +4411,7 @@ int handler::ha_reset_auto_increment(ulonglong value) { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_WRLCK); + m_lock_type == F_WRLCK || table->file != this); mark_trx_read_write(); return reset_auto_increment(value); @@ -4427,7 +4428,7 @@ int handler::ha_optimize(THD* thd, HA_CHECK_OPT* check_opt) { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_WRLCK); + m_lock_type == F_WRLCK || table->file != this); mark_trx_read_write(); return optimize(thd, check_opt); @@ -4444,7 +4445,7 @@ int handler::ha_analyze(THD* thd, HA_CHECK_OPT* check_opt) { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); mark_trx_read_write(); return analyze(thd, check_opt); @@ -4461,7 +4462,7 @@ bool handler::ha_check_and_repair(THD *thd) { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_UNLCK); + m_lock_type == F_UNLCK || table->file != this); mark_trx_read_write(); return check_and_repair(thd); @@ -4478,7 +4479,7 @@ int handler::ha_disable_indexes(uint mode) { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); mark_trx_read_write(); return disable_indexes(mode); @@ -4495,7 +4496,7 @@ int handler::ha_enable_indexes(uint mode) { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); mark_trx_read_write(); return enable_indexes(mode); @@ -4512,7 +4513,7 @@ int handler::ha_discard_or_import_tablespace(my_bool discard) { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_WRLCK); + m_lock_type == F_WRLCK || table->file != this); mark_trx_read_write(); return discard_or_import_tablespace(discard); @@ -4523,7 +4524,7 @@ bool handler::ha_prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); mark_trx_read_write(); return prepare_inplace_alter_table(altered_table, ha_alter_info); @@ -4759,7 +4760,7 @@ handler::ha_change_partitions(HA_CREATE_INFO *create_info, from current partitions and write lock will be taken on new partitions. */ DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + m_lock_type != F_UNLCK || table->file != this); mark_trx_read_write(); @@ -6546,7 +6547,7 @@ int handler::ha_write_row(uchar *buf) int error; Log_func *log_func= Write_rows_log_event::binlog_row_logging_function; DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_WRLCK); + m_lock_type == F_WRLCK || table->file != this); DBUG_ENTER("handler::ha_write_row"); DEBUG_SYNC_C("ha_write_row_start"); @@ -6589,7 +6590,7 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data) int error; Log_func *log_func= Update_rows_log_event::binlog_row_logging_function; DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_WRLCK); + m_lock_type == F_WRLCK || table->file != this); /* Some storage engines require that the new record is in record[0] @@ -6659,7 +6660,7 @@ int handler::ha_delete_row(const uchar *buf) int error; Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function; DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type == F_WRLCK); + m_lock_type == F_WRLCK || table->file != this); /* Normally table->record[0] is used, but sometimes table->record[1] is used. */ diff --git a/sql/handler.h b/sql/handler.h index fb6862e4ce1..4bee8d16cab 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -351,6 +351,15 @@ enum enum_alter_inplace_result { #define HA_DO_RANGE_FILTER_PUSHDOWN 1024 +/* table flags for partition engine */ +#define HA_PT_CALL_AT_ONCE_STORE_LOCK (1 << 0) +#define HA_PT_CALL_AT_ONCE_EXTERNAL_LOCK (1 << 1) +#define HA_PT_CALL_AT_ONCE_START_STMT (1 << 2) +#define HA_PT_CALL_AT_ONCE_EXTRA (1 << 3) +#define HA_PT_CALL_AT_ONCE_COND_PUSH (1 << 4) +#define HA_PT_CALL_AT_ONCE_INFO_PUSH (1 << 5) +#define HA_PT_CALL_AT_ONCE_TOP_TABLE (1 << 6) + /* bits in alter_table_flags: */ @@ -3904,6 +3913,7 @@ public: } virtual void set_part_info(partition_info *part_info) {return;} virtual void return_record_by_parent() { return; } + virtual ulong table_flags_for_partition() { return 0; }; virtual ulong index_flags(uint idx, uint part, bool all_parts) const =0; diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index c892bd8828c..80ffbc80b3c 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -75,11 +75,8 @@ ha_spider::ha_spider( spider_alloc_calc_mem_init(mem_calc, 139); spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); share = NULL; - trx = NULL; conns = NULL; need_mons = NULL; - condition = NULL; - cond_check = FALSE; blob_buff = NULL; conn_keys = NULL; spider_thread_id = 0; @@ -89,10 +86,9 @@ ha_spider::ha_spider( trx_hs_w_conn_adjustment = 0; #endif search_link_query_id = 0; - searched_bitmap = NULL; #ifdef WITH_PARTITION_STORAGE_ENGINE partition_handler_share = NULL; - pt_handler_share_creator = NULL; + pt_handler_share_owner = FALSE; #endif #ifdef HA_MRR_USE_DEFAULT_IMPL multi_range_keys = NULL; @@ -101,7 +97,6 @@ ha_spider::ha_spider( append_tblnm_alias = NULL; use_index_merge = FALSE; is_clone = FALSE; - clone_bitmap_init = FALSE; pt_clone_source_handler = NULL; pt_clone_last_searcher = NULL; ft_handler = NULL; @@ -115,6 +110,7 @@ ha_spider::ha_spider( #ifdef SPIDER_HAS_GROUP_BY_HANDLER use_fields = FALSE; #endif + dml_inited = FALSE; use_pre_call = FALSE; use_pre_records = FALSE; #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS @@ -127,10 +123,6 @@ ha_spider::ha_spider( hs_decrement = FALSE; hs_pushed_strref_num = 0; #endif - direct_update_fields = NULL; -#endif -#ifdef INFO_KIND_FORCE_LIMIT_BEGIN - info_limit = 9223372036854775807LL; #endif #ifdef HA_CAN_BULK_ACCESS is_bulk_access_clone = FALSE; @@ -187,11 +179,8 @@ ha_spider::ha_spider( spider_alloc_calc_mem_init(mem_calc, 0); spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); share = NULL; - trx = NULL; conns = NULL; need_mons = NULL; - condition = NULL; - cond_check = FALSE; blob_buff = NULL; conn_keys = NULL; spider_thread_id = 0; @@ -201,10 +190,9 @@ ha_spider::ha_spider( trx_hs_w_conn_adjustment = 0; #endif search_link_query_id = 0; - searched_bitmap = NULL; #ifdef WITH_PARTITION_STORAGE_ENGINE partition_handler_share = NULL; - pt_handler_share_creator = NULL; + pt_handler_share_owner = FALSE; #endif #ifdef HA_MRR_USE_DEFAULT_IMPL multi_range_keys = NULL; @@ -213,7 +201,6 @@ ha_spider::ha_spider( append_tblnm_alias = NULL; use_index_merge = FALSE; is_clone = FALSE; - clone_bitmap_init = FALSE; pt_clone_source_handler = NULL; pt_clone_last_searcher = NULL; ft_handler = NULL; @@ -227,6 +214,7 @@ ha_spider::ha_spider( #ifdef SPIDER_HAS_GROUP_BY_HANDLER use_fields = FALSE; #endif + dml_inited = FALSE; use_pre_call = FALSE; use_pre_records = FALSE; #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS @@ -239,10 +227,6 @@ ha_spider::ha_spider( hs_decrement = FALSE; hs_pushed_strref_num = 0; #endif - direct_update_fields = NULL; -#endif -#ifdef INFO_KIND_FORCE_LIMIT_BEGIN - info_limit = 9223372036854775807LL; #endif #ifdef HA_CAN_BULK_ACCESS is_bulk_access_clone = FALSE; @@ -294,6 +278,19 @@ ha_spider::~ha_spider() { DBUG_ENTER("ha_spider::~ha_spider"); DBUG_PRINT("info",("spider this=%p", this)); +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (pt_handler_share_owner) + { + spider_free(spider_current_trx, partition_handler_share, MYF(0)); + pt_handler_share_owner = FALSE; + } + partition_handler_share = NULL; +#endif + if (wide_handler_owner) + { + spider_free(spider_current_trx, wide_handler, MYF(0)); + } + wide_handler = NULL; spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); DBUG_VOID_RETURN; } @@ -339,14 +336,16 @@ int ha_spider::open( THD *thd = ha_thd(); int error_num, roop_count; int init_sql_alloc_size; + ha_spider *spider, *owner; + bool wide_handler_alloc = FALSE; + SPIDER_WIDE_SHARE *wide_share; #ifdef WITH_PARTITION_STORAGE_ENGINE - SPIDER_PARTITION_SHARE *partition_share; - uchar *idx_read_bitmap, *idx_write_bitmap, - *rnd_read_bitmap, *rnd_write_bitmap; uint part_num; - bool create_pt_handler_share = FALSE, pt_handler_mutex = FALSE, - may_be_clone = FALSE; - ha_spider **pt_handler_share_handlers; + bool pt_handler_share_alloc = FALSE; + bool pt_handler_mutex = FALSE; + ha_spider **pt_handler_share_handlers = NULL; + ha_partition *clone_source; + ha_spider *pt_handler_share_key; #ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value; #endif @@ -356,148 +355,148 @@ int ha_spider::open( dup_key_idx = (uint) -1; conn_kinds = SPIDER_CONN_KIND_MYSQL; - if (!spider_get_share(name, table, thd, this, &error_num)) - goto error_get_share; - thr_lock_data_init(&share->lock,&lock,NULL); - #ifdef WITH_PARTITION_STORAGE_ENGINE - partition_share = share->partition_share; table->file->get_no_parts("", &part_num); - if (partition_share) + if (part_num) { - pt_handler_mutex = TRUE; - pthread_mutex_lock(&partition_share->pt_handler_mutex); -/* - if ( - !partition_share->partition_handler_share || - partition_share->partition_handler_share->table != table - ) - create_pt_handler_share = TRUE; -*/ -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - hash_value = my_calc_hash(&partition_share->pt_handler_hash, - (uchar*) &table, sizeof(TABLE *)); - if (!(partition_handler_share = (SPIDER_PARTITION_HANDLER_SHARE*) - my_hash_search_using_hash_value(&partition_share->pt_handler_hash, - hash_value, (uchar*) &table, sizeof(TABLE *)))) -#else - if (!(partition_handler_share = (SPIDER_PARTITION_HANDLER_SHARE*) - my_hash_search(&partition_share->pt_handler_hash, (uchar*) &table, - sizeof(TABLE *)))) -#endif + pt_handler_share_handlers = + (ha_spider **) ((ha_partition *) table->file)->get_child_handlers(); + spider = pt_handler_share_handlers[0]; + owner = pt_handler_share_handlers[part_num - 1]; + clone_source = ((ha_partition *) table->file)->get_clone_source(); + if (clone_source) { - create_pt_handler_share = TRUE; + pt_handler_share_key = (ha_spider *) + clone_source->get_child_handlers()[0]; + is_clone = TRUE; + } else { + pt_handler_share_key = spider; } - } - - if (create_pt_handler_share) - { - if (!(searched_bitmap = (uchar *) - spider_bulk_malloc(spider_current_trx, 15, MYF(MY_WME), + } else { +#endif + spider = this; + owner = this; +#ifdef WITH_PARTITION_STORAGE_ENGINE + clone_source = NULL; + pt_handler_share_key = this; + } +#endif + if (!spider->wide_handler) + { + uchar *searched_bitmap; + uchar *ft_discard_bitmap; + uchar *position_bitmap; + uchar *idx_read_bitmap; + uchar *idx_write_bitmap; + uchar *rnd_read_bitmap; + uchar *rnd_write_bitmap; + if (!(wide_handler = (SPIDER_WIDE_HANDLER *) + spider_bulk_malloc(spider_current_trx, 16, MYF(MY_WME | MY_ZEROFILL), + &wide_handler, sizeof(SPIDER_WIDE_HANDLER), &searched_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), &ft_discard_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), &position_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), - &partition_handler_share, sizeof(SPIDER_PARTITION_HANDLER_SHARE), &idx_read_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), &idx_write_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), &rnd_read_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), &rnd_write_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), - &pt_handler_share_handlers, sizeof(ha_spider *) * part_num, NullS)) ) { error_num = HA_ERR_OUT_OF_MEM; - goto error_searched_bitmap_alloc; - } - DBUG_PRINT("info",("spider create partition_handler_share")); - partition_handler_share->use_count = 1; -/* - if (partition_handler_share->use_count < part_num) - partition_share->partition_handler_share = partition_handler_share; -*/ - DBUG_PRINT("info",("spider table=%p", table)); - partition_handler_share->table = table; - partition_handler_share->searched_bitmap = NULL; - partition_handler_share->ft_discard_bitmap = NULL; - partition_handler_share->idx_read_bitmap = idx_read_bitmap; - partition_handler_share->idx_write_bitmap = idx_write_bitmap; - partition_handler_share->rnd_read_bitmap = rnd_read_bitmap; - partition_handler_share->rnd_write_bitmap = rnd_write_bitmap; - partition_handler_share->between_flg = FALSE; - partition_handler_share->idx_bitmap_is_set = FALSE; - partition_handler_share->rnd_bitmap_is_set = FALSE; - partition_handler_share->table_hash_value = hash_value; - partition_handler_share->creator = this; - partition_handler_share->parallel_search_query_id = 0; - pt_handler_share_creator = this; - if (part_num) - { - partition_handler_share->handlers = (void **) pt_handler_share_handlers; - partition_handler_share->handlers[0] = this; - } else - partition_handler_share->handlers = NULL; - uint old_elements = partition_share->pt_handler_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&partition_share->pt_handler_hash, - hash_value, (uchar*) partition_handler_share)) + goto error_wide_handler_alloc; + } + spider->wide_handler = wide_handler; + owner->wide_handler = wide_handler; + wide_handler->searched_bitmap = searched_bitmap; + wide_handler->ft_discard_bitmap = ft_discard_bitmap; + wide_handler->position_bitmap = position_bitmap; + wide_handler->idx_read_bitmap = idx_read_bitmap; + wide_handler->idx_write_bitmap = idx_write_bitmap; + wide_handler->rnd_read_bitmap = rnd_read_bitmap; + wide_handler->rnd_write_bitmap = rnd_write_bitmap; + wide_handler->owner = owner; + owner->wide_handler_owner = TRUE; + memset(wide_handler->ft_discard_bitmap, 0xFF, + no_bytes_in_map(table->read_set)); + memset(wide_handler->searched_bitmap, 0, + no_bytes_in_map(table->read_set)); + wide_handler_alloc = TRUE; + } else { + wide_handler = spider->wide_handler; + } + if (!share && !spider_get_share(name, table, thd, this, &error_num)) + goto error_get_share; + + wide_share = share->wide_share; + if (wide_handler_alloc) + { + thr_lock_data_init(&wide_share->lock, &wide_handler->lock, NULL); + } + +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (!wide_handler->partition_handler_share) + { + pt_handler_mutex = TRUE; + pthread_mutex_lock(&wide_share->pt_handler_mutex); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + hash_value = my_calc_hash(&wide_share->pt_handler_hash, + (uchar*) pt_handler_share_key, sizeof(ha_spider *)); + if (!(partition_handler_share = (SPIDER_PARTITION_HANDLER_SHARE*) + my_hash_search_using_hash_value(&wide_share->pt_handler_hash, + hash_value, (uchar*) pt_handler_share_key, sizeof(ha_spider *)))) #else - if (my_hash_insert(&partition_share->pt_handler_hash, - (uchar*) partition_handler_share)) + if (!(partition_handler_share = (SPIDER_PARTITION_HANDLER_SHARE*) + my_hash_search(&wide_share->pt_handler_hash, + (uchar*) pt_handler_share_key, sizeof(ha_spider *)))) #endif { - error_num = HA_ERR_OUT_OF_MEM; - goto error_hash_insert; - } - if (partition_share->pt_handler_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - partition_share->pt_handler_hash, - (partition_share->pt_handler_hash.array.max_element - old_elements) * - partition_share->pt_handler_hash.array.size_of_element); - } - pthread_mutex_unlock(&partition_share->pt_handler_mutex); - pt_handler_mutex = FALSE; - } else { + if (!(partition_handler_share = (SPIDER_PARTITION_HANDLER_SHARE *) + spider_bulk_malloc(spider_current_trx, 15, MYF(MY_WME | MY_ZEROFILL), + &partition_handler_share, sizeof(SPIDER_PARTITION_HANDLER_SHARE), + NullS)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_partition_handler_share_alloc; + } + DBUG_PRINT("info",("spider create partition_handler_share")); + DBUG_PRINT("info",("spider table=%p", table)); + partition_handler_share->table = table; + partition_handler_share->table_hash_value = hash_value; + partition_handler_share->no_parts = part_num; + partition_handler_share->owner = owner; + partition_handler_share->parallel_search_query_id = 0; + spider->partition_handler_share = partition_handler_share; + owner->partition_handler_share = partition_handler_share; + owner->pt_handler_share_owner = TRUE; + partition_handler_share->handlers = pt_handler_share_handlers; + uint old_elements = wide_share->pt_handler_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&wide_share->pt_handler_hash, + hash_value, (uchar*) partition_handler_share)) +#else + if (my_hash_insert(&wide_share->pt_handler_hash, + (uchar*) partition_handler_share)) #endif - if (!(searched_bitmap = (uchar *) - spider_bulk_malloc(spider_current_trx, 16, MYF(MY_WME), - &searched_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), - &ft_discard_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), - &position_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), - NullS)) - ) { - error_num = HA_ERR_OUT_OF_MEM; - goto error_searched_bitmap_alloc; - } -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (partition_share) - { - DBUG_PRINT("info",("spider copy partition_handler_share")); -/* - partition_handler_share = (SPIDER_PARTITION_HANDLER_SHARE *) - partition_share->partition_handler_share; -*/ - if (part_num) { - if (partition_handler_share->use_count >= part_num) - may_be_clone = TRUE; - else { - partition_handler_share->handlers[ - partition_handler_share->use_count] = this; - partition_handler_share->use_count++; - } + error_num = HA_ERR_OUT_OF_MEM; + goto error_hash_insert; + } + if (wide_share->pt_handler_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + wide_share->pt_handler_hash, + (wide_share->pt_handler_hash.array.max_element - + old_elements) * + wide_share->pt_handler_hash.array.size_of_element); } -/* - if (partition_handler_share->use_count == part_num) - partition_share->partition_handler_share = NULL; -*/ - pthread_mutex_unlock(&partition_share->pt_handler_mutex); - pt_handler_mutex = FALSE; } + pthread_mutex_unlock(&wide_share->pt_handler_mutex); + pt_handler_mutex = FALSE; + pt_handler_share_alloc = TRUE; + } else { + partition_handler_share = wide_handler->partition_handler_share; } #endif - memset(ft_discard_bitmap, 0xFF, no_bytes_in_map(table->read_set)); - memset(searched_bitmap, 0, no_bytes_in_map(table->read_set)); - init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); @@ -556,10 +555,6 @@ int ha_spider::open( } } -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (may_be_clone && thd_sql_command(thd) != SQLCOM_ALTER_TABLE) - is_clone = TRUE; -#endif if (is_clone) { #ifdef WITH_PARTITION_STORAGE_ENGINE @@ -567,28 +562,38 @@ int ha_spider::open( { for (roop_count = 0; roop_count < (int) part_num; roop_count++) { - if (((ha_spider *) partition_handler_share->handlers[roop_count])-> - share == share) + if (partition_handler_share->handlers[roop_count]->share == share) { pt_clone_source_handler = - (ha_spider *) partition_handler_share->handlers[roop_count]; + partition_handler_share->handlers[roop_count]; break; } } } #endif - sql_command = pt_clone_source_handler->sql_command; - result_list.lock_type = pt_clone_source_handler->result_list.lock_type; - lock_mode = pt_clone_source_handler->lock_mode; + wide_handler->external_lock_type = + pt_clone_source_handler->wide_handler->external_lock_type; - if (!pt_clone_source_handler->clone_bitmap_init) + if (wide_handler_alloc) + { + wide_handler->lock_mode = + pt_clone_source_handler->wide_handler->lock_mode; + if (!partition_handler_share->clone_bitmap_init) + { + pt_clone_source_handler->set_select_column_mode(); + partition_handler_share->clone_bitmap_init = TRUE; + } + set_clone_searched_bitmap(); + wide_handler->position_bitmap_init = FALSE; + wide_handler->sql_command = + pt_clone_source_handler->wide_handler->sql_command; + } + } else { + if (share->semi_table_lock) { - pt_clone_source_handler->set_select_column_mode(); - pt_clone_source_handler->clone_bitmap_init = TRUE; + wide_handler->semi_table_lock = TRUE; } - set_clone_searched_bitmap(); - position_bitmap_init = FALSE; } #ifdef HA_CAN_BULK_ACCESS external_lock_cnt = 0; @@ -608,50 +613,55 @@ error_reset: error_init_blob_buff: error_init_result_list: #ifdef WITH_PARTITION_STORAGE_ENGINE - if ( - partition_handler_share && - pt_handler_share_creator == this - ) { - partition_share = share->partition_share; +error_hash_insert: + if (pt_handler_share_alloc) + { + wide_share = share->wide_share; if (!pt_handler_mutex) - pthread_mutex_lock(&partition_share->pt_handler_mutex); -/* - if (partition_share->partition_handler_share == partition_handler_share) - partition_share->partition_handler_share = NULL; -*/ + pthread_mutex_lock(&wide_share->pt_handler_mutex); #ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&partition_share->pt_handler_hash, + my_hash_delete_with_hash_value(&wide_share->pt_handler_hash, partition_handler_share->table_hash_value, (uchar*) partition_handler_share); #else - my_hash_delete(&partition_share->pt_handler_hash, + my_hash_delete(&wide_share->pt_handler_hash, (uchar*) partition_handler_share); #endif - pthread_mutex_unlock(&partition_share->pt_handler_mutex); + pthread_mutex_unlock(&wide_share->pt_handler_mutex); pt_handler_mutex = FALSE; + spider_free(spider_current_trx, partition_handler_share, MYF(0)); + spider->partition_handler_share = NULL; + owner->partition_handler_share = NULL; + owner->pt_handler_share_owner = FALSE; } -error_hash_insert: - partition_handler_share = NULL; - pt_handler_share_creator = NULL; -#endif - if (searched_bitmap) - { - spider_free(spider_current_trx, searched_bitmap, MYF(0)); - searched_bitmap = NULL; - } -error_searched_bitmap_alloc: -#ifdef WITH_PARTITION_STORAGE_ENGINE +error_partition_handler_share_alloc: if (pt_handler_mutex) - pthread_mutex_unlock(&partition_share->pt_handler_mutex); + pthread_mutex_unlock(&wide_share->pt_handler_mutex); + partition_handler_share = NULL; #endif spider_free_share(share); share = NULL; -error_get_share: if (conn_keys) { spider_free(spider_current_trx, conn_keys, MYF(0)); conn_keys = NULL; } +error_get_share: + if (wide_handler_alloc) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (pt_handler_share_handlers) + { + pt_handler_share_handlers[0]->wide_handler = NULL; + } +#endif + spider_free(spider_current_trx, wide_handler, MYF(0)); + spider->wide_handler = NULL; + owner->wide_handler = NULL; + owner->wide_handler_owner = FALSE; + } + wide_handler = NULL; +error_wide_handler_alloc: DBUG_RETURN(error_num); } @@ -659,9 +669,7 @@ int ha_spider::close() { int error_num = 0, roop_count, error_num2; THD *thd = ha_thd(); -#ifdef WITH_PARTITION_STORAGE_ENGINE - SPIDER_PARTITION_SHARE *partition_share; -#endif + SPIDER_WIDE_SHARE *wide_share; backup_error_status(); DBUG_ENTER("ha_spider::close"); DBUG_PRINT("info",("spider this=%p", this)); @@ -687,8 +695,8 @@ int ha_spider::close() bulk_access_link_first->spider)); DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", bulk_access_link_first->spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &bulk_access_link_first->spider->dbton_handler)); + DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=" + "%p", &bulk_access_link_first->spider->dbton_handler)); bulk_access_link_current = bulk_access_link_first->next; delete_bulk_access_link(bulk_access_link_first); bulk_access_link_first = bulk_access_link_current; @@ -751,34 +759,30 @@ int ha_spider::close() conn_keys = NULL; } #ifdef WITH_PARTITION_STORAGE_ENGINE - if ( - partition_handler_share && - pt_handler_share_creator == this - ) { - partition_share = share->partition_share; - pthread_mutex_lock(&partition_share->pt_handler_mutex); -/* - if (partition_share->partition_handler_share == partition_handler_share) - partition_share->partition_handler_share = NULL; -*/ + if (pt_handler_share_owner) + { + wide_share = share->wide_share; + pthread_mutex_lock(&wide_share->pt_handler_mutex); #ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&partition_share->pt_handler_hash, + my_hash_delete_with_hash_value(&wide_share->pt_handler_hash, partition_handler_share->table_hash_value, (uchar*) partition_handler_share); #else - my_hash_delete(&partition_share->pt_handler_hash, + my_hash_delete(&wide_share->pt_handler_hash, (uchar*) partition_handler_share); #endif - pthread_mutex_unlock(&partition_share->pt_handler_mutex); + pthread_mutex_unlock(&wide_share->pt_handler_mutex); + spider_free(spider_current_trx, partition_handler_share, MYF(0)); + pt_handler_share_owner = FALSE; } partition_handler_share = NULL; - pt_handler_share_creator = NULL; #endif - if (searched_bitmap) + if (wide_handler_owner) { - spider_free(spider_current_trx, searched_bitmap, MYF(0)); - searched_bitmap = NULL; + spider_free(spider_current_trx, wide_handler, MYF(0)); + wide_handler_owner = FALSE; } + wide_handler = NULL; if (blob_buff) { delete [] blob_buff; @@ -823,34 +827,23 @@ int ha_spider::close() } #endif #endif -#ifdef HA_CAN_BULK_ACCESS -/* - if (init_ha_mem_root) - { - free_root(&ha_mem_root, MYF(0)); - init_ha_mem_root = FALSE; - } -*/ -#endif is_clone = FALSE; pt_clone_source_handler = NULL; share = NULL; - trx = NULL; conns = NULL; DBUG_RETURN(error_num); } -int ha_spider::check_access_kind( +int ha_spider::check_access_kind_for_connection( THD *thd, bool write_request ) { int error_num, roop_count; - DBUG_ENTER("ha_spider::check_access_kind"); + DBUG_ENTER("ha_spider::check_access_kind_for_connection"); DBUG_PRINT("info",("spider this=%p", this)); - sql_command = thd_sql_command(thd); conn_kinds = 0; - switch (sql_command) + switch (wide_handler->sql_command) { #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) case SQLCOM_HS_READ: @@ -952,33 +945,60 @@ int ha_spider::check_access_kind( { DBUG_RETURN(error_num); } - DBUG_PRINT("info",("spider sql_command=%u", sql_command)); + DBUG_PRINT("info",("spider wide_handler->semi_trx_isolation_chk = %s", + wide_handler->semi_trx_isolation_chk ? "TRUE" : "FALSE")); + if (wide_handler->semi_trx_isolation_chk) + { + SPIDER_SET_CONNS_PARAM(semi_trx_isolation_chk, TRUE, conns, + share->link_statuses, conn_link_idx, (int) share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + } + DBUG_PRINT("info",("spider wide_handler->semi_trx_chk = %s", + wide_handler->semi_trx_chk ? "TRUE" : "FALSE")); + if (wide_handler->semi_trx_chk) + { + SPIDER_SET_CONNS_PARAM(semi_trx_chk, TRUE, conns, share->link_statuses, + conn_link_idx, (int) share->link_count, SPIDER_LINK_STATUS_RECOVERY); + } else { + SPIDER_SET_CONNS_PARAM(semi_trx_chk, FALSE, conns, share->link_statuses, + conn_link_idx, (int) share->link_count, SPIDER_LINK_STATUS_RECOVERY); + } + DBUG_RETURN(0); +} + +void ha_spider::check_access_kind( + THD *thd +) { + DBUG_ENTER("ha_spider::check_access_kind"); + DBUG_PRINT("info",("spider this=%p", this)); + wide_handler->sql_command = thd_sql_command(thd); + DBUG_PRINT("info",("spider sql_command=%u", wide_handler->sql_command)); DBUG_PRINT("info",("spider thd->query_id=%lld", thd->query_id)); #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HS_HAS_SQLCOM - if (sql_command == SQLCOM_HS_UPDATE) - update_request = TRUE; + if (wide_handler->sql_command == SQLCOM_HS_UPDATE) + wide_handler->update_request = TRUE; else #endif - update_request = FALSE; + wide_handler->update_request = FALSE; #else if ( #ifdef HS_HAS_SQLCOM - sql_command == SQLCOM_HS_UPDATE || + wide_handler->sql_command == SQLCOM_HS_UPDATE || #endif - sql_command == SQLCOM_UPDATE || - sql_command == SQLCOM_UPDATE_MULTI || + wide_handler->sql_command == SQLCOM_UPDATE || + wide_handler->sql_command == SQLCOM_UPDATE_MULTI || /* for triggers */ - sql_command == SQLCOM_INSERT || - sql_command == SQLCOM_INSERT_SELECT || - sql_command == SQLCOM_DELETE || - sql_command == SQLCOM_DELETE_MULTI + wide_handler->sql_command == SQLCOM_INSERT || + wide_handler->sql_command == SQLCOM_INSERT_SELECT || + wide_handler->sql_command == SQLCOM_DELETE || + wide_handler->sql_command == SQLCOM_DELETE_MULTI ) - update_request = TRUE; + wide_handler->update_request = TRUE; else - update_request = FALSE; + wide_handler->update_request = FALSE; #endif - DBUG_RETURN(0); + DBUG_VOID_RETURN; } #ifdef HA_CAN_BULK_ACCESS @@ -992,14 +1012,20 @@ int ha_spider::additional_lock( { if (is_bulk_access_clone) { - DBUG_RETURN(check_access_kind(thd, (lock_type >= TL_WRITE_ALLOW_WRITE))); + check_access_kind(thd); + DBUG_RETURN(check_access_kind_for_connection(thd, + (lock_type >= TL_WRITE_ALLOW_WRITE))); } else if (bulk_access_link_exec_tgt->called) { - DBUG_RETURN(bulk_access_link_exec_tgt->spider->check_access_kind( - thd, (lock_type >= TL_WRITE_ALLOW_WRITE))); + bulk_access_link_exec_tgt->spider->check_access_kind(thd); + DBUG_RETURN(bulk_access_link_exec_tgt->spider-> + check_access_kind_for_connection( + thd, (lock_type >= TL_WRITE_ALLOW_WRITE))); } } - DBUG_RETURN(check_access_kind(thd, (lock_type >= TL_WRITE_ALLOW_WRITE))); + check_access_kind(thd); + DBUG_RETURN(check_access_kind_for_connection(thd, + (lock_type >= TL_WRITE_ALLOW_WRITE))); } #endif @@ -1008,53 +1034,27 @@ THR_LOCK_DATA **ha_spider::store_lock( THR_LOCK_DATA **to, enum thr_lock_type lock_type ) { - int error_num, roop_count; DBUG_ENTER("ha_spider::store_lock"); DBUG_PRINT("info",("spider this=%p", this)); + wide_handler->lock_table_type = 0; if (lock_type == TL_IGNORE) { - *to++ = &lock; + *to++ = &wide_handler->lock; DBUG_RETURN(to); } - if ((error_num = check_access_kind(thd, - (lock_type >= TL_WRITE_ALLOW_WRITE)))) - { - store_error_num = error_num; - DBUG_RETURN(to); - } - DBUG_PRINT("info",("spider sql_command=%u", sql_command)); + check_access_kind(thd); + DBUG_PRINT("info",("spider sql_command=%u", wide_handler->sql_command)); DBUG_PRINT("info",("spider lock_type=%d", lock_type)); DBUG_PRINT("info",("spider thd->query_id=%lld", thd->query_id)); - if (sql_command == SQLCOM_ALTER_TABLE) - { - if (trx->query_id != thd->query_id) - { - spider_free_trx_alter_table(trx); - trx->query_id = thd->query_id; - trx->tmp_flg = FALSE; - } - if (!(SPIDER_ALTER_TABLE*) my_hash_search(&trx->trx_alter_table_hash, - (uchar*) share->table_name, share->table_name_length)) - { - if (spider_create_trx_alter_table(trx, share, FALSE)) - { - store_error_num = HA_ERR_OUT_OF_MEM; - DBUG_RETURN(to); - } - } - } - this->lock_type = lock_type; - selupd_lock_mode = spider_param_selupd_lock_mode(thd, - share->selupd_lock_mode); + wide_handler->lock_type = lock_type; if ( - sql_command != SQLCOM_DROP_TABLE && - sql_command != SQLCOM_ALTER_TABLE + wide_handler->sql_command != SQLCOM_DROP_TABLE && + wide_handler->sql_command != SQLCOM_ALTER_TABLE ) { - SPIDER_SET_CONNS_PARAM(semi_trx_chk, FALSE, conns, share->link_statuses, - conn_link_idx, (int) share->link_count, SPIDER_LINK_STATUS_RECOVERY); + wide_handler->semi_trx_chk = FALSE; } - switch (sql_command) + switch (wide_handler->sql_command) { case SQLCOM_SELECT: case SQLCOM_HA_READ: @@ -1062,17 +1062,14 @@ THR_LOCK_DATA **ha_spider::store_lock( case SQLCOM_HS_READ: #endif if (lock_type == TL_READ_WITH_SHARED_LOCKS) - lock_mode = 1; + wide_handler->lock_mode = 1; else if (lock_type <= TL_READ_NO_INSERT) { - lock_mode = 0; - SPIDER_SET_CONNS_PARAM(semi_trx_isolation_chk, TRUE, conns, - share->link_statuses, conn_link_idx, (int) share->link_count, - SPIDER_LINK_STATUS_RECOVERY); + wide_handler->lock_mode = 0; + wide_handler->semi_trx_isolation_chk = TRUE; } else - lock_mode = -1; - SPIDER_SET_CONNS_PARAM(semi_trx_chk, TRUE, conns, share->link_statuses, - conn_link_idx, (int) share->link_count, SPIDER_LINK_STATUS_RECOVERY); + wide_handler->lock_mode = -1; + wide_handler->semi_trx_chk = TRUE; break; case SQLCOM_UPDATE: case SQLCOM_UPDATE_MULTI: @@ -1093,39 +1090,37 @@ THR_LOCK_DATA **ha_spider::store_lock( #endif if (lock_type >= TL_READ && lock_type <= TL_READ_NO_INSERT) { - lock_mode = selupd_lock_mode; - SPIDER_SET_CONNS_PARAM(semi_trx_isolation_chk, TRUE, conns, - share->link_statuses, conn_link_idx, (int) share->link_count, - SPIDER_LINK_STATUS_RECOVERY); + wide_handler->lock_mode = -2; + wide_handler->semi_trx_isolation_chk = TRUE; } else - lock_mode = -1; - SPIDER_SET_CONNS_PARAM(semi_trx_chk, TRUE, conns, share->link_statuses, - conn_link_idx, (int) share->link_count, SPIDER_LINK_STATUS_RECOVERY); + wide_handler->lock_mode = -1; + wide_handler->semi_trx_chk = TRUE; break; default: - lock_mode = -1; + wide_handler->lock_mode = -1; } switch (lock_type) { case TL_READ_HIGH_PRIORITY: - high_priority = TRUE; + wide_handler->high_priority = TRUE; break; case TL_WRITE_DELAYED: - insert_delayed = TRUE; + wide_handler->insert_delayed = TRUE; break; case TL_WRITE_LOW_PRIORITY: - low_priority = TRUE; + wide_handler->low_priority = TRUE; break; default: break; } - if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) + if (wide_handler->lock_type != TL_IGNORE && + wide_handler->lock.type == TL_UNLOCK) { if ( - sql_command == SQLCOM_DROP_TABLE || - sql_command == SQLCOM_ALTER_TABLE || - sql_command == SQLCOM_SHOW_CREATE + wide_handler->sql_command == SQLCOM_DROP_TABLE || + wide_handler->sql_command == SQLCOM_ALTER_TABLE || + wide_handler->sql_command == SQLCOM_SHOW_CREATE ) { if ( lock_type == TL_READ_NO_INSERT && @@ -1138,80 +1133,36 @@ THR_LOCK_DATA **ha_spider::store_lock( ) lock_type = TL_WRITE_ALLOW_WRITE; } else if ( - sql_command == SQLCOM_LOCK_TABLES || - (spider_param_lock_exchange(thd) == 1 && share->semi_table_lock)) + wide_handler->sql_command == SQLCOM_LOCK_TABLES || + (spider_param_lock_exchange(thd) == 1 && wide_handler->semi_table_lock)) { DBUG_PRINT("info",("spider lock exchange route")); - DBUG_PRINT("info",("spider lock_type=%u", this->lock_type)); + DBUG_PRINT("info",("spider lock_type=%u", wide_handler->lock_type)); if ( ( - this->lock_type == TL_READ || - this->lock_type == TL_READ_NO_INSERT || - this->lock_type == TL_WRITE_LOW_PRIORITY || - this->lock_type == TL_WRITE + wide_handler->lock_type == TL_READ || + wide_handler->lock_type == TL_READ_NO_INSERT || + wide_handler->lock_type == TL_WRITE_LOW_PRIORITY || + wide_handler->lock_type == TL_WRITE ) && !spider_param_local_lock_table(thd) ) { - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - SPIDER_CONN *conn = conns[roop_count]; - int appended = 0; - if ((error_num = dbton_handler[conn->dbton_id]-> - append_lock_tables_list(conn, roop_count, &appended))) - { - store_error_num = error_num; - DBUG_RETURN(to); - } - if (appended) - { - conn->table_lock = 2; - } - } + wide_handler->lock_table_type = 1; } } else { DBUG_PRINT("info",("spider default lock route")); - DBUG_PRINT("info",("spider lock_type=%u", this->lock_type)); + DBUG_PRINT("info",("spider lock_type=%u", wide_handler->lock_type)); if ( - this->lock_type == TL_READ || - this->lock_type == TL_READ_NO_INSERT || - this->lock_type == TL_WRITE_LOW_PRIORITY || - this->lock_type == TL_WRITE + wide_handler->lock_type == TL_READ || + wide_handler->lock_type == TL_READ_NO_INSERT || + wide_handler->lock_type == TL_WRITE_LOW_PRIORITY || + wide_handler->lock_type == TL_WRITE ) { - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) + if ( + !spider_param_local_lock_table(thd) && + spider_param_semi_table_lock(thd, wide_handler->semi_table_lock) ) { - if ( - conns[roop_count] && - conns[roop_count]->table_lock != 1 && - spider_param_semi_table_lock(thd, share->semi_table_lock) && - !spider_param_local_lock_table(thd) - ) { - SPIDER_CONN *conn = conns[roop_count]; - int appended = 0; - if ((error_num = dbton_handler[conn->dbton_id]-> - append_lock_tables_list(conn, roop_count, &appended))) - { - store_error_num = error_num; - DBUG_RETURN(to); - } - if (appended) - { - conn->table_lock = 3; - } - } + wide_handler->lock_table_type = 2; } } if ( @@ -1226,9 +1177,9 @@ THR_LOCK_DATA **ha_spider::store_lock( ) lock_type = TL_WRITE_ALLOW_WRITE; } - lock.type = lock_type; + wide_handler->lock.type = lock_type; } - *to++ = &lock; + *to++ = &wide_handler->lock; DBUG_RETURN(to); } @@ -1236,8 +1187,8 @@ int ha_spider::external_lock( THD *thd, int lock_type ) { - int error_num, roop_count; - bool sync_trx_isolation = spider_param_sync_trx_isolation(thd); + int error_num = 0; + SPIDER_TRX *trx; backup_error_status(); DBUG_ENTER("ha_spider::external_lock"); DBUG_PRINT("info",("spider this=%p", this)); @@ -1249,37 +1200,35 @@ int ha_spider::external_lock( info_auto_called = FALSE; #endif - sql_command = thd_sql_command(thd); - if (sql_command == SQLCOM_BEGIN) - sql_command = SQLCOM_UNLOCK_TABLES; - if ( - sql_command == SQLCOM_UNLOCK_TABLES && - (error_num = spider_check_trx_and_get_conn(thd, this, - FALSE)) - ) { + wide_handler->sql_command = thd_sql_command(thd); + if (wide_handler->sql_command == SQLCOM_BEGIN) + wide_handler->sql_command = SQLCOM_UNLOCK_TABLES; + + trx = spider_get_trx(thd, TRUE, &error_num); + if (error_num) DBUG_RETURN(error_num); - } + wide_handler->trx = trx; - DBUG_PRINT("info",("spider sql_command=%d", sql_command)); - DBUG_ASSERT(trx == spider_get_trx(thd, TRUE, &error_num)); + DBUG_PRINT("info",("spider sql_command=%d", wide_handler->sql_command)); #ifdef HA_CAN_BULK_ACCESS - external_lock_cnt++; + wide_handler->external_lock_cnt++; #endif if ( lock_type == F_UNLCK && - sql_command != SQLCOM_UNLOCK_TABLES + wide_handler->sql_command != SQLCOM_UNLOCK_TABLES ) DBUG_RETURN(0); if (store_error_num) DBUG_RETURN(store_error_num); + wide_handler->external_lock_type = lock_type; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) if ((conn_kinds & SPIDER_CONN_KIND_MYSQL)) { #endif if ( /* SQLCOM_RENAME_TABLE and SQLCOM_DROP_DB don't come here */ - sql_command == SQLCOM_DROP_TABLE || - sql_command == SQLCOM_ALTER_TABLE + wide_handler->sql_command == SQLCOM_DROP_TABLE || + wide_handler->sql_command == SQLCOM_ALTER_TABLE ) { if (trx->locked_connections) { @@ -1289,277 +1238,59 @@ int ha_spider::external_lock( } DBUG_RETURN(0); } - if (!conns[search_link_idx]) + if (unlikely((error_num = spider_internal_start_trx(this)))) { - my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, - ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); - DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); - } - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - if (sql_command == SQLCOM_TRUNCATE) - DBUG_RETURN(0); - else if (sql_command != SQLCOM_UNLOCK_TABLES) - { - DBUG_PRINT("info",("spider conns[%d]->join_trx=%u", - roop_count, conns[roop_count]->join_trx)); - if ( - (!conns[roop_count]->join_trx && - (error_num = spider_internal_start_trx(this, conns[roop_count], - roop_count))) - ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode(error_num)); - } - result_list.lock_type = lock_type; - reset_first_link_idx(); - if ( - conns[roop_count]->semi_trx_isolation == -2 && - conns[roop_count]->semi_trx_isolation_chk == TRUE && - sync_trx_isolation && - spider_param_semi_trx_isolation(trx->thd) >= 0 - ) { -/* - if (conns[roop_count]->trx_isolation != - spider_param_semi_trx_isolation(trx->thd)) - { -*/ - spider_conn_queue_semi_trx_isolation(conns[roop_count], - spider_param_semi_trx_isolation(trx->thd)); -/* - } - conns[roop_count]->semi_trx_isolation = - spider_param_semi_trx_isolation(trx->thd); - conns[roop_count]->trx_isolation = - thd_tx_isolation(conns[roop_count]->thd); - DBUG_PRINT("info",("spider conn=%p", conns[roop_count])); - DBUG_PRINT("info",("spider conn->trx_isolation=%d", - conns[roop_count]->trx_isolation)); -*/ - } else { - if (sync_trx_isolation) - { - if ((error_num = spider_check_and_set_trx_isolation( - conns[roop_count], &need_mons[roop_count]))) - { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode(error_num)); - } - } - conns[roop_count]->semi_trx_isolation = -1; - } - } - if (conns[roop_count]->table_lock >= 2) - { - if ( - conns[roop_count]->db_conn->have_lock_table_list() && - (error_num = spider_db_lock_tables(this, roop_count)) - ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - conns[roop_count]->table_lock = 0; - DBUG_RETURN(check_error_mode(error_num)); - } - if (conns[roop_count]->table_lock == 2) - conns[roop_count]->table_lock = 1; - } else if (sql_command == SQLCOM_UNLOCK_TABLES || - spider_param_internal_unlock(thd) == 1) - { - if (conns[roop_count]->table_lock == 1) - { - conns[roop_count]->table_lock = 0; - if (!conns[roop_count]->trx_start) - conns[roop_count]->disable_reconnect = FALSE; - if ((error_num = spider_db_unlock_tables(this, roop_count))) - { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode(error_num)); - } - } - } + DBUG_RETURN(error_num); } #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) } else { - result_list.lock_type = lock_type; - reset_first_link_idx(); trans_register_ha(trx->thd, FALSE, spider_hton_ptr); if (thd_test_options(trx->thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) trans_register_ha(trx->thd, TRUE, spider_hton_ptr); } +#endif - if ((conn_kinds & SPIDER_CONN_KIND_HS_READ)) + if (wide_handler->lock_table_type > 0 || + wide_handler->sql_command == SQLCOM_UNLOCK_TABLES) { - SPIDER_CONN *hs_conn; - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - hs_conn = hs_r_conns[roop_count]; - if ( - hs_conn && - hs_conn->hsc_query_id != thd->query_id && - hs_conn->hs_pre_age == hs_conn->hs_age - ) { - double interval = spider_param_hs_ping_interval(thd); - time_t tmp_time = (time_t) time((time_t*) 0); - DBUG_PRINT("info", - ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); - DBUG_PRINT("info", ("spider interval=%f", interval)); - if ( - hs_conn->server_lost || - difftime(tmp_time, hs_conn->ping_time) >= interval - ) { - DBUG_PRINT("info", ("spider hsr[%d] need reconnect", roop_count)); - hs_conn->hs_pre_age++; - hs_conn->ping_time = tmp_time; + if (wide_handler->sql_command == SQLCOM_UNLOCK_TABLES) + { + /* lock tables does not call reset() */ + /* unlock tables does not call store_lock() */ + wide_handler->lock_table_type = 0; + } + + /* lock/unlock tables */ +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (partition_handler_share && partition_handler_share->handlers) + { + uint roop_count; + for (roop_count = 0; roop_count < partition_handler_share->no_parts; + ++roop_count) + { + if (unlikely((error_num = + partition_handler_share->handlers[roop_count]->lock_tables()))) + { + DBUG_RETURN(error_num); } - hs_conn->hsc_query_id = thd->query_id; } - } - } - if ( -#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) - ( -#endif - conn_kinds & SPIDER_CONN_KIND_HS_WRITE -#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) - ) || - /* for direct_update */ - sql_command == SQLCOM_HS_UPDATE || - sql_command == SQLCOM_HS_DELETE + } else { #endif - ) { - SPIDER_CONN *hs_conn; - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - hs_conn = hs_w_conns[roop_count]; - if ( - hs_conn && - hs_conn->hsc_query_id != thd->query_id && - hs_conn->hs_pre_age == hs_conn->hs_age - ) { - double interval = spider_param_hs_ping_interval(thd); - time_t tmp_time = (time_t) time((time_t*) 0); - DBUG_PRINT("info", - ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); - DBUG_PRINT("info", ("spider interval=%f", interval)); - if ( - hs_conn->server_lost || - difftime(tmp_time, hs_conn->ping_time) >= interval - ) { - DBUG_PRINT("info", ("spider hsw[%d] need reconnect", roop_count)); - hs_conn->hs_pre_age++; - hs_conn->ping_time = tmp_time; - } - hs_conn->hsc_query_id = thd->query_id; + if (unlikely((error_num = lock_tables()))) + { + DBUG_RETURN(error_num); } +#ifdef WITH_PARTITION_STORAGE_ENGINE } - } #endif + } - DBUG_PRINT("info",("spider trx_start=%s", trx->trx_start ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider trx_start=%s", + trx->trx_start ? "TRUE" : "FALSE")); /* need to check after spider_internal_start_trx() */ if (trx->trx_start) { - switch (sql_command) + switch (wide_handler->sql_command) { case SQLCOM_SELECT: case SQLCOM_HA_READ: @@ -1594,6 +1325,14 @@ int ha_spider::external_lock( DBUG_RETURN(0); } +int ha_spider::start_stmt( + THD *thd, + thr_lock_type lock_type +) { + DBUG_ENTER("ha_spider::start_stmt"); + DBUG_RETURN(0); +} + int ha_spider::reset() { int error_num = 0, error_num2, roop_count; @@ -1663,25 +1402,45 @@ int ha_spider::reset() #endif result_list.direct_distinct = FALSE; store_error_num = 0; -#ifdef WITH_PARTITION_STORAGE_ENGINE if ( - partition_handler_share && - partition_handler_share->searched_bitmap + wide_handler && + wide_handler->sql_command != SQLCOM_END ) { + wide_handler->sql_command = SQLCOM_END; + wide_handler->between_flg = FALSE; + wide_handler->idx_bitmap_is_set = FALSE; + wide_handler->rnd_bitmap_is_set = FALSE; + wide_handler->quick_mode = FALSE; + wide_handler->keyread = FALSE; + wide_handler->ignore_dup_key = FALSE; + wide_handler->write_can_replace = FALSE; + wide_handler->insert_with_update = FALSE; + wide_handler->low_priority = FALSE; + wide_handler->high_priority = FALSE; + wide_handler->insert_delayed = FALSE; + wide_handler->lock_table_type = 0; + wide_handler->semi_trx_isolation_chk = FALSE; + wide_handler->semi_trx_chk = FALSE; if (!is_clone) { - partition_handler_share->searched_bitmap = NULL; - partition_handler_share->ft_discard_bitmap = NULL; + memset(wide_handler->ft_discard_bitmap, 0xFF, + no_bytes_in_map(table->read_set)); + memset(wide_handler->searched_bitmap, 0, + no_bytes_in_map(table->read_set)); } - partition_handler_share->between_flg = FALSE; - partition_handler_share->idx_bitmap_is_set = FALSE; - partition_handler_share->rnd_bitmap_is_set = FALSE; - } + while (wide_handler->condition) + { + tmp_cond = wide_handler->condition->next; + spider_free(spider_current_trx, wide_handler->condition, MYF(0)); + wide_handler->condition = tmp_cond; + } + wide_handler->cond_check = FALSE; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + wide_handler->direct_update_fields = NULL; +#endif +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + wide_handler->info_limit = 9223372036854775807LL; #endif - if (!is_clone) - { - memset(ft_discard_bitmap, 0xFF, no_bytes_in_map(table->read_set)); - memset(searched_bitmap, 0, no_bytes_in_map(table->read_set)); } if (!(tmp_trx = spider_get_trx(thd, TRUE, &error_num2))) { @@ -1691,82 +1450,11 @@ int ha_spider::reset() } if (share) { - trx_bak = trx; - trx = tmp_trx; + trx_bak = wide_handler->trx; + wide_handler->trx = tmp_trx; if ((error_num2 = spider_db_free_result(this, FALSE))) error_num = error_num2; - trx = trx_bak; -/* - int semi_table_lock_conn = spider_param_semi_table_lock_connection(thd, - share->semi_table_lock_conn); - if (semi_table_lock_conn) - first_byte = '0' + - spider_param_semi_table_lock(thd, share->semi_table_lock); - else - first_byte = '0'; - DBUG_PRINT("info",("spider semi_table_lock_conn = %d", - semi_table_lock_conn)); - DBUG_PRINT("info",("spider semi_table_lock = %d", - spider_param_semi_table_lock(thd, share->semi_table_lock))); - DBUG_PRINT("info",("spider first_byte = %d", first_byte)); - if (tmp_trx->spider_thread_id != spider_thread_id || - (tmp_trx->trx_conn_adjustment != trx_conn_adjustment && - tmp_trx->trx_conn_adjustment - 1 != trx_conn_adjustment) || - first_byte != *conn_keys[0] - ) { - DBUG_PRINT("info",(first_byte != *conn_keys[0] ? - "spider change conn type" : tmp_trx != trx ? "spider change thd" : - "spider next trx")); - trx = tmp_trx; - spider_thread_id = tmp_trx->spider_thread_id; - trx_conn_adjustment = tmp_trx->trx_conn_adjustment; - - first_byte_bak = *conn_keys[0]; - *conn_keys[0] = first_byte; - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - *conn_keys[roop_count] = first_byte; - if ( - !(conns[roop_count] = - spider_get_conn(share, roop_count, conn_keys[roop_count], trx, - this, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL, &error_num)) - ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_PRINT("info",("spider get conn error")); - *conn_keys[0] = first_byte_bak; - conns[0] = NULL; - DBUG_RETURN(error_num); - } - } - } -*/ + wide_handler->trx = trx_bak; memset(need_mons, 0, sizeof(int) * share->link_count); memset(result_list.casual_read, 0, sizeof(int) * share->link_count); rm_bulk_tmp_table(); @@ -1796,19 +1484,12 @@ int ha_spider::reset() } } } - quick_mode = FALSE; - keyread = FALSE; - ignore_dup_key = FALSE; - write_can_replace = FALSE; - insert_with_update = FALSE; - low_priority = FALSE; - high_priority = FALSE; - insert_delayed = FALSE; + dml_inited = FALSE; use_pre_call = FALSE; use_pre_records = FALSE; pre_bitmap_checked = FALSE; bulk_insert = FALSE; - clone_bitmap_init = FALSE; + partition_handler_share->clone_bitmap_init = FALSE; result_list.tmp_table_join = FALSE; result_list.use_union = FALSE; result_list.use_both_key = FALSE; @@ -1816,13 +1497,6 @@ int ha_spider::reset() conn_kinds = SPIDER_CONN_KIND_MYSQL; use_index_merge = FALSE; init_rnd_handler = FALSE; - while (condition) - { - tmp_cond = condition->next; - spider_free(spider_current_trx, condition, MYF(0)); - condition = tmp_cond; - } - cond_check = FALSE; #ifdef HA_MRR_USE_DEFAULT_IMPL if (multi_range_keys) { @@ -1845,10 +1519,6 @@ int ha_spider::reset() #endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; - direct_update_fields = NULL; -#endif -#ifdef INFO_KIND_FORCE_LIMIT_BEGIN - info_limit = 9223372036854775807LL; #endif prev_index_rnd_init = SPD_NONE; result_list.have_sql_kind_backup = FALSE; @@ -1889,52 +1559,51 @@ int ha_spider::extra( switch (operation) { case HA_EXTRA_QUICK: - quick_mode = TRUE; + wide_handler->quick_mode = TRUE; break; case HA_EXTRA_KEYREAD: if (!is_clone) { - keyread = TRUE; + wide_handler->keyread = TRUE; #ifdef WITH_PARTITION_STORAGE_ENGINE - if (update_request) + if (wide_handler->update_request) { if (check_partitioned()) - keyread = FALSE; + wide_handler->keyread = FALSE; } #endif } break; case HA_EXTRA_NO_KEYREAD: - keyread = FALSE; + wide_handler->keyread = FALSE; break; case HA_EXTRA_IGNORE_DUP_KEY: - ignore_dup_key = TRUE; + wide_handler->ignore_dup_key = TRUE; break; case HA_EXTRA_NO_IGNORE_DUP_KEY: - ignore_dup_key = FALSE; + wide_handler->ignore_dup_key = FALSE; break; case HA_EXTRA_WRITE_CAN_REPLACE: - write_can_replace = TRUE; + wide_handler->write_can_replace = TRUE; break; case HA_EXTRA_WRITE_CANNOT_REPLACE: - write_can_replace = FALSE; + wide_handler->write_can_replace = FALSE; break; #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS case HA_EXTRA_INSERT_WITH_UPDATE: - insert_with_update = TRUE; - check_insert_dup_update_pushdown(); + wide_handler->insert_with_update = TRUE; break; #endif case HA_EXTRA_ATTACH_CHILDREN: DBUG_PRINT("info",("spider HA_EXTRA_ATTACH_CHILDREN")); - if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num))) + if (!(wide_handler->trx = spider_get_trx(ha_thd(), TRUE, &error_num))) DBUG_RETURN(error_num); break; #if MYSQL_VERSION_ID < 50500 #else case HA_EXTRA_ADD_CHILDREN_LIST: DBUG_PRINT("info",("spider HA_EXTRA_ADD_CHILDREN_LIST")); - if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num))) + if (!(wide_handler->trx = spider_get_trx(ha_thd(), TRUE, &error_num))) DBUG_RETURN(error_num); break; #endif @@ -1957,7 +1626,8 @@ int ha_spider::extra( part_num < spider_user_defined_key_parts(key_info); key_part++, part_num++ ) { - spider_set_bit(searched_bitmap, key_part->field->field_index); + spider_set_bit(wide_handler->searched_bitmap, + key_part->field->field_index); } } else { DBUG_PRINT("info",("spider need all columns")); @@ -1967,7 +1637,7 @@ int ha_spider::extra( *field; field++ ) { - spider_set_bit(searched_bitmap, (*field)->field_index); + spider_set_bit(wide_handler->searched_bitmap, (*field)->field_index); } } break; @@ -1999,6 +1669,13 @@ int ha_spider::index_init( } } #endif + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + DBUG_RETURN(error_num); + } + } pushed_pos = NULL; active_index = idx; result_list.sorted = sorted; @@ -2010,20 +1687,21 @@ int ha_spider::index_init( if (pre_bitmap_checked) pre_bitmap_checked = FALSE; else { - if (result_list.lock_type == F_WRLCK) + if (wide_handler->external_lock_type == F_WRLCK) { pk_update = FALSE; /* check_and_start_bulk_update(SPD_BU_START_BY_INDEX_OR_RND_INIT); */ if ( - update_request && + wide_handler->update_request && share->have_recovery_link && (pk_update = spider_check_pk_update(table)) ) { bitmap_set_all(table->read_set); if (is_clone) - memset(searched_bitmap, 0xFF, no_bytes_in_map(table->read_set)); + memset(wide_handler->searched_bitmap, 0xFF, + no_bytes_in_map(table->read_set)); } } @@ -2117,7 +1795,7 @@ int ha_spider::index_read_map_internal( backup_error_status(); DBUG_ENTER("ha_spider::index_read_map_internal"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -2162,7 +1840,7 @@ int ha_spider::index_read_map_internal( DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); result_list.finish_flg = FALSE; result_list.record_num = 0; - if (keyread) + if (wide_handler->keyread) result_list.keyread = TRUE; else result_list.keyread = FALSE; @@ -2277,7 +1955,8 @@ int ha_spider::index_read_map_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -2289,8 +1968,8 @@ int ha_spider::index_read_map_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -2353,7 +2032,7 @@ int ha_spider::index_read_map_internal( conn_kind[roop_count] != SPIDER_CONN_KIND_MYSQL ) { connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(trx, conn); + spider_trx_add_bulk_access_conn(wide_handler->trx, conn); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { @@ -2373,8 +2052,8 @@ int ha_spider::index_read_map_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -2392,7 +2071,7 @@ int ha_spider::index_read_map_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -2407,8 +2086,8 @@ int ha_spider::index_read_map_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -2438,8 +2117,8 @@ int ha_spider::index_read_map_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -2628,7 +2307,7 @@ int ha_spider::index_read_last_map_internal( backup_error_status(); DBUG_ENTER("ha_spider::index_read_last_map_internal"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -2682,7 +2361,7 @@ int ha_spider::index_read_last_map_internal( DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); result_list.finish_flg = FALSE; result_list.record_num = 0; - if (keyread) + if (wide_handler->keyread) result_list.keyread = TRUE; else result_list.keyread = FALSE; @@ -2773,7 +2452,8 @@ int ha_spider::index_read_last_map_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -2785,8 +2465,8 @@ int ha_spider::index_read_last_map_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -2846,7 +2526,7 @@ int ha_spider::index_read_last_map_internal( if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(trx, conn); + spider_trx_add_bulk_access_conn(wide_handler->trx, conn); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { @@ -2866,8 +2546,8 @@ int ha_spider::index_read_last_map_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -2885,7 +2565,7 @@ int ha_spider::index_read_last_map_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -2900,8 +2580,8 @@ int ha_spider::index_read_last_map_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -2931,8 +2611,8 @@ int ha_spider::index_read_last_map_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -3015,7 +2695,7 @@ int ha_spider::index_next( backup_error_status(); DBUG_ENTER("ha_spider::index_next"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -3061,7 +2741,7 @@ int ha_spider::index_prev( backup_error_status(); DBUG_ENTER("ha_spider::index_prev"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -3108,7 +2788,7 @@ int ha_spider::index_first_internal( backup_error_status(); DBUG_ENTER("ha_spider::index_first_internal"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -3151,7 +2831,7 @@ int ha_spider::index_first_internal( DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); result_list.finish_flg = FALSE; result_list.record_num = 0; - if (keyread) + if (wide_handler->keyread) result_list.keyread = TRUE; else result_list.keyread = FALSE; @@ -3243,7 +2923,8 @@ int ha_spider::index_first_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -3255,8 +2936,8 @@ int ha_spider::index_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -3317,7 +2998,7 @@ int ha_spider::index_first_internal( if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(trx, conn); + spider_trx_add_bulk_access_conn(wide_handler->trx, conn); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { @@ -3337,8 +3018,8 @@ int ha_spider::index_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -3356,7 +3037,7 @@ int ha_spider::index_first_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -3371,8 +3052,8 @@ int ha_spider::index_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -3402,8 +3083,8 @@ int ha_spider::index_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -3496,7 +3177,7 @@ int ha_spider::index_last_internal( backup_error_status(); DBUG_ENTER("ha_spider::index_last_internal"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -3539,7 +3220,7 @@ int ha_spider::index_last_internal( DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); result_list.finish_flg = FALSE; result_list.record_num = 0; - if (keyread) + if (wide_handler->keyread) result_list.keyread = TRUE; else result_list.keyread = FALSE; @@ -3631,7 +3312,8 @@ int ha_spider::index_last_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -3643,8 +3325,8 @@ int ha_spider::index_last_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -3705,7 +3387,7 @@ int ha_spider::index_last_internal( if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(trx, conn); + spider_trx_add_bulk_access_conn(wide_handler->trx, conn); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { @@ -3725,8 +3407,8 @@ int ha_spider::index_last_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -3744,7 +3426,7 @@ int ha_spider::index_last_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -3759,8 +3441,8 @@ int ha_spider::index_last_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -3790,8 +3472,8 @@ int ha_spider::index_last_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -3885,7 +3567,7 @@ int ha_spider::index_next_same( backup_error_status(); DBUG_ENTER("ha_spider::index_next_same"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -3937,7 +3619,7 @@ int ha_spider::read_range_first_internal( backup_error_status(); DBUG_ENTER("ha_spider::read_range_first_internal"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -3987,7 +3669,7 @@ int ha_spider::read_range_first_internal( DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); result_list.finish_flg = FALSE; result_list.record_num = 0; - if (keyread) + if (wide_handler->keyread) result_list.keyread = TRUE; else result_list.keyread = FALSE; @@ -4079,7 +3761,8 @@ int ha_spider::read_range_first_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -4091,8 +3774,8 @@ int ha_spider::read_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4152,7 +3835,7 @@ int ha_spider::read_range_first_internal( if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(trx, conn); + spider_trx_add_bulk_access_conn(wide_handler->trx, conn); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { @@ -4172,8 +3855,8 @@ int ha_spider::read_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4191,7 +3874,7 @@ int ha_spider::read_range_first_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -4206,8 +3889,8 @@ int ha_spider::read_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4237,8 +3920,8 @@ int ha_spider::read_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4328,7 +4011,7 @@ int ha_spider::read_range_next() backup_error_status(); DBUG_ENTER("ha_spider::read_range_next"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -4380,17 +4063,18 @@ ha_rows ha_spider::multi_range_read_info_const( DBUG_PRINT("info",("spider this=%p", this)); if (!pre_bitmap_checked) { - if (result_list.lock_type == F_WRLCK) + if (wide_handler->external_lock_type == F_WRLCK) { pk_update = FALSE; if ( - update_request && + wide_handler->update_request && share->have_recovery_link && (pk_update = spider_check_pk_update(table)) ) { bitmap_set_all(table->read_set); if (is_clone) - memset(searched_bitmap, 0xFF, no_bytes_in_map(table->read_set)); + memset(wide_handler->searched_bitmap, 0xFF, + no_bytes_in_map(table->read_set)); } } @@ -4444,17 +4128,18 @@ ha_rows ha_spider::multi_range_read_info( DBUG_PRINT("info",("spider this=%p", this)); if (!pre_bitmap_checked) { - if (result_list.lock_type == F_WRLCK) + if (wide_handler->external_lock_type == F_WRLCK) { pk_update = FALSE; if ( - update_request && + wide_handler->update_request && share->have_recovery_link && (pk_update = spider_check_pk_update(table)) ) { bitmap_set_all(table->read_set); if (is_clone) - memset(searched_bitmap, 0xFF, no_bytes_in_map(table->read_set)); + memset(wide_handler->searched_bitmap, 0xFF, + no_bytes_in_map(table->read_set)); } } @@ -4489,7 +4174,7 @@ int ha_spider::multi_range_read_init( uint mode, HANDLER_BUFFER *buf ) { - bka_mode = spider_param_bka_mode(trx->thd, share->bka_mode); + bka_mode = spider_param_bka_mode(wide_handler->trx->thd, share->bka_mode); backup_error_status(); DBUG_ENTER("ha_spider::multi_range_read_init"); DBUG_PRINT("info",("spider this=%p", this)); @@ -4536,12 +4221,12 @@ int ha_spider::read_multi_range_first_internal( backup_error_status(); DBUG_ENTER("ha_spider::multi_range_read_next_first"); #else - bka_mode = spider_param_bka_mode(trx->thd, share->bka_mode); + bka_mode = spider_param_bka_mode(wide_handler->trx->thd, share->bka_mode); backup_error_status(); DBUG_ENTER("ha_spider::read_multi_range_first_internal"); #endif DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -4596,7 +4281,7 @@ int ha_spider::read_multi_range_first_internal( result_list.multi_split_read <= 1 || (sql_kinds & SPIDER_SQL_KIND_HANDLER) ) { - if (keyread) + if (wide_handler->keyread) result_list.keyread = TRUE; else result_list.keyread = FALSE; @@ -4711,7 +4396,8 @@ int ha_spider::read_multi_range_first_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -4723,8 +4409,8 @@ int ha_spider::read_multi_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4783,7 +4469,7 @@ int ha_spider::read_multi_range_first_internal( if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(trx, conn); + spider_trx_add_bulk_access_conn(wide_handler->trx, conn); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL @@ -4809,8 +4495,8 @@ int ha_spider::read_multi_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4829,7 +4515,7 @@ int ha_spider::read_multi_range_first_internal( if (!error_num) { spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -4844,8 +4530,8 @@ int ha_spider::read_multi_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4877,8 +4563,8 @@ int ha_spider::read_multi_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4977,7 +4663,7 @@ int ha_spider::read_multi_range_first_internal( if (error_num) DBUG_RETURN(check_error_mode_eof(error_num)); } else { - bool tmp_high_priority = high_priority; + bool tmp_high_priority = wide_handler->high_priority; bool have_multi_range; #ifdef HA_MRR_USE_DEFAULT_IMPL const uchar *first_mrr_start_key; @@ -4986,7 +4672,7 @@ int ha_spider::read_multi_range_first_internal( uint first_mrr_end_key_length; have_second_range = FALSE; #endif - if (keyread) + if (wide_handler->keyread) result_list.keyread = TRUE; else result_list.keyread = FALSE; @@ -5372,7 +5058,7 @@ int ha_spider::read_multi_range_first_internal( (error_num = set_union_table_name_pos_sql()) ) DBUG_RETURN(error_num); - high_priority = FALSE; + wide_handler->high_priority = FALSE; if ( share->key_hint && (error_num = append_hint_after_table_sql_part( @@ -5447,7 +5133,7 @@ int ha_spider::read_multi_range_first_internal( #ifdef HA_MRR_USE_DEFAULT_IMPL while (!range_res); #endif - high_priority = tmp_high_priority; + wide_handler->high_priority = tmp_high_priority; if ((error_num = append_union_all_end_sql_part( SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); @@ -5506,7 +5192,8 @@ int ha_spider::read_multi_range_first_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -5518,8 +5205,8 @@ int ha_spider::read_multi_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5581,7 +5268,7 @@ int ha_spider::read_multi_range_first_internal( if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(trx, conn); + spider_trx_add_bulk_access_conn(wide_handler->trx, conn); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL @@ -5607,8 +5294,8 @@ int ha_spider::read_multi_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5633,7 +5320,7 @@ int ha_spider::read_multi_range_first_internal( spider_set_bit(result_list.tmp_table_created, roop_count); result_list.tmp_tables_created = TRUE; spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_TMP_SQL, conn, @@ -5648,8 +5335,8 @@ int ha_spider::read_multi_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5669,7 +5356,7 @@ int ha_spider::read_multi_range_first_internal( spider_db_discard_multiple_result(this, roop_count, conn); } spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -5684,8 +5371,8 @@ int ha_spider::read_multi_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5715,8 +5402,8 @@ int ha_spider::read_multi_range_first_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -6000,7 +5687,7 @@ int ha_spider::read_multi_range_next( DBUG_ENTER("ha_spider::read_multi_range_next"); #endif DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -6160,7 +5847,8 @@ int ha_spider::read_multi_range_next( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -6172,8 +5860,8 @@ int ha_spider::read_multi_range_next( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -6232,7 +5920,7 @@ int ha_spider::read_multi_range_next( if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(trx, conn); + spider_trx_add_bulk_access_conn(wide_handler->trx, conn); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL @@ -6258,8 +5946,8 @@ int ha_spider::read_multi_range_next( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -6278,7 +5966,7 @@ int ha_spider::read_multi_range_next( if (!error_num) { spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -6293,8 +5981,8 @@ int ha_spider::read_multi_range_next( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -6326,8 +6014,8 @@ int ha_spider::read_multi_range_next( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -6523,7 +6211,7 @@ int ha_spider::read_multi_range_next( multi_range_ranges = multi_range_curr; #endif - bool tmp_high_priority = high_priority; + bool tmp_high_priority = wide_handler->high_priority; bool have_multi_range; multi_range_cnt = 0; error_num = 0; @@ -6831,7 +6519,7 @@ int ha_spider::read_multi_range_next( (error_num = set_union_table_name_pos_sql()) ) DBUG_RETURN(error_num); - high_priority = FALSE; + wide_handler->high_priority = FALSE; if ( share->key_hint && (error_num = append_hint_after_table_sql_part( @@ -6901,7 +6589,7 @@ int ha_spider::read_multi_range_next( #ifdef HA_MRR_USE_DEFAULT_IMPL while (!range_res); #endif - high_priority = tmp_high_priority; + wide_handler->high_priority = tmp_high_priority; if ((error_num = append_union_all_end_sql_part(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); @@ -6959,7 +6647,8 @@ int ha_spider::read_multi_range_next( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -6971,8 +6660,8 @@ int ha_spider::read_multi_range_next( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7034,7 +6723,7 @@ int ha_spider::read_multi_range_next( if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(trx, conn); + spider_trx_add_bulk_access_conn(wide_handler->trx, conn); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL @@ -7060,8 +6749,8 @@ int ha_spider::read_multi_range_next( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7086,7 +6775,7 @@ int ha_spider::read_multi_range_next( spider_set_bit(result_list.tmp_table_created, roop_count); result_list.tmp_tables_created = TRUE; spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_TMP_SQL, conn, @@ -7101,8 +6790,8 @@ int ha_spider::read_multi_range_next( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7122,7 +6811,7 @@ int ha_spider::read_multi_range_next( spider_db_discard_multiple_result(this, roop_count, conn); } spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -7137,8 +6826,8 @@ int ha_spider::read_multi_range_next( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7168,8 +6857,8 @@ int ha_spider::read_multi_range_next( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7328,15 +7017,22 @@ int ha_spider::rnd_init( DBUG_ENTER("ha_spider::rnd_init"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider scan=%s", scan ? "TRUE" : "FALSE")); + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + DBUG_RETURN(error_num); + } + } pushed_pos = NULL; /* - if (result_list.lock_type == F_WRLCK) + if (wide_handler->external_lock_type == F_WRLCK) check_and_start_bulk_update(SPD_BU_START_BY_INDEX_OR_RND_INIT); */ rnd_scan_and_first = scan; if ( scan && - sql_command != SQLCOM_ALTER_TABLE + wide_handler->sql_command != SQLCOM_ALTER_TABLE ) { spider_set_result_list_param(this); pk_update = FALSE; @@ -7401,14 +7097,15 @@ int ha_spider::rnd_init( use_spatial_index = FALSE; if ( - update_request && + wide_handler->update_request && share->have_recovery_link && - result_list.lock_type == F_WRLCK && + wide_handler->external_lock_type == F_WRLCK && (pk_update = spider_check_pk_update(table)) ) { bitmap_set_all(table->read_set); if (is_clone) - memset(searched_bitmap, 0xFF, no_bytes_in_map(table->read_set)); + memset(wide_handler->searched_bitmap, 0xFF, + no_bytes_in_map(table->read_set)); } set_select_column_mode(); @@ -7478,17 +7175,17 @@ int ha_spider::rnd_next_internal( ) { int error_num; ha_spider *direct_limit_offset_spider = - (ha_spider *) partition_handler_share->creator; + (ha_spider *) partition_handler_share->owner; backup_error_status(); DBUG_ENTER("ha_spider::rnd_next_internal"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } /* do not copy table data at alter table */ - if (sql_command == SQLCOM_ALTER_TABLE) + if (wide_handler->sql_command == SQLCOM_ALTER_TABLE) DBUG_RETURN(HA_ERR_END_OF_FILE); #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; @@ -7634,7 +7331,8 @@ int ha_spider::rnd_next_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -7646,8 +7344,8 @@ int ha_spider::rnd_next_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7706,8 +7404,8 @@ int ha_spider::rnd_next_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7725,7 +7423,7 @@ int ha_spider::rnd_next_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, conn, @@ -7740,8 +7438,8 @@ int ha_spider::rnd_next_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7771,8 +7469,8 @@ int ha_spider::rnd_next_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7889,15 +7587,15 @@ void ha_spider::position( DBUG_PRINT("info",("spider self position")); DBUG_PRINT("info", ("spider current_row_num=%lld", result_list.current_row_num)); - if (!position_bitmap_init) + if (!wide_handler->position_bitmap_init) { if (select_column_mode) { spider_db_handler *dbton_hdl = dbton_handler[result_list.current->dbton_id]; - dbton_hdl->copy_minimum_select_bitmap(position_bitmap); + dbton_hdl->copy_minimum_select_bitmap(wide_handler->position_bitmap); } - position_bitmap_init = TRUE; + wide_handler->position_bitmap_init = TRUE; } spider_db_create_position(this, (SPIDER_POSITION *) ref); } @@ -7919,7 +7617,7 @@ int ha_spider::rnd_pos( ((uchar *) table->read_set->bitmap)[roop_count])); } #endif - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -8135,7 +7833,7 @@ int ha_spider::ft_read_internal( backup_error_status(); DBUG_ENTER("ha_spider::ft_read_internal"); DBUG_PRINT("info",("spider this=%p", this)); - if (trx->thd->killed) + if (wide_handler->trx->thd->killed) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); @@ -8155,7 +7853,7 @@ int ha_spider::ft_read_internal( DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); result_list.finish_flg = FALSE; result_list.record_num = 0; - if (keyread) + if (wide_handler->keyread) result_list.keyread = TRUE; else result_list.keyread = FALSE; @@ -8256,7 +7954,8 @@ int ha_spider::ft_read_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read(trx->thd, this, + if ((error_num = spider_check_and_init_casual_read( + wide_handler->trx->thd, this, roop_count))) DBUG_RETURN(error_num); if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, @@ -8268,8 +7967,8 @@ int ha_spider::ft_read_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8322,8 +8021,8 @@ int ha_spider::ft_read_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8340,7 +8039,8 @@ int ha_spider::ft_read_internal( } DBUG_RETURN(check_error_mode_eof(error_num)); } - spider_conn_set_timeout_from_share(conn, roop_count, trx->thd, share); + spider_conn_set_timeout_from_share(conn, roop_count, + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_SELECT_SQL, conn, @@ -8355,8 +8055,8 @@ int ha_spider::ft_read_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8386,8 +8086,8 @@ int ha_spider::ft_read_internal( need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8486,7 +8186,7 @@ int ha_spider::info( #ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT auto_inc_temporary = FALSE; #endif - sql_command = thd_sql_command(thd); + wide_handler->sql_command = thd_sql_command(thd); /* if ( sql_command == SQLCOM_DROP_TABLE || @@ -8507,8 +8207,8 @@ int ha_spider::info( } } if ( - sql_command == SQLCOM_DROP_TABLE || - sql_command == SQLCOM_ALTER_TABLE + wide_handler->sql_command == SQLCOM_DROP_TABLE || + wide_handler->sql_command == SQLCOM_ALTER_TABLE ) DBUG_RETURN(0); /* @@ -8539,7 +8239,7 @@ int ha_spider::info( pthread_mutex_unlock(&share->sts_mutex); else { if ((spider_init_error_table = - spider_get_init_error_table(trx, share, FALSE))) + spider_get_init_error_table(wide_handler->trx, share, FALSE))) { DBUG_PRINT("info",("spider diff=%f", difftime(tmp_time, spider_init_error_table->init_error_time))); @@ -8548,7 +8248,7 @@ int ha_spider::info( spider_param_table_init_error_interval()) { pthread_mutex_unlock(&share->sts_mutex); - if (sql_command == SQLCOM_SHOW_CREATE) + if (wide_handler->sql_command == SQLCOM_SHOW_CREATE) { if (thd->is_error()) { @@ -8574,9 +8274,7 @@ int ha_spider::info( if (flag & HA_STATUS_AUTO) { if ( -#ifdef WITH_PARTITION_STORAGE_ENGINE - share->partition_share && -#endif + share->wide_share && tmp_auto_increment_mode == 1 && !share->lgtm_tblhnd_share->auto_increment_init ) { @@ -8609,7 +8307,8 @@ int ha_spider::info( if ( spider_init_error_table || (spider_init_error_table = - spider_get_init_error_table(trx, share, TRUE)) + spider_get_init_error_table(wide_handler->trx, + share, TRUE)) ) { spider_init_error_table->init_error = error_num; if ((spider_init_error_table->init_error_with_message = @@ -8622,7 +8321,7 @@ int ha_spider::info( share->init_error = TRUE; share->init = TRUE; } - if (sql_command == SQLCOM_SHOW_CREATE) + if (wide_handler->sql_command == SQLCOM_SHOW_CREATE) { if (thd->is_error()) { @@ -8647,8 +8346,8 @@ int ha_spider::info( need_mons[search_link_idx] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, search_link_idx, (uint32) share->monitoring_sid[search_link_idx], @@ -8668,7 +8367,8 @@ int ha_spider::info( if ( spider_init_error_table || (spider_init_error_table = - spider_get_init_error_table(trx, share, TRUE)) + spider_get_init_error_table(wide_handler->trx, + share, TRUE)) ) { spider_init_error_table->init_error = error_num; /* @@ -8685,7 +8385,7 @@ int ha_spider::info( share->init_error = TRUE; share->init = TRUE; } - if (sql_command == SQLCOM_SHOW_CREATE) + if (wide_handler->sql_command == SQLCOM_SHOW_CREATE) { if (thd->is_error()) { @@ -8714,7 +8414,7 @@ int ha_spider::info( if ((error_num = spider_create_sts_thread(share))) { pthread_mutex_unlock(&share->sts_mutex); - if (sql_command == SQLCOM_SHOW_CREATE) + if (wide_handler->sql_command == SQLCOM_SHOW_CREATE) { if (thd->is_error()) { @@ -8745,7 +8445,7 @@ int ha_spider::info( { if ((error_num = check_crd())) { - if (sql_command == SQLCOM_SHOW_CREATE) + if (wide_handler->sql_command == SQLCOM_SHOW_CREATE) { if (thd->is_error()) { @@ -8782,8 +8482,7 @@ int ha_spider::info( #ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT auto_inc_temporary = FALSE; #endif -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (share->partition_share && table->next_number_field) + if (share->wide_share && table->next_number_field) { ulonglong first_value, nb_reserved_values; if ( @@ -8820,12 +8519,9 @@ int ha_spider::info( share->lgtm_tblhnd_share->auto_increment_value; } } else { -#endif stats.auto_increment_value = share->lgtm_tblhnd_share->auto_increment_value; -#ifdef WITH_PARTITION_STORAGE_ENGINE } -#endif } } if (flag & HA_STATUS_ERRKEY) @@ -8863,7 +8559,7 @@ ha_rows ha_spider::records_in_range( pthread_mutex_unlock(&share->crd_mutex); else { if ((spider_init_error_table = - spider_get_init_error_table(trx, share, FALSE))) + spider_get_init_error_table(wide_handler->trx, share, FALSE))) { DBUG_PRINT("info",("spider diff=%f", difftime(tmp_time, spider_init_error_table->init_error_time))); @@ -8901,6 +8597,15 @@ ha_rows ha_spider::records_in_range( share->static_key_cardinality[inx] == -1 && difftime(tmp_time, share->crd_get_time) >= crd_interval ) { + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + if (check_error_mode(error_num)) + my_errno = error_num; + DBUG_RETURN(HA_POS_ERROR); + } + } if ( crd_interval == 0 || !pthread_mutex_trylock(&share->crd_mutex) @@ -8926,8 +8631,8 @@ ha_rows ha_spider::records_in_range( need_mons[search_link_idx] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, search_link_idx, (uint32) share->monitoring_sid[search_link_idx], @@ -8947,7 +8652,8 @@ ha_rows ha_spider::records_in_range( if ( spider_init_error_table || (spider_init_error_table = - spider_get_init_error_table(trx, share, TRUE)) + spider_get_init_error_table(wide_handler->trx, + share, TRUE)) ) { spider_init_error_table->init_error = error_num; /* @@ -9135,6 +8841,15 @@ ha_rows ha_spider::records_in_range( DBUG_RETURN((ha_rows) rows); } else if (crd_mode == 3) { + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + if (check_error_mode(error_num)) + my_errno = error_num; + DBUG_RETURN(HA_POS_ERROR); + } + } result_list.key_info = &table->key_info[inx]; DBUG_RETURN(spider_db_explain_select(start_key, end_key, this, search_link_idx)); @@ -9167,7 +8882,7 @@ int ha_spider::check_crd() pthread_mutex_unlock(&share->crd_mutex); else { if ((spider_init_error_table = - spider_get_init_error_table(trx, share, FALSE))) + spider_get_init_error_table(wide_handler->trx, share, FALSE))) { DBUG_PRINT("info",("spider diff=%f", difftime(tmp_time, spider_init_error_table->init_error_time))); @@ -9226,8 +8941,8 @@ int ha_spider::check_crd() need_mons[search_link_idx] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, search_link_idx, (uint32) share->monitoring_sid[search_link_idx], @@ -9247,7 +8962,7 @@ int ha_spider::check_crd() if ( spider_init_error_table || (spider_init_error_table = - spider_get_init_error_table(trx, share, TRUE)) + spider_get_init_error_table(wide_handler->trx, share, TRUE)) ) { spider_init_error_table->init_error = error_num; if ((spider_init_error_table->init_error_with_message = @@ -9307,7 +9022,7 @@ int ha_spider::pre_records() backup_error_status(); DBUG_ENTER("ha_spider::pre_records"); DBUG_PRINT("info",("spider this=%p", this)); - if (sql_command == SQLCOM_ALTER_TABLE) + if (wide_handler->sql_command == SQLCOM_ALTER_TABLE) { DBUG_RETURN(0); } @@ -9315,7 +9030,7 @@ int ha_spider::pre_records() { DBUG_RETURN(0); } - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; if ( spider_param_sync_autocommit(thd) && (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) @@ -9337,7 +9052,7 @@ ha_rows ha_spider::records() backup_error_status(); DBUG_ENTER("ha_spider::records"); DBUG_PRINT("info",("spider this=%p", this)); - if (sql_command == SQLCOM_ALTER_TABLE) + if (wide_handler->sql_command == SQLCOM_ALTER_TABLE) { use_pre_records = FALSE; DBUG_RETURN(0); @@ -9348,7 +9063,7 @@ ha_rows ha_spider::records() } if (!use_pre_records && !this->result_list.direct_limit_offset) { - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; if ( spider_param_sync_autocommit(thd) && (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) @@ -9425,6 +9140,36 @@ ulonglong ha_spider::table_flags() const DBUG_RETURN(flags); } +ulong ha_spider::table_flags_for_partition() +{ + DBUG_ENTER("ha_spider::table_flags_for_partition"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN( +#ifdef HA_PT_CALL_AT_ONCE_STORE_LOCK + HA_PT_CALL_AT_ONCE_STORE_LOCK | +#endif +#ifdef HA_PT_CALL_AT_ONCE_EXTERNAL_LOCK + HA_PT_CALL_AT_ONCE_EXTERNAL_LOCK | +#endif +#ifdef HA_PT_CALL_AT_ONCE_START_STMT + HA_PT_CALL_AT_ONCE_START_STMT | +#endif +#ifdef HA_PT_CALL_AT_ONCE_EXTRA + HA_PT_CALL_AT_ONCE_EXTRA | +#endif +#ifdef HA_PT_CALL_AT_ONCE_COND_PUSH + HA_PT_CALL_AT_ONCE_COND_PUSH | +#endif +#ifdef HA_PT_CALL_AT_ONCE_INFO_PUSH + HA_PT_CALL_AT_ONCE_INFO_PUSH | +#endif +#ifdef HA_PT_CALL_AT_ONCE_TOP_TABLE + HA_PT_CALL_AT_ONCE_TOP_TABLE | +#endif + 0 + ); +} + const char *ha_spider::index_type( uint key_number ) { @@ -9552,7 +9297,7 @@ int ha_spider::update_auto_increment() /* if ( next_insert_id >= auto_inc_interval_for_cur_row.maximum() && - trx->thd->auto_inc_intervals_forced.get_current() + wide_handler->trx->thd->auto_inc_intervals_forced.get_current() ) { force_auto_increment = TRUE; DBUG_PRINT("info",("spider force_auto_increment=TRUE")); @@ -9775,6 +9520,13 @@ int ha_spider::write_row( DBUG_RETURN(error_num); } #endif + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + DBUG_RETURN(error_num); + } + } #ifndef SPIDER_WITHOUT_HA_STATISTIC_INCREMENT ha_statistic_increment(&SSV::ha_write_count); #endif @@ -9837,19 +9589,21 @@ int ha_spider::write_row( if (!bulk_insert || bulk_size < 0) { direct_dup_insert = - spider_param_direct_dup_insert(trx->thd, share->direct_dup_insert); + spider_param_direct_dup_insert(wide_handler->trx->thd, + share->direct_dup_insert); DBUG_PRINT("info",("spider direct_dup_insert=%d", direct_dup_insert)); if ((error_num = spider_db_bulk_insert_init(this, table))) DBUG_RETURN(check_error_mode(error_num)); if (bulk_insert) bulk_size = #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - (insert_with_update && !result_list.insert_dup_update_pushdown) || + (wide_handler->insert_with_update && + !result_list.insert_dup_update_pushdown) || #else - insert_with_update || + wide_handler->insert_with_update || #endif - (!direct_dup_insert && ignore_dup_key) ? - 0 : spider_param_bulk_size(trx->thd, share->bulk_size); + (!direct_dup_insert && wide_handler->ignore_dup_key) ? + 0 : spider_param_bulk_size(wide_handler->trx->thd, share->bulk_size); else bulk_size = 0; } @@ -9873,7 +9627,7 @@ int ha_spider::pre_write_row( ) { int error_num; ulonglong option_backup = 0; - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::pre_write_row"); DBUG_PRINT("info",("spider this=%p", this)); #if MYSQL_VERSION_ID < 50500 @@ -10111,7 +9865,7 @@ int ha_spider::direct_update_rows_init( st_select_lex *select_lex; longlong select_limit; longlong offset_limit; - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_update_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); #ifdef HA_CAN_BULK_ACCESS @@ -10140,6 +9894,13 @@ int ha_spider::direct_update_rows_init( #endif } #endif + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + DBUG_RETURN(error_num); + } + } direct_update_init( thd, #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) @@ -10189,7 +9950,7 @@ int ha_spider::direct_update_rows_init( } result_list.direct_order_limit = TRUE; } - trx->direct_update_count++; + wide_handler->trx->direct_update_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); } @@ -10232,7 +9993,7 @@ int ha_spider::direct_update_rows_init( DBUG_RETURN(error_num); } #endif - trx->direct_update_count++; + wide_handler->trx->direct_update_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); } @@ -10261,10 +10022,10 @@ int ha_spider::direct_update_rows_init() st_select_lex *select_lex; longlong select_limit; longlong offset_limit; - List_iterator<Item> it(*direct_update_fields); + List_iterator<Item> it(*wide_handler->direct_update_fields); Item *item; Field *field; - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_update_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); if (thd->variables.time_zone != UTC) @@ -10313,14 +10074,21 @@ int ha_spider::direct_update_rows_init() #endif } #endif + if (!dml_inited) + { + if (unlikely(dml_init())) + { + DBUG_RETURN(HA_ERR_WRONG_COMMAND); + } + } direct_update_init( thd, FALSE ); - if (!condition) - cond_check = FALSE; + if (!wide_handler->condition) + wide_handler->cond_check = FALSE; spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); - if (direct_update_fields) + if (wide_handler->direct_update_fields) { if ( #if MYSQL_VERSION_ID < 50500 @@ -10356,20 +10124,20 @@ int ha_spider::direct_update_rows_init() } result_list.direct_order_limit = TRUE; } - trx->direct_update_count++; + wide_handler->trx->direct_update_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); } DBUG_PRINT("info",("spider offset_limit=%lld", offset_limit)); - DBUG_PRINT("info",("spider sql_command=%u", sql_command)); + DBUG_PRINT("info",("spider sql_command=%u", wide_handler->sql_command)); DBUG_PRINT("info",("spider do_direct_update=%s", do_direct_update ? "TRUE" : "FALSE")); if ( !offset_limit && do_direct_update ) { - trx->direct_update_count++; + wide_handler->trx->direct_update_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); } @@ -10418,6 +10186,13 @@ int ha_spider::pre_direct_update_rows_init( bulk_access_link_current->called = TRUE; DBUG_RETURN(error_num); } + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + DBUG_RETURN(error_num); + } + } #ifdef SPIDER_MDEV_16246 pre_direct_init_result = direct_update_rows_init( update_fields, mode, ranges, range_count, sorted, new_data); @@ -10462,6 +10237,13 @@ int ha_spider::pre_direct_update_rows_init() bulk_access_link_current->called = TRUE; DBUG_RETURN(error_num); } + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + DBUG_RETURN(error_num); + } + } #ifdef SPIDER_MDEV_16246 pre_direct_init_result = direct_update_rows_init(update_fields); #else @@ -10687,7 +10469,7 @@ int ha_spider::direct_delete_rows_init( st_select_lex *select_lex; longlong select_limit; longlong offset_limit; - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_delete_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); #ifdef HA_CAN_BULK_ACCESS @@ -10709,6 +10491,13 @@ int ha_spider::direct_delete_rows_init( mode, ranges, range_count, sorted)); } #endif + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + DBUG_RETURN(error_num); + } + } direct_update_init( thd, #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) @@ -10755,7 +10544,7 @@ int ha_spider::direct_delete_rows_init( } result_list.direct_order_limit = TRUE; } - trx->direct_delete_count++; + wide_handler->trx->direct_delete_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); } @@ -10778,7 +10567,7 @@ int ha_spider::direct_delete_rows_init( DBUG_RETURN(error_num); } #endif - trx->direct_delete_count++; + wide_handler->trx->direct_delete_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); } @@ -10792,7 +10581,7 @@ int ha_spider::direct_delete_rows_init() st_select_lex *select_lex; longlong select_limit; longlong offset_limit; - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_delete_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); #ifdef HA_CAN_BULK_ACCESS @@ -10813,12 +10602,19 @@ int ha_spider::direct_delete_rows_init() DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_delete_rows_init()); } #endif + if (!dml_inited) + { + if (unlikely(dml_init())) + { + DBUG_RETURN(HA_ERR_WRONG_COMMAND); + } + } direct_update_init( thd, FALSE ); - if (!condition) - cond_check = FALSE; + if (!wide_handler->condition) + wide_handler->cond_check = FALSE; spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); if ( #if MYSQL_VERSION_ID < 50500 @@ -10853,7 +10649,7 @@ int ha_spider::direct_delete_rows_init() } result_list.direct_order_limit = TRUE; } - trx->direct_delete_count++; + wide_handler->trx->direct_delete_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); } @@ -10879,6 +10675,13 @@ int ha_spider::pre_direct_delete_rows_init( bulk_access_link_current->called = TRUE; DBUG_RETURN(error_num); } + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + DBUG_RETURN(error_num); + } + } pre_direct_init_result = direct_delete_rows_init( mode, ranges, range_count, sorted); DBUG_RETURN(pre_direct_init_result); @@ -10897,6 +10700,13 @@ int ha_spider::pre_direct_delete_rows_init() bulk_access_link_current->called = TRUE; DBUG_RETURN(error_num); } + if (!dml_inited) + { + if (unlikely((error_num = dml_init()))) + { + DBUG_RETURN(error_num); + } + } pre_direct_init_result = direct_delete_rows_init(); DBUG_RETURN(pre_direct_init_result); } @@ -11060,7 +10870,8 @@ int ha_spider::delete_all_rows() sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; if ((error_num = spider_db_delete_all_rows(this))) DBUG_RETURN(check_error_mode(error_num)); - if (sql_command == SQLCOM_TRUNCATE && table->found_next_number_field) + if (wide_handler->sql_command == SQLCOM_TRUNCATE && + table->found_next_number_field) { DBUG_PRINT("info",("spider reset auto increment")); pthread_mutex_lock(&share->lgtm_tblhnd_share->auto_increment_mutex); @@ -11089,7 +10900,7 @@ int ha_spider::truncate() table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } - sql_command = SQLCOM_TRUNCATE; + wide_handler->sql_command = SQLCOM_TRUNCATE; if ((error_num = spider_check_trx_and_get_conn(thd, this, FALSE))) { DBUG_RETURN(error_num); @@ -11102,7 +10913,8 @@ int ha_spider::truncate() sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; if ((error_num = spider_db_delete_all_rows(this))) DBUG_RETURN(check_error_mode(error_num)); - if (sql_command == SQLCOM_TRUNCATE && table->found_next_number_field) + if (wide_handler->sql_command == SQLCOM_TRUNCATE && + table->found_next_number_field) { DBUG_PRINT("info",("spider reset auto increment")); pthread_mutex_lock(&share->lgtm_tblhnd_share->auto_increment_mutex); @@ -11122,10 +10934,10 @@ int ha_spider::truncate() void ha_spider::bulk_req_exec() { int need_mon; - SPIDER_CONN *conn = trx->bulk_access_conn_first; + SPIDER_CONN *conn = wide_handler->trx->bulk_access_conn_first; DBUG_ENTER("ha_spider::bulk_req_exec"); DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider trx=%p", trx)); + DBUG_PRINT("info",("spider trx=%p", wide_handler->trx)); DBUG_PRINT("info",("spider first_conn=%p", conn)); while (conn) { @@ -11162,7 +10974,7 @@ void ha_spider::bulk_req_exec() } conn = conn->bulk_access_next; } - trx->bulk_access_conn_first = NULL; + wide_handler->trx->bulk_access_conn_first = NULL; DBUG_VOID_RETURN; } #endif @@ -11183,7 +10995,7 @@ double ha_spider::read_time( ) { DBUG_ENTER("ha_spider::read_time"); DBUG_PRINT("info",("spider this=%p", this)); - if (keyread) + if (wide_handler->keyread) { DBUG_PRINT("info",("spider read_time(keyread) = %.6f", share->read_rate * table->key_info[index].key_length * @@ -11466,6 +11278,27 @@ void ha_spider::update_create_info( ) { DBUG_ENTER("ha_spider::update_create_info"); DBUG_PRINT("info",("spider this=%p", this)); + if (wide_handler && wide_handler->sql_command == SQLCOM_ALTER_TABLE) + { + SPIDER_TRX *trx = wide_handler->trx; + THD *thd = trx->thd; + if (trx->query_id != thd->query_id) + { + spider_free_trx_alter_table(trx); + trx->query_id = thd->query_id; + trx->tmp_flg = FALSE; + } + if (!(SPIDER_ALTER_TABLE*) my_hash_search(&trx->trx_alter_table_hash, + (uchar*) share->table_name, share->table_name_length)) + { + if (spider_create_trx_alter_table(trx, share, FALSE)) + { + store_error_num = HA_ERR_OUT_OF_MEM; + DBUG_VOID_RETURN; + } + } + } + if (!create_info->connect_string.str) { create_info->connect_string.str = table->s->connect_string.str; @@ -11984,6 +11817,34 @@ bool ha_spider::is_fatal_error( DBUG_RETURN(TRUE); } +int ha_spider::set_top_table_and_fields( + TABLE *top_table, + Field **top_table_field, + uint top_table_fields +) { + DBUG_ENTER("ha_spider::set_top_table_and_fields"); + if (!wide_handler->set_top_table_fields) + { + wide_handler->set_top_table_fields = TRUE; + wide_handler->top_table = top_table; + wide_handler->top_table_field = top_table_field; + wide_handler->top_table_fields = top_table_fields; + } + DBUG_RETURN(0); +} +void ha_spider::clear_top_table_fields() +{ + DBUG_ENTER("ha_spider::clear_top_table_fields"); + if (wide_handler->set_top_table_fields) + { + wide_handler->set_top_table_fields = FALSE; + wide_handler->top_table = NULL; + wide_handler->top_table_field = NULL; + wide_handler->top_table_fields = 0; + } + DBUG_VOID_RETURN; +} + Field *ha_spider::get_top_table_field( uint16 field_index ) { @@ -11997,9 +11858,9 @@ Field *ha_spider::get_top_table_field( #endif DBUG_PRINT("info",("spider field_index=%u", field_index)); #ifdef HANDLER_HAS_TOP_TABLE_FIELDS - if (set_top_table_fields) + if (wide_handler->set_top_table_fields) { - field = top_table->field[field_index]; + field = wide_handler->top_table->field[field_index]; } else { #endif field = table->field[field_index]; @@ -12023,12 +11884,12 @@ Field *ha_spider::field_exchange( DBUG_PRINT("info",("spider in field=%p", field)); DBUG_PRINT("info",("spider in field->table=%p", field->table)); #ifdef HANDLER_HAS_TOP_TABLE_FIELDS - if (set_top_table_fields) + if (wide_handler->set_top_table_fields) { - DBUG_PRINT("info",("spider top_table=%p", top_table)); - if (field->table != top_table) + DBUG_PRINT("info",("spider top_table=%p", wide_handler->top_table)); + if (field->table != wide_handler->top_table) DBUG_RETURN(NULL); - if (!(field = top_table_field[field->field_index])) + if (!(field = wide_handler->top_table_field[field->field_index])) DBUG_RETURN(NULL); } else { #endif @@ -12046,7 +11907,7 @@ const COND *ha_spider::cond_push( const COND *cond ) { DBUG_ENTER("ha_spider::cond_push"); - cond_check = FALSE; + wide_handler->cond_check = FALSE; if (cond) { SPIDER_CONDITION *tmp_cond; @@ -12055,8 +11916,8 @@ const COND *ha_spider::cond_push( ) DBUG_RETURN(cond); tmp_cond->cond = (COND *) cond; - tmp_cond->next = condition; - condition = tmp_cond; + tmp_cond->next = wide_handler->condition; + wide_handler->condition = tmp_cond; } DBUG_RETURN(NULL); } @@ -12064,11 +11925,11 @@ const COND *ha_spider::cond_push( void ha_spider::cond_pop() { DBUG_ENTER("ha_spider::cond_pop"); - if (condition) + if (wide_handler->condition) { - SPIDER_CONDITION *tmp_cond = condition->next; - spider_free(spider_current_trx, condition, MYF(0)); - condition = tmp_cond; + SPIDER_CONDITION *tmp_cond = wide_handler->condition->next; + spider_free(spider_current_trx, wide_handler->condition, MYF(0)); + wide_handler->condition = tmp_cond; } DBUG_VOID_RETURN; } @@ -12119,33 +11980,39 @@ int ha_spider::info_push( size_t roop_count; Field *field; SPIDER_HS_UINT32_INFO *tmp_info = (SPIDER_HS_UINT32_INFO *) info; - hs_pushed_ret_fields_num = tmp_info->info_size; - if (hs_pushed_ret_fields_size < hs_pushed_ret_fields_num) - { - if (hs_pushed_ret_fields) - spider_free(spider_current_trx, hs_pushed_ret_fields, MYF(0)); - if (!(hs_pushed_ret_fields = (uint32 *) + wide_handler->hs_pushed_ret_fields_num = tmp_info->info_size; + if (wide_handler->hs_pushed_ret_fields_size < + wide_handler->hs_pushed_ret_fields_num) + { + if (wide_handler->hs_pushed_ret_fields) + spider_free(spider_current_trx, wide_handler->hs_pushed_ret_fields, + MYF(0)); + if (!(wide_handler->hs_pushed_ret_fields = (uint32 *) spider_bulk_malloc(spider_current_trx, 17, MYF(MY_WME), - &hs_pushed_ret_fields, sizeof(uint32) * hs_pushed_ret_fields_num, + &wide_handler->hs_pushed_ret_fields, + sizeof(uint32) * wide_handler->hs_pushed_ret_fields_num, NullS)) ) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } - hs_pushed_ret_fields_size = hs_pushed_ret_fields_num; + wide_handler->hs_pushed_ret_fields_size = + wide_handler->hs_pushed_ret_fields_num; } - memcpy(hs_pushed_ret_fields, tmp_info->info, - sizeof(uint32) * hs_pushed_ret_fields_num); + memcpy(wide_handler->hs_pushed_ret_fields, tmp_info->info, + sizeof(uint32) * wide_handler->hs_pushed_ret_fields_num); bitmap_clear_all(table->read_set); bitmap_clear_all(table->write_set); - hs_pushed_lcl_fields_num = 0; - for (roop_count = 0; roop_count < hs_pushed_ret_fields_num; roop_count++) + wide_handler->hs_pushed_lcl_fields_num = 0; + for (roop_count = 0; roop_count < wide_handler->hs_pushed_ret_fields_num; + roop_count++) { - field = get_top_table_field(hs_pushed_ret_fields[roop_count]); + field = get_top_table_field( + wide_handler->hs_pushed_ret_fields[roop_count]); if ((field = field_exchange(field))) { if (!bitmap_is_set(table->read_set, field->field_index)) { - ++hs_pushed_lcl_fields_num; + ++wide_handler->hs_pushed_lcl_fields_num; bitmap_set_bit(table->read_set, field->field_index); bitmap_set_bit(table->write_set, field->field_index); } @@ -12167,172 +12034,168 @@ int ha_spider::info_push( } #endif Field *field; - if (hs_pushed_ret_fields) + if (wide_handler->hs_pushed_ret_fields) { field = get_top_table_field( - hs_pushed_ret_fields[hs_pushed_strref_num]); + wide_handler->hs_pushed_ret_fields[ + wide_handler->hs_pushed_strref_num]); } else { field = get_top_table_field( - pt_clone_source_handler->hs_pushed_ret_fields[hs_pushed_strref_num]); + pt_clone_source_handler->wide_handler->hs_pushed_ret_fields[ + wide_handler->hs_pushed_strref_num]); } if (!field_exchange(field)) { - hs_pushed_strref_num++; + wide_handler->hs_pushed_strref_num++; break; } - hs_pushed_strref_num++; - if ((error_num = push_back_hs_upds(*((SPIDER_HS_STRING_REF*) info)))) + wide_handler->hs_pushed_strref_num++; + if (partition_handler_share && partition_handler_share->handlers) { - DBUG_RETURN(error_num); + size_t roop_count; + ha_spider **handlers = partition_handler_share->handlers; + for (roop_count = 0; roop_count < partition_handler_share->no_parts; + ++roop_count) + { + if ((error_num = handlers[roop_count]->push_back_hs_upds( + *((SPIDER_HS_STRING_REF*) info)))) + { + DBUG_RETURN(error_num); + } + } + } else { + if ((error_num = push_back_hs_upds(*((SPIDER_HS_STRING_REF*) info)))) + { + DBUG_RETURN(error_num); + } } break; } case INFO_KIND_HS_CLEAR_STRING_REF: DBUG_PRINT("info",("spider INFO_KIND_HS_CLEAR_STRING_REF")); - hs_pushed_strref_num = 0; - if ((error_num = reset_hs_upds(SPIDER_SQL_TYPE_UPDATE_HS))) + wide_handler->hs_pushed_strref_num = 0; + if (partition_handler_share && partition_handler_share->handlers) { - DBUG_RETURN(error_num); + size_t roop_count; + ha_spider **handlers = partition_handler_share->handlers; + for (roop_count = 0; roop_count < partition_handler_share->no_parts; + ++roop_count) + { + if ((error_num = handlers[roop_count]->reset_hs_upds( + SPIDER_SQL_TYPE_UPDATE_HS))) + { + DBUG_RETURN(error_num); + } + } + } else { + if ((error_num = reset_hs_upds(SPIDER_SQL_TYPE_UPDATE_HS))) + { + DBUG_RETURN(error_num); + } } break; case INFO_KIND_HS_INCREMENT_BEGIN: DBUG_PRINT("info",("spider INFO_KIND_HS_INCREMENT_BEGIN")); - hs_increment = TRUE; + wide_handler->hs_increment = TRUE; break; case INFO_KIND_HS_INCREMENT_END: DBUG_PRINT("info",("spider INFO_KIND_HS_INCREMENT_END")); - hs_increment = FALSE; + wide_handler->hs_increment = FALSE; break; case INFO_KIND_HS_DECREMENT_BEGIN: DBUG_PRINT("info",("spider INFO_KIND_HS_DECREMENT_BEGIN")); - hs_decrement = TRUE; + wide_handler->hs_decrement = TRUE; break; case INFO_KIND_HS_DECREMENT_END: DBUG_PRINT("info",("spider INFO_KIND_HS_DECREMENT_END")); - hs_decrement = FALSE; + wide_handler->hs_decrement = FALSE; break; #endif #ifdef INFO_KIND_UPDATE_FIELDS case INFO_KIND_UPDATE_FIELDS: DBUG_PRINT("info",("spider INFO_KIND_UPDATE_FIELDS")); - direct_update_fields = (List<Item> *) info; - update_request = TRUE; + wide_handler->direct_update_fields = (List<Item> *) info; + wide_handler->update_request = TRUE; #ifdef WITH_PARTITION_STORAGE_ENGINE - if (keyread && check_partitioned()) - keyread = FALSE; + if (wide_handler->keyread && check_partitioned()) + wide_handler->keyread = FALSE; #endif break; #endif #ifdef INFO_KIND_UPDATE_VALUES case INFO_KIND_UPDATE_VALUES: DBUG_PRINT("info",("spider INFO_KIND_UPDATE_VALUES")); - direct_update_values = (List<Item> *) info; + wide_handler->direct_update_values = (List<Item> *) info; break; #endif #ifdef INFO_KIND_FORCE_LIMIT_BEGIN case INFO_KIND_FORCE_LIMIT_BEGIN: DBUG_PRINT("info",("spider INFO_KIND_FORCE_LIMIT_BEGIN")); - info_limit = *((longlong *) info); -/* - trx->direct_aggregate_count++; -*/ + wide_handler->info_limit = *((longlong *) info); break; case INFO_KIND_FORCE_LIMIT_END: DBUG_PRINT("info",("spider INFO_KIND_FORCE_LIMIT_END")); - info_limit = 9223372036854775807LL; + wide_handler->info_limit = 9223372036854775807LL; break; #endif #endif #ifdef HA_CAN_BULK_ACCESS case INFO_KIND_BULK_ACCESS_BEGIN: DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_BEGIN")); - if (bulk_access_started) + if (partition_handler_share && partition_handler_share->handlers) { - if (!bulk_access_link_current->next) + size_t roop_count; + ha_spider **handlers = partition_handler_share->handlers; + for (roop_count = 0; roop_count < partition_handler_share->no_parts; + ++roop_count) { - if (!(bulk_access_link_current->next = create_bulk_access_link())) + if ((error_num = handlers[roop_count]->bulk_access_begin(info))) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_RETURN(error_num); } - bulk_access_link_current->next->sequence_num = - bulk_access_link_current->sequence_num + 1; } - bulk_access_link_current = bulk_access_link_current->next; } else { - if (!bulk_access_link_first) + if ((error_num = bulk_access_begin(info))) { - if (!(bulk_access_link_first = create_bulk_access_link())) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - bulk_access_link_first->sequence_num = 0; + DBUG_RETURN(error_num); } - bulk_access_link_current = bulk_access_link_first; - bulk_access_started = TRUE; - bulk_access_executing = FALSE; - } - if ( - (error_num = bulk_access_link_current->spider-> - sync_from_clone_source(this)) || - (error_num = bulk_access_link_current->spider-> - check_access_kind(trx->thd, (lock_type >= TL_WRITE_ALLOW_WRITE))) - ) { - DBUG_RETURN(error_num); - } -#ifdef HA_CAN_BULK_ACCESS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - memset( - bulk_access_link_current->spider->result_list.hs_r_bulk_open_index, 0, - share->link_bitmap_size); - memset( - bulk_access_link_current->spider->result_list.hs_w_bulk_open_index, 0, - share->link_bitmap_size); -#endif -#endif -/* -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = bulk_access_link_current->spider->reset_hs_strs_pos( - SPIDER_SQL_TYPE_UPDATE_HS))) - { - DBUG_RETURN(error_num); } -#endif -*/ - bulk_access_link_current->spider->bulk_access_executing = FALSE; - bulk_access_link_current->spider->bulk_access_pre_called = FALSE; - bulk_access_link_current->used = TRUE; - bulk_access_link_current->called = FALSE; - *((void **) info) = bulk_access_link_current; break; case INFO_KIND_BULK_ACCESS_CURRENT: DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_CURRENT")); - bulk_access_executing = TRUE; - bulk_access_link_exec_tgt = (SPIDER_BULK_ACCESS_LINK *) info; - if (bulk_access_link_exec_tgt->spider->pt_clone_source_handler != this) - { - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider pt_clone_source_handler=%p", - bulk_access_link_exec_tgt->spider->pt_clone_source_handler)); - /* partitioned */ - uint sequence_num = bulk_access_link_exec_tgt->sequence_num; - for ( - bulk_access_link_exec_tgt = bulk_access_link_first; - bulk_access_link_exec_tgt; - bulk_access_link_exec_tgt = bulk_access_link_exec_tgt->next - ) { - if (bulk_access_link_exec_tgt->sequence_num >= sequence_num) + if (partition_handler_share && partition_handler_share->handlers) + { + size_t roop_count; + ha_spider **handlers = partition_handler_share->handlers; + for (roop_count = 0; roop_count < partition_handler_share->no_parts; + ++roop_count) + { + if ((error_num = handlers[roop_count]->bulk_access_current(info))) { - DBUG_ASSERT( - bulk_access_link_exec_tgt->sequence_num == sequence_num); - break; + DBUG_RETURN(error_num); } } + } else { + if ((error_num = bulk_access_current(info))) + { + DBUG_RETURN(error_num); + } } - bulk_access_link_exec_tgt->spider->bulk_access_executing = TRUE; break; case INFO_KIND_BULK_ACCESS_END: DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_END")); - bulk_access_started = FALSE; + if (partition_handler_share && partition_handler_share->handlers) + { + size_t roop_count; + ha_spider **handlers = partition_handler_share->handlers; + for (roop_count = 0; roop_count < partition_handler_share->no_parts; + ++roop_count) + { + handlers[roop_count]->bulk_access_end(); + } + } else { + bulk_access_end(); + } break; #endif default: @@ -12398,7 +12261,8 @@ void ha_spider::set_ft_discard_bitmap() if (!field || !(field = field_exchange(field))) continue; DBUG_PRINT("info",("spider clear_bit=%u", field->field_index)); - spider_clear_bit(ft_discard_bitmap, field->field_index); + spider_clear_bit(wide_handler->ft_discard_bitmap, + field->field_index); } } } @@ -12424,7 +12288,8 @@ void ha_spider::set_ft_discard_bitmap() if (!field || !(field = field_exchange(field))) continue; DBUG_PRINT("info",("spider field_index=%u", field->field_index)); - if (!spider_bit_is_set(ft_discard_bitmap, field->field_index)) + if (!spider_bit_is_set(wide_handler->ft_discard_bitmap, + field->field_index)) { bool match_flag = FALSE; List_iterator_fast<Item_func_match> fmi(*select_lex->ftfunc_list); @@ -12450,7 +12315,8 @@ void ha_spider::set_ft_discard_bitmap() if (!match_flag) { DBUG_PRINT("info",("spider set_bit=%u", field->field_index)); - spider_set_bit(ft_discard_bitmap, field->field_index); + spider_set_bit(wide_handler->ft_discard_bitmap, + field->field_index); } } } @@ -12466,18 +12332,19 @@ void ha_spider::set_searched_bitmap() for (roop_count = 0; roop_count < (int) ((table_share->fields + 7) / 8); roop_count++) { - searched_bitmap[roop_count] = + wide_handler->searched_bitmap[roop_count] = ((uchar *) table->read_set->bitmap)[roop_count] | ((uchar *) table->write_set->bitmap)[roop_count]; DBUG_PRINT("info",("spider roop_count=%d", roop_count)); DBUG_PRINT("info",("spider searched_bitmap=%d", - searched_bitmap[roop_count])); + wide_handler->searched_bitmap[roop_count])); DBUG_PRINT("info",("spider read_set=%d", ((uchar *) table->read_set->bitmap)[roop_count])); DBUG_PRINT("info",("spider write_set=%d", ((uchar *) table->write_set->bitmap)[roop_count])); } - if (sql_command == SQLCOM_UPDATE || sql_command == SQLCOM_UPDATE_MULTI) + if (wide_handler->sql_command == SQLCOM_UPDATE || + wide_handler->sql_command == SQLCOM_UPDATE_MULTI) { DBUG_PRINT("info",("spider update option start")); Item *item; @@ -12493,7 +12360,7 @@ void ha_spider::set_searched_bitmap() DBUG_PRINT("info",("spider field is for different table")); continue; } - spider_set_bit(searched_bitmap, field->field_index); + spider_set_bit(wide_handler->searched_bitmap, field->field_index); DBUG_PRINT("info",("spider set searched_bitmap=%u", field->field_index)); } else { @@ -12507,23 +12374,26 @@ void ha_spider::set_searched_bitmap() void ha_spider::set_clone_searched_bitmap() { DBUG_ENTER("ha_spider::set_clone_searched_bitmap"); - DBUG_PRINT("info",("spider searched_bitmap=%p", searched_bitmap)); + DBUG_PRINT("info",("spider searched_bitmap=%p", + wide_handler->searched_bitmap)); #ifndef DBUG_OFF int roop_count; for (roop_count = 0; roop_count < (int) ((table_share->fields + 7) / 8); roop_count++) DBUG_PRINT("info", ("spider before searched_bitmap is %x", - ((uchar *) searched_bitmap)[roop_count])); + ((uchar *) wide_handler->searched_bitmap)[roop_count])); #endif - memcpy(searched_bitmap, pt_clone_source_handler->searched_bitmap, + memcpy(wide_handler->searched_bitmap, + pt_clone_source_handler->wide_handler->searched_bitmap, (table_share->fields + 7) / 8); #ifndef DBUG_OFF for (roop_count = 0; roop_count < (int) ((table_share->fields + 7) / 8); roop_count++) DBUG_PRINT("info", ("spider after searched_bitmap is %x", - ((uchar *) searched_bitmap)[roop_count])); + ((uchar *) wide_handler->searched_bitmap)[roop_count])); #endif - memcpy(ft_discard_bitmap, pt_clone_source_handler->ft_discard_bitmap, + memcpy(wide_handler->ft_discard_bitmap, + pt_clone_source_handler->wide_handler->ft_discard_bitmap, (table_share->fields + 7) / 8); DBUG_VOID_RETURN; } @@ -12555,7 +12425,7 @@ void ha_spider::set_searched_bitmap_from_item_list() if (!field || !(field = field_exchange(field))) continue; DBUG_PRINT("info",("spider field_index=%u", field->field_index)); - spider_set_bit(searched_bitmap, field->field_index); + spider_set_bit(wide_handler->searched_bitmap, field->field_index); } DBUG_VOID_RETURN; } @@ -12566,9 +12436,9 @@ void ha_spider::set_select_column_mode() KEY *key_info; KEY_PART_INFO *key_part; Field *field; - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::set_select_column_mode"); - position_bitmap_init = FALSE; + wide_handler->position_bitmap_init = FALSE; #ifndef DBUG_OFF for (roop_count = 0; roop_count < (int) ((table_share->fields + 7) / 8); roop_count++) @@ -12579,72 +12449,48 @@ void ha_spider::set_select_column_mode() share->select_column_mode); if (select_column_mode) { - DBUG_PRINT("info",("spider searched_bitmap=%p", searched_bitmap)); -#ifdef WITH_PARTITION_STORAGE_ENGINE - if ( - partition_handler_share && - partition_handler_share->searched_bitmap - ) { - if (partition_handler_share->searched_bitmap != searched_bitmap) - { - memcpy(searched_bitmap, partition_handler_share->searched_bitmap, - (table_share->fields + 7) / 8); - memcpy(ft_discard_bitmap, partition_handler_share->ft_discard_bitmap, - (table_share->fields + 7) / 8); - } - partition_handler_share->between_flg = FALSE; - DBUG_PRINT("info",("spider copy searched_bitmap")); - } else { -#endif - set_searched_bitmap(); - set_searched_bitmap_from_item_list(); - if (result_list.lock_type == F_WRLCK && sql_command != SQLCOM_SELECT) - { + DBUG_PRINT("info",("spider searched_bitmap=%p", + wide_handler->searched_bitmap)); + set_searched_bitmap(); + set_searched_bitmap_from_item_list(); + if (wide_handler->external_lock_type == F_WRLCK && + wide_handler->sql_command != SQLCOM_SELECT) + { #ifdef WITH_PARTITION_STORAGE_ENGINE - uint part_num = 0; - if (update_request) - part_num = check_partitioned(); + uint part_num = 0; + if (wide_handler->update_request) + part_num = check_partitioned(); #endif - if ( + if ( #ifdef WITH_PARTITION_STORAGE_ENGINE - part_num || + part_num || #endif - table_share->primary_key == MAX_KEY - ) { - /* need all columns */ - for (roop_count = 0; roop_count < (int) table_share->fields; - roop_count++) - spider_set_bit(searched_bitmap, roop_count); - } else { - /* need primary key columns */ - key_info = &table_share->key_info[table_share->primary_key]; - key_part = key_info->key_part; - for (roop_count = 0; - roop_count < (int) spider_user_defined_key_parts(key_info); - roop_count++) - { - field = key_part[roop_count].field; - spider_set_bit(searched_bitmap, field->field_index); - } - } -#ifndef DBUG_OFF + table_share->primary_key == MAX_KEY + ) { + /* need all columns */ + for (roop_count = 0; roop_count < (int) table_share->fields; + roop_count++) + spider_set_bit(wide_handler->searched_bitmap, roop_count); + } else { + /* need primary key columns */ + key_info = &table_share->key_info[table_share->primary_key]; + key_part = key_info->key_part; for (roop_count = 0; - roop_count < (int) ((table_share->fields + 7) / 8); + roop_count < (int) spider_user_defined_key_parts(key_info); roop_count++) - DBUG_PRINT("info", ("spider change bitmap is %x", - searched_bitmap[roop_count])); -#endif - } -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (partition_handler_share) - { - partition_handler_share->searched_bitmap = searched_bitmap; - partition_handler_share->ft_discard_bitmap = ft_discard_bitmap; - partition_handler_share->between_flg = TRUE; - DBUG_PRINT("info",("spider set searched_bitmap")); + { + field = key_part[roop_count].field; + spider_set_bit(wide_handler->searched_bitmap, field->field_index); + } } - } +#ifndef DBUG_OFF + for (roop_count = 0; + roop_count < (int) ((table_share->fields + 7) / 8); + roop_count++) + DBUG_PRINT("info", ("spider change bitmap is %x", + wide_handler->searched_bitmap[roop_count])); #endif + } } DBUG_VOID_RETURN; } @@ -12652,55 +12498,55 @@ void ha_spider::set_select_column_mode() #ifdef WITH_PARTITION_STORAGE_ENGINE void ha_spider::check_select_column(bool rnd) { - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::check_select_column"); select_column_mode = spider_param_select_column_mode(thd, share->select_column_mode); - if (select_column_mode && partition_handler_share) + if (select_column_mode) { if (!rnd) { - if (partition_handler_share->between_flg) + if (wide_handler->between_flg) { - memcpy(partition_handler_share->idx_read_bitmap, + memcpy(wide_handler->idx_read_bitmap, table->read_set->bitmap, (table_share->fields + 7) / 8); - memcpy(partition_handler_share->idx_write_bitmap, + memcpy(wide_handler->idx_write_bitmap, table->write_set->bitmap, (table_share->fields + 7) / 8); - partition_handler_share->between_flg = FALSE; - partition_handler_share->idx_bitmap_is_set = TRUE; + wide_handler->between_flg = FALSE; + wide_handler->idx_bitmap_is_set = TRUE; DBUG_PRINT("info",("spider set idx_bitmap")); - } else if (partition_handler_share->idx_bitmap_is_set) + } else if (wide_handler->idx_bitmap_is_set) { memcpy(table->read_set->bitmap, - partition_handler_share->idx_read_bitmap, + wide_handler->idx_read_bitmap, (table_share->fields + 7) / 8); memcpy(table->write_set->bitmap, - partition_handler_share->idx_write_bitmap, + wide_handler->idx_write_bitmap, (table_share->fields + 7) / 8); DBUG_PRINT("info",("spider copy idx_bitmap")); } } else { if ( - !partition_handler_share->rnd_bitmap_is_set && + !wide_handler->rnd_bitmap_is_set && ( - partition_handler_share->between_flg || - partition_handler_share->idx_bitmap_is_set + wide_handler->between_flg || + wide_handler->idx_bitmap_is_set ) ) { - memcpy(partition_handler_share->rnd_read_bitmap, + memcpy(wide_handler->rnd_read_bitmap, table->read_set->bitmap, (table_share->fields + 7) / 8); - memcpy(partition_handler_share->rnd_write_bitmap, + memcpy(wide_handler->rnd_write_bitmap, table->write_set->bitmap, (table_share->fields + 7) / 8); - partition_handler_share->between_flg = FALSE; - partition_handler_share->rnd_bitmap_is_set = TRUE; + wide_handler->between_flg = FALSE; + wide_handler->rnd_bitmap_is_set = TRUE; DBUG_PRINT("info",("spider set rnd_bitmap")); - } else if (partition_handler_share->rnd_bitmap_is_set) + } else if (wide_handler->rnd_bitmap_is_set) { memcpy(table->read_set->bitmap, - partition_handler_share->rnd_read_bitmap, + wide_handler->rnd_read_bitmap, (table_share->fields + 7) / 8); memcpy(table->write_set->bitmap, - partition_handler_share->rnd_write_bitmap, + wide_handler->rnd_write_bitmap, (table_share->fields + 7) / 8); DBUG_PRINT("info",("spider copy rnd_bitmap")); } @@ -12919,11 +12765,11 @@ int ha_spider::check_ha_range_eof() result_list.use_both_key ? "TRUE" : "FALSE")); DBUG_PRINT("info",("spider sql_kind[%u]=%u", search_link_idx, sql_kind[search_link_idx])); - DBUG_PRINT("info",("spider sql_command=%u", sql_command)); + DBUG_PRINT("info",("spider sql_command=%u", wide_handler->sql_command)); if ( result_list.use_both_key && (sql_kind[search_link_idx] & SPIDER_SQL_KIND_HANDLER) && - sql_command != SQLCOM_HA_READ + wide_handler->sql_command != SQLCOM_HA_READ ) { int cmp_result = key_cmp(result_list.key_info->key_part, end_key->key, end_key->length); @@ -13001,8 +12847,8 @@ int ha_spider::drop_tmp_tables() need_mons[roop_count] ) { tmp_error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -13022,7 +12868,7 @@ int ha_spider::drop_tmp_tables() if (!tmp_error_num) { spider_conn_set_timeout_from_share(conn, roop_count, - trx->thd, share); + wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL, conn, @@ -13037,8 +12883,8 @@ int ha_spider::drop_tmp_tables() need_mons[roop_count] ) { tmp_error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -13157,8 +13003,8 @@ int ha_spider::close_opened_handler( need_mons[link_idx] ) { error_num2 = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, link_idx, (uint32) share->monitoring_sid[link_idx], @@ -13176,9 +13022,10 @@ int ha_spider::close_opened_handler( error_num = error_num2; } spider_clear_bit(m_handler_opened, link_idx); - if (release_conn) + if (release_conn && !conns[link_idx]->join_trx) { - spider_free_conn_from_trx(trx, conns[link_idx], FALSE, FALSE, NULL); + spider_free_conn_from_trx(wide_handler->trx, conns[link_idx], + FALSE, FALSE, NULL); conns[link_idx] = NULL; } } @@ -13193,8 +13040,8 @@ int ha_spider::close_opened_handler( need_mons[link_idx] ) { error_num2 = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, link_idx, (uint32) share->monitoring_sid[link_idx], @@ -13212,16 +13059,18 @@ int ha_spider::close_opened_handler( error_num = error_num2; } spider_clear_bit(r_handler_opened, link_idx); - if (release_conn) + if (release_conn && !hs_w_conns[link_idx]->join_trx) { if ( !hs_r_conns[link_idx]->opened_handlers && - trx->trx_hs_r_conn_adjustment == trx_hs_r_conn_adjustment && - spider_param_hs_r_conn_recycle_mode(trx->thd) != 2 + wide_handler->trx->trx_hs_r_conn_adjustment == + trx_hs_r_conn_adjustment && + spider_param_hs_r_conn_recycle_mode(wide_handler->trx->thd) != 2 ) { - trx->trx_hs_r_conn_adjustment++; + wide_handler->trx->trx_hs_r_conn_adjustment++; } - spider_free_conn_from_trx(trx, hs_r_conns[link_idx], FALSE, FALSE, NULL); + spider_free_conn_from_trx(wide_handler->trx, hs_r_conns[link_idx], + FALSE, FALSE, NULL); hs_r_conns[link_idx] = NULL; } } @@ -13235,8 +13084,8 @@ int ha_spider::close_opened_handler( need_mons[link_idx] ) { error_num2 = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, link_idx, (uint32) share->monitoring_sid[link_idx], @@ -13254,16 +13103,18 @@ int ha_spider::close_opened_handler( error_num = error_num2; } spider_clear_bit(w_handler_opened, link_idx); - if (release_conn) + if (release_conn && !hs_w_conns[link_idx]->join_trx) { if ( !hs_w_conns[link_idx]->opened_handlers && - trx->trx_hs_w_conn_adjustment == trx_hs_w_conn_adjustment && - spider_param_hs_w_conn_recycle_mode(trx->thd) != 2 + wide_handler->trx->trx_hs_w_conn_adjustment == + trx_hs_w_conn_adjustment && + spider_param_hs_w_conn_recycle_mode(wide_handler->trx->thd) != 2 ) { - trx->trx_hs_w_conn_adjustment++; + wide_handler->trx->trx_hs_w_conn_adjustment++; } - spider_free_conn_from_trx(trx, hs_w_conns[link_idx], FALSE, FALSE, NULL); + spider_free_conn_from_trx(wide_handler->trx, hs_w_conns[link_idx], + FALSE, FALSE, NULL); hs_w_conns[link_idx] = NULL; } } @@ -13337,8 +13188,8 @@ int ha_spider::index_handler_init() need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -13444,8 +13295,8 @@ int ha_spider::rnd_handler_init() need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, + wide_handler->trx, + wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -13632,7 +13483,7 @@ void ha_spider::check_pre_call( thd->query_id != partition_handler_share->parallel_search_query_id ) { partition_handler_share->parallel_search_query_id = thd->query_id; - ++trx->parallel_search_count; + ++wide_handler->trx->parallel_search_count; } use_pre_call = use_parallel; if (!use_pre_call) @@ -13654,7 +13505,7 @@ void ha_spider::check_pre_call( #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS void ha_spider::check_insert_dup_update_pushdown() { - THD *thd = trx->thd; + THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::check_insert_dup_update_pushdown"); DBUG_PRINT("info",("spider this=%p", this)); if (!spider_param_direct_dup_insert(thd, share->direct_dup_insert)) @@ -13662,8 +13513,8 @@ void ha_spider::check_insert_dup_update_pushdown() DBUG_PRINT("info",("spider FALSE by direct_dup_insert")); DBUG_VOID_RETURN; } - direct_update_fields = &thd->lex->update_list; - direct_update_values = &thd->lex->value_list; + wide_handler->direct_update_fields = &thd->lex->update_list; + wide_handler->direct_update_values = &thd->lex->value_list; if (!append_dup_update_pushdown_sql_part(NULL, 0)) { result_list.insert_dup_update_pushdown = TRUE; @@ -13758,14 +13609,14 @@ int ha_spider::sync_from_clone_source( if (!synced_from_clone_source) { DBUG_PRINT("info",("spider synced from clone source all")); - trx = spider->trx; + wide_handler->trx = spider->wide_handler->trx; sql_command = spider->sql_command; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) conn_kinds = spider->conn_kinds; memcpy(conn_kind, spider->conn_kind, sizeof(uint) * share->link_count); #endif - result_list.lock_type = spider->result_list.lock_type; - lock_type = spider->lock_type; + wide_handler->external_lock_type = + spider->wide_handler->external_lock_type; selupd_lock_mode = spider->selupd_lock_mode; update_request = spider->update_request; lock_mode = spider->lock_mode; @@ -13806,8 +13657,8 @@ int ha_spider::sync_from_clone_source( conn_kinds = spider->conn_kinds; memcpy(conn_kind, spider->conn_kind, sizeof(uint) * share->link_count); #endif - result_list.lock_type = spider->result_list.lock_type; - lock_type = spider->lock_type; + wide_handler->external_lock_type = + spider->wide_handler->external_lock_type; selupd_lock_mode = spider->selupd_lock_mode; update_request = spider->update_request; lock_mode = spider->lock_mode; @@ -13815,7 +13666,8 @@ int ha_spider::sync_from_clone_source( insert_delayed = spider->insert_delayed; low_priority = spider->low_priority; - if ((error_num = spider_check_trx_and_get_conn(spider->trx->thd, + if ((error_num = spider_check_trx_and_get_conn( + spider->wide_handler->trx->thd, this, TRUE))) { DBUG_RETURN(error_num); @@ -14808,7 +14660,7 @@ int ha_spider::append_sum_select_sql_part( DBUG_RETURN(error_num); } } - trx->direct_aggregate_count++; + wide_handler->trx->direct_aggregate_count++; DBUG_RETURN(0); } #endif @@ -15772,14 +15624,16 @@ int ha_spider::mk_bulk_tmp_table_and_bulk_start() if ( !tmp_table[roop_count] && !(tmp_table[roop_count] = spider_mk_sys_tmp_table( - trx->thd, table, &result_list.upd_tmp_tbl_prms[roop_count], + wide_handler->trx->thd, table, + &result_list.upd_tmp_tbl_prms[roop_count], &field_name, result_list.update_sqls[roop_count].charset())) ) #else if ( !tmp_table[roop_count] && !(tmp_table[roop_count] = spider_mk_sys_tmp_table( - trx->thd, table, &result_list.upd_tmp_tbl_prms[roop_count], "a", + wide_handler->trx->thd, table, + &result_list.upd_tmp_tbl_prms[roop_count], "a", result_list.update_sqls[roop_count].charset())) ) #endif @@ -15799,7 +15653,8 @@ error_2: if (tmp_table[roop_count - 1]) { tmp_table[roop_count - 1]->file->ha_end_bulk_insert(); - spider_rm_sys_tmp_table(trx->thd, tmp_table[roop_count - 1], + spider_rm_sys_tmp_table(wide_handler->trx->thd, + tmp_table[roop_count - 1], &result_list.upd_tmp_tbl_prms[roop_count - 1]); tmp_table[roop_count - 1] = NULL; } @@ -15828,7 +15683,8 @@ void ha_spider::rm_bulk_tmp_table() { if (tmp_table[roop_count - 1]) { - spider_rm_sys_tmp_table(trx->thd, tmp_table[roop_count - 1], + spider_rm_sys_tmp_table(wide_handler->trx->thd, + tmp_table[roop_count - 1], &result_list.upd_tmp_tbl_prms[roop_count - 1]); tmp_table[roop_count - 1] = NULL; } @@ -15964,3 +15820,503 @@ int ha_spider::set_union_table_name_pos_sql() } DBUG_RETURN(0); } + +int ha_spider::lock_tables() +{ + int error_num, roop_count; + DBUG_ENTER("ha_spider::lock_tables"); + DBUG_PRINT("info",("spider lock_table_type=%u", + wide_handler->lock_table_type)); + + if ((error_num = spider_check_trx_and_get_conn(wide_handler->trx->thd, this, + FALSE))) + { + DBUG_RETURN(error_num); + } + + if (wide_handler->lock_table_type == 1) + { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + SPIDER_CONN *conn = conns[roop_count]; + int appended = 0; + if ((error_num = dbton_handler[conn->dbton_id]-> + append_lock_tables_list(conn, roop_count, &appended))) + { + DBUG_RETURN(error_num); + } + if (appended) + { + conn->table_lock = 2; + } + } + } else if (wide_handler->lock_table_type == 2) + { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if ( + conns[roop_count] && + conns[roop_count]->table_lock != 1 && + spider_param_semi_table_lock(wide_handler->trx->thd, + share->semi_table_lock) + ) { + SPIDER_CONN *conn = conns[roop_count]; + int appended = 0; + if ((error_num = dbton_handler[conn->dbton_id]-> + append_lock_tables_list(conn, roop_count, &appended))) + { + DBUG_RETURN(error_num); + } + if (appended) + { + conn->table_lock = 3; + } + } + } + } + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((conn_kinds & SPIDER_CONN_KIND_MYSQL)) + { +#endif + if (!conns[search_link_idx]) + { + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if (wide_handler->sql_command != SQLCOM_UNLOCK_TABLES) + { + DBUG_PRINT("info",("spider conns[%d]->join_trx=%u", + roop_count, conns[roop_count]->join_trx)); + if ( + (!conns[roop_count]->join_trx && + (error_num = spider_internal_start_trx_for_connection(this, + conns[roop_count], + roop_count))) + ) { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + wide_handler->trx, + wide_handler->trx->thd, + share, + roop_count, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + share->monitoring_flag[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode(error_num)); + } + reset_first_link_idx(); + } + if (conns[roop_count]->table_lock >= 2) + { + if ( + conns[roop_count]->db_conn->have_lock_table_list() && + (error_num = spider_db_lock_tables(this, roop_count)) + ) { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + wide_handler->trx, + wide_handler->trx->thd, + share, + roop_count, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + share->monitoring_flag[roop_count], + TRUE + ); + } + conns[roop_count]->table_lock = 0; + DBUG_RETURN(check_error_mode(error_num)); + } + if (conns[roop_count]->table_lock == 2) + conns[roop_count]->table_lock = 1; + } else if (wide_handler->sql_command == SQLCOM_UNLOCK_TABLES || + spider_param_internal_unlock(wide_handler->trx->thd) == 1) + { + if (conns[roop_count]->table_lock == 1) + { + conns[roop_count]->table_lock = 0; + if (!conns[roop_count]->trx_start) + conns[roop_count]->disable_reconnect = FALSE; + if ((error_num = spider_db_unlock_tables(this, roop_count))) + { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + wide_handler->trx, + wide_handler->trx->thd, + share, + roop_count, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + share->monitoring_flag[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode(error_num)); + } + } + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + DBUG_RETURN(0); +} + +int ha_spider::dml_init() +{ + int error_num, roop_count; + SPIDER_TRX *trx = wide_handler->trx; + THD *thd = trx->thd; + bool sync_trx_isolation = spider_param_sync_trx_isolation(thd); + DBUG_ENTER("ha_spider::dml_init"); + if (wide_handler->lock_mode == -2) + { + wide_handler->lock_mode = spider_param_selupd_lock_mode(thd, + share->selupd_lock_mode); + } + if ((error_num = check_access_kind_for_connection(thd, + (wide_handler->lock_type >= TL_WRITE_ALLOW_WRITE)))) + { + DBUG_RETURN(error_num); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((conn_kinds & SPIDER_CONN_KIND_MYSQL)) + { +#endif + if (!conns[search_link_idx]) + { + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } + if (wide_handler->sql_command == SQLCOM_TRUNCATE) + DBUG_RETURN(0); + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + DBUG_PRINT("info",("spider conns[%d]->join_trx=%u", + roop_count, conns[roop_count]->join_trx)); + if ( + (!conns[roop_count]->join_trx && + (error_num = spider_internal_start_trx_for_connection(this, + conns[roop_count], + roop_count))) + ) { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + roop_count, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + share->monitoring_flag[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode(error_num)); + } + reset_first_link_idx(); + if ( + conns[roop_count]->semi_trx_isolation == -2 && + conns[roop_count]->semi_trx_isolation_chk == TRUE && + sync_trx_isolation && + spider_param_semi_trx_isolation(trx->thd) >= 0 + ) { + spider_conn_queue_semi_trx_isolation(conns[roop_count], + spider_param_semi_trx_isolation(trx->thd)); + } else { + if (sync_trx_isolation) + { + if ((error_num = spider_check_and_set_trx_isolation( + conns[roop_count], &need_mons[roop_count]))) + { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + roop_count, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + share->monitoring_flag[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode(error_num)); + } + } + conns[roop_count]->semi_trx_isolation = -1; + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + reset_first_link_idx(); + } + if ((conn_kinds & SPIDER_CONN_KIND_HS_READ)) + { + SPIDER_CONN *hs_conn; + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + hs_conn = hs_r_conns[roop_count]; + if ( + hs_conn && + hs_conn->hsc_query_id != thd->query_id && + hs_conn->hs_pre_age == hs_conn->hs_age + ) { + double interval = spider_param_hs_ping_interval(thd); + time_t tmp_time = (time_t) time((time_t*) 0); + DBUG_PRINT("info", + ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); + DBUG_PRINT("info", ("spider interval=%f", interval)); + if ( + hs_conn->server_lost || + difftime(tmp_time, hs_conn->ping_time) >= interval + ) { + DBUG_PRINT("info", ("spider hsr[%d] need reconnect", roop_count)); + hs_conn->hs_pre_age++; + hs_conn->ping_time = tmp_time; + } + hs_conn->hsc_query_id = thd->query_id; + } + } + } + if ( +#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) + ( +#endif + conn_kinds & SPIDER_CONN_KIND_HS_WRITE +#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) + ) || + /* for direct_update */ + wide_handler->sql_command == SQLCOM_HS_UPDATE || + wide_handler->sql_command == SQLCOM_HS_DELETE +#endif + ) { + SPIDER_CONN *hs_conn; + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + hs_conn = hs_w_conns[roop_count]; + if ( + hs_conn && + hs_conn->hsc_query_id != thd->query_id && + hs_conn->hs_pre_age == hs_conn->hs_age + ) { + double interval = spider_param_hs_ping_interval(thd); + time_t tmp_time = (time_t) time((time_t*) 0); + DBUG_PRINT("info", + ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); + DBUG_PRINT("info", ("spider interval=%f", interval)); + if ( + hs_conn->server_lost || + difftime(tmp_time, hs_conn->ping_time) >= interval + ) { + DBUG_PRINT("info", ("spider hsw[%d] need reconnect", roop_count)); + hs_conn->hs_pre_age++; + hs_conn->ping_time = tmp_time; + } + hs_conn->hsc_query_id = thd->query_id; + } + } + } +#endif +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if (wide_handler->insert_with_update) + { + check_insert_dup_update_pushdown(); + } +#endif + dml_inited = TRUE; + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::bulk_access_begin( + void *info +) { + DBUG_ENTER("ha_spider::bulk_access_begin"); + DBUG_PRINT("info",("spider this=%p", this)); + if (bulk_access_started) + { + if (!bulk_access_link_current->next) + { + if (!(bulk_access_link_current->next = create_bulk_access_link())) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + bulk_access_link_current->next->sequence_num = + bulk_access_link_current->sequence_num + 1; + } + bulk_access_link_current = bulk_access_link_current->next; + } else { + if (!bulk_access_link_first) + { + if (!(bulk_access_link_first = create_bulk_access_link())) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + bulk_access_link_first->sequence_num = 0; + } + bulk_access_link_current = bulk_access_link_first; + bulk_access_started = TRUE; + bulk_access_executing = FALSE; + } + bulk_access_link_current->spider-> + check_access_kind(wide_handler->trx->thd); + if ( + (error_num = bulk_access_link_current->spider-> + sync_from_clone_source(this)) || + (error_num = bulk_access_link_current->spider-> + check_access_kind_for_connection(wide_handler->trx->thd, + (lock_type >= TL_WRITE_ALLOW_WRITE))) + ) { + DBUG_RETURN(error_num); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + memset( + bulk_access_link_current->spider->result_list.hs_r_bulk_open_index, 0, + share->link_bitmap_size); + memset( + bulk_access_link_current->spider->result_list.hs_w_bulk_open_index, 0, + share->link_bitmap_size); +#endif + bulk_access_link_current->spider->bulk_access_executing = FALSE; + bulk_access_link_current->spider->bulk_access_pre_called = FALSE; + bulk_access_link_current->used = TRUE; + bulk_access_link_current->called = FALSE; + *((void **) info) = bulk_access_link_current; + DBUG_RETURN(0); +} + +int ha_spider::bulk_access_current( + void *info +) { + DBUG_ENTER("ha_spider::bulk_access_current"); + DBUG_PRINT("info",("spider this=%p", this)); + bulk_access_executing = TRUE; + bulk_access_link_exec_tgt = (SPIDER_BULK_ACCESS_LINK *) info; + if (bulk_access_link_exec_tgt->spider->pt_clone_source_handler != this) + { + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider pt_clone_source_handler=%p", + bulk_access_link_exec_tgt->spider->pt_clone_source_handler)); + /* partitioned */ + uint sequence_num = bulk_access_link_exec_tgt->sequence_num; + for ( + bulk_access_link_exec_tgt = bulk_access_link_first; + bulk_access_link_exec_tgt; + bulk_access_link_exec_tgt = bulk_access_link_exec_tgt->next + ) { + if (bulk_access_link_exec_tgt->sequence_num >= sequence_num) + { + DBUG_ASSERT( + bulk_access_link_exec_tgt->sequence_num == sequence_num); + break; + } + } + } + bulk_access_link_exec_tgt->spider->bulk_access_executing = TRUE; + DBUG_RETURN(0); +} + +void ha_spider::bulk_access_end() +{ + DBUG_ENTER("ha_spider::bulk_access_end"); + DBUG_PRINT("info",("spider this=%p", this)); + bulk_access_started = FALSE; + DBUG_VOID_RETURN; +} +#endif diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index d33d9a3a7dc..29a7a19d2a5 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -51,9 +51,7 @@ struct st_spider_ft_info class ha_spider: public handler { public: - THR_LOCK_DATA lock; SPIDER_SHARE *share; - SPIDER_TRX *trx; ulonglong spider_thread_id; ulonglong trx_conn_adjustment; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) @@ -89,18 +87,16 @@ public: int search_link_idx; int result_link_idx; SPIDER_RESULT_LIST result_list; - SPIDER_CONDITION *condition; spider_string *blob_buff; - uchar *searched_bitmap; - uchar *ft_discard_bitmap; - bool position_bitmap_init; - uchar *position_bitmap; SPIDER_POSITION *pushed_pos; SPIDER_POSITION pushed_pos_buf; #ifdef WITH_PARTITION_STORAGE_ENGINE + bool pt_handler_share_owner = FALSE; SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share; - ha_spider *pt_handler_share_creator; #endif + bool wide_handler_owner = FALSE; + SPIDER_WIDE_HANDLER *wide_handler = NULL; + #ifdef HA_CAN_BULK_ACCESS int pre_direct_init_result; bool is_bulk_access_clone; @@ -115,10 +111,8 @@ public: bool init_ha_mem_root; MEM_ROOT ha_mem_root; */ - ulonglong external_lock_cnt; #endif bool is_clone; - bool clone_bitmap_init; ha_spider *pt_clone_source_handler; ha_spider *pt_clone_last_searcher; bool use_index_merge; @@ -160,22 +154,11 @@ public: ha_spider *next; + bool dml_inited; bool rnd_scan_and_first; - bool quick_mode; - bool keyread; - bool ignore_dup_key; - bool write_can_replace; - bool insert_with_update; - bool low_priority; - bool high_priority; - bool insert_delayed; bool use_pre_call; bool use_pre_records; bool pre_bitmap_checked; - enum thr_lock_type lock_type; - int lock_mode; - uint sql_command; - int selupd_lock_mode; bool bulk_insert; #ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC bool info_auto_called; @@ -188,12 +171,9 @@ public: int store_error_num; uint dup_key_idx; int select_column_mode; - bool update_request; bool pk_update; bool force_auto_increment; int bka_mode; - bool cond_check; - int cond_check_error; int error_mode; ulonglong store_last_insert_id; @@ -215,14 +195,7 @@ public: uint32 **hs_w_ret_fields; size_t *hs_r_ret_fields_num; size_t *hs_w_ret_fields_num; - uint32 *hs_pushed_ret_fields; - size_t hs_pushed_ret_fields_num; - size_t hs_pushed_ret_fields_size; - size_t hs_pushed_lcl_fields_num; uchar *tmp_column_bitmap; - bool hs_increment; - bool hs_decrement; - uint32 hs_pushed_strref_num; #endif #endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS @@ -231,11 +204,6 @@ public: bool maybe_do_hs_direct_update; #endif uint direct_update_kinds; - List<Item> *direct_update_fields; - List<Item> *direct_update_values; -#endif -#ifdef INFO_KIND_FORCE_LIMIT_BEGIN - longlong info_limit; #endif spider_index_rnd_init prev_index_rnd_init; #ifdef HANDLER_HAS_DIRECT_AGGREGATE @@ -277,10 +245,13 @@ public: uint test_if_locked ); int close(); - int check_access_kind( + int check_access_kind_for_connection( THD *thd, bool write_request ); + void check_access_kind( + THD *thd + ); #ifdef HA_CAN_BULK_ACCESS int additional_lock( THD *thd, @@ -296,6 +267,10 @@ public: THD *thd, int lock_type ); + int start_stmt( + THD *thd, + thr_lock_type lock_type + ); int reset(); int extra( enum ha_extra_function operation @@ -514,6 +489,7 @@ public: ha_rows records(); const char *table_type() const; ulonglong table_flags() const; + ulong table_flags_for_partition(); const char *index_type( uint key_number ); @@ -853,6 +829,12 @@ public: int error_num, uint flags ); + int set_top_table_and_fields( + TABLE *top_table, + Field **top_table_field, + uint top_table_fields + ); + void clear_top_table_fields(); Field *get_top_table_field( uint16 field_index ); @@ -1239,4 +1221,15 @@ public: #endif int init_union_table_name_pos_sql(); int set_union_table_name_pos_sql(); + int lock_tables(); + int dml_init(); +#ifdef HA_CAN_BULK_ACCESS + int bulk_access_begin( + void *info + ); + int bulk_access_current( + void *info + ); + void bulk_access_end(); +#endif }; diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index aac4edd072c..7296b451f37 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -308,6 +308,10 @@ void spider_free_conn_from_trx( } } else { /* conn_recycle_mode == 0 */ + if (conn->quick_target) + { + spider_db_free_result((ha_spider *) conn->quick_target, TRUE); + } spider_free_conn(conn); } } else if (roop_count) @@ -1279,7 +1283,7 @@ int spider_check_and_get_casual_read_conn( if ( !(spider->conns[link_idx] = spider_get_conn(spider->share, link_idx, - spider->conn_keys[link_idx], spider->trx, + spider->conn_keys[link_idx], spider->wide_handler->trx, spider, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL, &error_num)) ) { @@ -1728,7 +1732,8 @@ int spider_set_conn_bg_param( int error_num, roop_count, bgs_mode; SPIDER_SHARE *share = spider->share; SPIDER_RESULT_LIST *result_list = &spider->result_list; - THD *thd = spider->trx->thd; + SPIDER_WIDE_HANDLER *wide_handler = spider->wide_handler; + THD *thd = wide_handler->trx->thd; DBUG_ENTER("spider_set_conn_bg_param"); DBUG_PRINT("info",("spider spider=%p", spider)); bgs_mode = @@ -1737,10 +1742,11 @@ int spider_set_conn_bg_param( result_list->bgs_phase = 0; else if ( bgs_mode <= 2 && - (result_list->lock_type == F_WRLCK || spider->lock_mode == 2) + (wide_handler->external_lock_type == F_WRLCK || + wide_handler->lock_mode == 2) ) result_list->bgs_phase = 0; - else if (bgs_mode <= 1 && spider->lock_mode == 1) + else if (bgs_mode <= 1 && wide_handler->lock_mode == 1) result_list->bgs_phase = 0; else { result_list->bgs_phase = 1; @@ -1787,12 +1793,12 @@ int spider_set_conn_bg_param( for ( roop_count = spider_conn_link_idx_next(share->link_statuses, spider->conn_link_idx, -1, share->link_count, - spider->lock_mode ? + spider->wide_handler->lock_mode ? SPIDER_LINK_STATUS_RECOVERY : SPIDER_LINK_STATUS_OK); roop_count < (int) share->link_count; roop_count = spider_conn_link_idx_next(share->link_statuses, spider->conn_link_idx, roop_count, share->link_count, - spider->lock_mode ? + spider->wide_handler->lock_mode ? SPIDER_LINK_STATUS_RECOVERY : SPIDER_LINK_STATUS_OK) ) { if ((error_num = spider_create_conn_thread(spider->conns[roop_count]))) @@ -2671,7 +2677,7 @@ void *spider_bg_conn_action( conn->link_idx); result_list->tmp_tables_created = TRUE; spider_conn_set_timeout_from_share(conn, conn->link_idx, - spider->trx->thd, share); + spider->wide_handler->trx->thd, share); if (dbton_handler->execute_sql( SPIDER_SQL_TYPE_TMP_SQL, conn, @@ -2689,7 +2695,7 @@ void *spider_bg_conn_action( if (!result_list->bgs_error) { spider_conn_set_timeout_from_share(conn, conn->link_idx, - spider->trx->thd, share); + spider->wide_handler->trx->thd, share); if (dbton_handler->execute_sql( sql_type, conn, @@ -2935,6 +2941,7 @@ void *spider_bg_sts_action( SPIDER_TRX *trx; int error_num = 0, roop_count; ha_spider spider; + SPIDER_WIDE_HANDLER wide_handler; int *need_mons; SPIDER_CONN **conns; uint *conn_link_idx; @@ -3028,7 +3035,8 @@ void *spider_bg_sts_action( DBUG_RETURN(NULL); } share->bg_sts_thd = thd; - spider.trx = trx; + spider.wide_handler = &wide_handler; + wide_handler.trx = trx; spider.share = share; spider.conns = conns; spider.conn_link_idx = conn_link_idx; @@ -3300,6 +3308,7 @@ void *spider_bg_crd_action( SPIDER_TRX *trx; int error_num = 0, roop_count; ha_spider spider; + SPIDER_WIDE_HANDLER wide_handler; TABLE table; int *need_mons; SPIDER_CONN **conns; @@ -3397,7 +3406,8 @@ void *spider_bg_crd_action( table.s = share->table_share; table.field = share->table_share->field; table.key_info = share->table_share->key_info; - spider.trx = trx; + spider.wide_handler = &wide_handler; + wide_handler.trx = trx; spider.change_table_ptr(&table, share->table_share); spider.share = share; spider.conns = conns; @@ -4080,11 +4090,12 @@ int spider_conn_get_link_status( int spider_conn_lock_mode( ha_spider *spider ) { - SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_WIDE_HANDLER *wide_handler = spider->wide_handler; DBUG_ENTER("spider_conn_lock_mode"); - if (result_list->lock_type == F_WRLCK || spider->lock_mode == 2) + if (wide_handler->external_lock_type == F_WRLCK || + wide_handler->lock_mode == 2) DBUG_RETURN(SPIDER_LOCK_MODE_EXCLUSIVE); - else if (spider->lock_mode == 1) + else if (wide_handler->lock_mode == 1) DBUG_RETURN(SPIDER_LOCK_MODE_SHARED); DBUG_RETURN(SPIDER_LOCK_MODE_NO_LOCK); } @@ -4107,7 +4118,7 @@ bool spider_conn_use_handler( int lock_mode, int link_idx ) { - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; int use_handler = spider_param_use_handler(thd, spider->share->use_handlers[link_idx]); DBUG_ENTER("spider_conn_use_handler"); @@ -4180,7 +4191,7 @@ bool spider_conn_use_handler( DBUG_RETURN(FALSE); } if ( - spider->sql_command == SQLCOM_HA_READ && + spider->wide_handler->sql_command == SQLCOM_HA_READ && ( !(use_handler & 2) || ( @@ -4195,7 +4206,7 @@ bool spider_conn_use_handler( DBUG_RETURN(TRUE); } if ( - spider->sql_command != SQLCOM_HA_READ && + spider->wide_handler->sql_command != SQLCOM_HA_READ && lock_mode == SPIDER_LOCK_MODE_NO_LOCK && spider_param_sync_trx_isolation(thd) && thd_tx_isolation(thd) != ISO_SERIALIZABLE && diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index 8dd9d968b99..5e4f1888ed7 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2009-2018 Kentoku Shiba +/* Copyright (C) 2009-2019 Kentoku Shiba + Copyright (C) 2019 MariaDB corp This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -836,6 +837,7 @@ long long spider_copy_tables_body( spider_string *tmp_sql = NULL; SPIDER_COPY_TABLE_CONN *table_conn, *src_tbl_conn, *dst_tbl_conn; SPIDER_CONN *tmp_conn; + SPIDER_WIDE_HANDLER *wide_handler; spider_db_copy_table *select_ct, *insert_ct; MEM_ROOT mem_root; longlong bulk_insert_rows; @@ -1125,13 +1127,15 @@ long long spider_copy_tables_body( __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), &tmp_spider->dbton_handler, sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + &wide_handler, sizeof(SPIDER_WIDE_HANDLER), NullS)) ) { my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); goto error; } tmp_spider->share = table_conn->share; - tmp_spider->trx = copy_tables->trx; + tmp_spider->wide_handler = wide_handler; + wide_handler->trx = copy_tables->trx; /* if (spider_db_append_set_names(table_conn->share)) { @@ -1144,7 +1148,7 @@ long long spider_copy_tables_body( tmp_sql[roop_count].set_charset(copy_tables->access_charset); tmp_spider->result_list.sqls = &tmp_sql[roop_count]; tmp_spider->need_mons = &table_conn->need_mon; - tmp_spider->lock_type = TL_READ; + tmp_spider->wide_handler->lock_type = TL_READ; tmp_spider->conn_link_idx = &tmp_conn_link_idx; uint dbton_id = tmp_spider->share->use_dbton_ids[0]; if (!(tmp_spider->dbton_handler[dbton_id] = @@ -1169,13 +1173,15 @@ long long spider_copy_tables_body( __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), &tmp_spider->dbton_handler, sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + &wide_handler, sizeof(SPIDER_WIDE_HANDLER), NullS)) ) { my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); goto error; } tmp_spider->share = table_conn->share; - tmp_spider->trx = copy_tables->trx; + tmp_spider->wide_handler = wide_handler; + wide_handler->trx = copy_tables->trx; /* if (spider_db_append_set_names(table_conn->share)) { @@ -1188,7 +1194,7 @@ long long spider_copy_tables_body( tmp_sql[roop_count].set_charset(copy_tables->access_charset); tmp_spider->result_list.sqls = &tmp_sql[roop_count]; tmp_spider->need_mons = &table_conn->need_mon; - tmp_spider->lock_type = TL_WRITE; + tmp_spider->wide_handler->lock_type = TL_WRITE; tmp_spider->conn_link_idx = &tmp_conn_link_idx; uint dbton_id = tmp_spider->share->use_dbton_ids[0]; if (!(tmp_spider->dbton_handler[dbton_id] = diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 97e2d24c8e7..5259cf36401 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -278,9 +278,9 @@ int spider_db_ping( ) { DBUG_ENTER("spider_db_ping"); #ifndef DBUG_OFF - if (spider->trx->thd) + if (spider->wide_handler->trx->thd) DBUG_PRINT("info", ("spider thd->query_id is %lld", - spider->trx->thd->query_id)); + spider->wide_handler->trx->thd->query_id)); #endif DBUG_RETURN(spider_db_ping_internal(spider->share, conn, spider->conn_link_idx[link_idx], &spider->need_mons[link_idx])); @@ -961,7 +961,8 @@ int spider_db_set_names( int link_idx ) { DBUG_ENTER("spider_db_set_names"); - DBUG_RETURN(spider_db_set_names_internal(spider->trx, spider->share, conn, + DBUG_RETURN(spider_db_set_names_internal(spider->wide_handler->trx, + spider->share, conn, spider->conn_link_idx[link_idx], &spider->need_mons[link_idx])); } @@ -994,8 +995,8 @@ int spider_db_query_with_set_names( spider->need_mons[link_idx] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, link_idx, (uint32) share->monitoring_sid[link_idx], @@ -1012,7 +1013,8 @@ int spider_db_query_with_set_names( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, @@ -1028,8 +1030,8 @@ int spider_db_query_with_set_names( spider->need_mons[link_idx] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, link_idx, (uint32) share->monitoring_sid[link_idx], @@ -1081,8 +1083,8 @@ int spider_db_query_for_bulk_update( spider->need_mons[link_idx] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, link_idx, (uint32) share->monitoring_sid[link_idx], @@ -1099,7 +1101,8 @@ int spider_db_query_for_bulk_update( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; if (dbton_hdl->execute_sql( @@ -1119,8 +1122,8 @@ int spider_db_query_for_bulk_update( spider->need_mons[link_idx] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, link_idx, (uint32) share->monitoring_sid[link_idx], @@ -1136,7 +1139,7 @@ int spider_db_query_for_bulk_update( ); } if ( - spider->ignore_dup_key && + spider->wide_handler->ignore_dup_key && ( error_num == ER_DUP_ENTRY || error_num == ER_DUP_KEY || @@ -1144,7 +1147,7 @@ int spider_db_query_for_bulk_update( ) ) { ++(*dup_key_found); - spider->trx->thd->clear_error(); + spider->wide_handler->trx->thd->clear_error(); DBUG_RETURN(0); } DBUG_RETURN(error_num); @@ -1164,8 +1167,8 @@ int spider_db_query_for_bulk_update( spider->need_mons[link_idx] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, link_idx, (uint32) share->monitoring_sid[link_idx], @@ -2646,7 +2649,7 @@ int spider_db_fetch_for_item_sum_func( ) { int error_num; SPIDER_SHARE *share = spider->share; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; DBUG_ENTER("spider_db_fetch_for_item_sum_func"); DBUG_PRINT("info",("spider Sumfunctype = %d", item_sum->sum_func())); switch (item_sum->sum_func()) @@ -3355,7 +3358,8 @@ int spider_db_fetch_minimum_columns( ) { DBUG_PRINT("info", ("spider field_index %u", (*field)->field_index)); DBUG_PRINT("info", ("spider searched_bitmap %u", - spider_bit_is_set(spider->searched_bitmap, (*field)->field_index))); + spider_bit_is_set(spider->wide_handler->searched_bitmap, + (*field)->field_index))); DBUG_PRINT("info", ("spider read_set %u", bitmap_is_set(table->read_set, (*field)->field_index))); DBUG_PRINT("info", ("spider write_set %u", @@ -3537,7 +3541,7 @@ int spider_db_free_result( SPIDER_RESULT *result; SPIDER_RESULT *prev; SPIDER_SHARE *share = spider->share; - SPIDER_TRX *trx = spider->trx; + SPIDER_TRX *trx = spider->wide_handler->trx; SPIDER_POSITION *position; int roop_count, error_num; DBUG_ENTER("spider_db_free_result"); @@ -3893,8 +3897,9 @@ int spider_db_store_result( spider_clear_bit(spider->db_request_phase, link_idx); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = + spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[link_idx]; request_key.next = NULL; @@ -3992,8 +3997,9 @@ int spider_db_store_result( spider_clear_bit(spider->db_request_phase, link_idx); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = + spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[link_idx]; request_key.next = NULL; @@ -4257,8 +4263,8 @@ int spider_db_store_result( spider_clear_bit(spider->db_request_phase, link_idx); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[link_idx]; request_key.next = NULL; @@ -4303,8 +4309,8 @@ void spider_db_discard_result( spider_clear_bit(spider->db_request_phase, link_idx); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[link_idx]; request_key.next = NULL; @@ -4329,8 +4335,8 @@ void spider_db_discard_multiple_result( { spider_clear_bit(spider->db_request_phase, link_idx); } - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[link_idx]; request_key.next = NULL; @@ -4638,7 +4644,7 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } spider_conn_set_timeout_from_share(conn, link_idx, - spider->trx->thd, share); + spider->wide_handler->trx->thd, share); if (dbton_handler->execute_sql( sql_type, conn, @@ -4728,8 +4734,8 @@ int spider_db_seek_next( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4748,7 +4754,7 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } spider_conn_set_timeout_from_share(conn, roop_count, - spider->trx->thd, share); + spider->wide_handler->trx->thd, share); if (dbton_handler->execute_sql( sql_type, conn, @@ -4763,8 +4769,8 @@ int spider_db_seek_next( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4796,8 +4802,8 @@ int spider_db_seek_next( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -4982,8 +4988,8 @@ int spider_db_seek_last( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5000,7 +5006,8 @@ int spider_db_seek_last( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if (dbton_handler->execute_sql( sql_type, @@ -5016,8 +5023,8 @@ int spider_db_seek_last( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5047,8 +5054,8 @@ int spider_db_seek_last( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5185,8 +5192,8 @@ int spider_db_seek_last( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5203,7 +5210,8 @@ int spider_db_seek_last( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if (dbton_handler->execute_sql( sql_type, @@ -5219,8 +5227,8 @@ int spider_db_seek_last( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5250,8 +5258,8 @@ int spider_db_seek_last( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5350,7 +5358,7 @@ void spider_db_create_position( pos->direct_aggregate = result_list->direct_aggregate; #endif pos->sql_kind = spider->sql_kind[spider->result_link_idx]; - pos->position_bitmap = spider->position_bitmap; + pos->position_bitmap = spider->wide_handler->position_bitmap; pos->ft_first = spider->ft_first; pos->ft_current = spider->ft_current; pos->result = current; @@ -5690,7 +5698,7 @@ int spider_db_show_records( bool pre_call ) { int error_num; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; SPIDER_CONN *conn; DBUG_ENTER("spider_db_show_records"); if (pre_call) @@ -5836,7 +5844,8 @@ int spider_db_bulk_insert_init( SPIDER_LINK_STATUS_RECOVERY) ) { if (spider->conns[roop_count]) - spider->conns[roop_count]->ignore_dup_key = spider->ignore_dup_key; + spider->conns[roop_count]->ignore_dup_key = + spider->wide_handler->ignore_dup_key; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) if ( spider_conn_use_handler(spider, spider->lock_mode, roop_count) && @@ -5856,8 +5865,8 @@ int spider_db_bulk_insert_init( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5877,7 +5886,8 @@ int spider_db_bulk_insert_init( spider->set_handler_opened(roop_count); } #else - spider_conn_use_handler(spider, spider->lock_mode, roop_count); + spider_conn_use_handler(spider, spider->wide_handler->lock_mode, + roop_count); #endif } #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) @@ -5910,7 +5920,7 @@ int spider_db_bulk_insert( SPIDER_RESULT_LIST *result_list = &spider->result_list; #endif SPIDER_SHARE *share = spider->share; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; bool mta_conn_mutex_lock_already_backup; bool mta_conn_mutex_unlock_later_backup; DBUG_ENTER("spider_db_bulk_insert"); @@ -6027,8 +6037,8 @@ int spider_db_bulk_insert( spider->need_mons[roop_count2] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count2, (uint32) share->monitoring_sid[roop_count2], @@ -6045,7 +6055,8 @@ int spider_db_bulk_insert( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count2, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count2, + spider->wide_handler->trx->thd, share); if (dbton_handler->execute_sql( sql_type, @@ -6077,8 +6088,8 @@ int spider_db_bulk_insert( spider->need_mons[roop_count2] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count2, (uint32) share->monitoring_sid[roop_count2], @@ -6113,8 +6124,9 @@ int spider_db_bulk_insert( spider_clear_bit(spider->db_request_phase, roop_count2); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = + spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[roop_count2]; request_key.next = NULL; @@ -6233,7 +6245,7 @@ int spider_db_bulk_bulk_insert( SPIDER_SHARE *share = spider->share; SPIDER_CONN *conn, *first_insert_conn = NULL; TABLE *table = spider->get_table(); - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; DBUG_ENTER("spider_db_bulk_bulk_insert"); for ( roop_count2 = spider_conn_link_idx_next(share->link_statuses, @@ -6282,8 +6294,9 @@ int spider_db_bulk_bulk_insert( spider_clear_bit(spider->db_request_phase, roop_count2); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = + spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[roop_count2]; request_key.next = NULL; @@ -6354,7 +6367,7 @@ int spider_db_update_auto_increment( int link_idx ) { int roop_count; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; ulonglong last_insert_id, affected_rows; SPIDER_SHARE *share = spider->share; TABLE *table = spider->get_table(); @@ -6516,7 +6529,7 @@ int spider_db_bulk_update_end( ha_rows *dup_key_found ) { int error_num = 0, error_num2, roop_count; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; SPIDER_SHARE *share = spider->share; SPIDER_CONN *conn; bool is_error = thd->is_error(); @@ -6691,7 +6704,7 @@ int spider_db_update( conn = spider->conns[roop_count]; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; #if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 - conn->ignore_dup_key = spider->ignore_dup_key; + conn->ignore_dup_key = spider->wide_handler->ignore_dup_key; #endif if (dbton_hdl->need_lock_before_set_sql_for_exec( SPIDER_SQL_TYPE_UPDATE_SQL)) @@ -6724,8 +6737,8 @@ int spider_db_update( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -6742,7 +6755,8 @@ int spider_db_update( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_UPDATE_SQL, @@ -6761,8 +6775,8 @@ int spider_db_update( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -6795,7 +6809,8 @@ int spider_db_update( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_INSERT_SQL, @@ -6814,8 +6829,8 @@ int spider_db_update( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7040,7 +7055,7 @@ int spider_db_direct_update( if (spider->is_bulk_access_clone) { spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->trx, conn); + spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); } else { #endif conn->need_mon = &spider->need_mons[roop_count]; @@ -7057,8 +7072,8 @@ int spider_db_direct_update( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7075,7 +7090,8 @@ int spider_db_direct_update( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if ( (error_num = dbton_hdl->execute_sql( @@ -7097,8 +7113,8 @@ int spider_db_direct_update( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7133,8 +7149,9 @@ int spider_db_direct_update( spider_clear_bit(spider->db_request_phase, roop_count); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = + spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[roop_count]; request_key.next = NULL; @@ -7295,7 +7312,7 @@ int spider_db_direct_update( if (spider->is_bulk_access_clone) { spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->trx, conn); + spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); } else { #endif conn->need_mon = &spider->need_mons[roop_count]; @@ -7312,8 +7329,8 @@ int spider_db_direct_update( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7330,7 +7347,8 @@ int spider_db_direct_update( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if ( (error_num = dbton_hdl->execute_sql( @@ -7339,7 +7357,8 @@ int spider_db_direct_update( -1, &spider->need_mons[roop_count]) ) && - (error_num != HA_ERR_FOUND_DUPP_KEY || !spider->ignore_dup_key) + (error_num != HA_ERR_FOUND_DUPP_KEY || + !spider->wide_handler->ignore_dup_key) ) { conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; @@ -7352,8 +7371,8 @@ int spider_db_direct_update( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7448,8 +7467,9 @@ int spider_db_bulk_direct_update( spider_clear_bit(spider->db_request_phase, roop_count); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = + spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[roop_count]; request_key.next = NULL; @@ -7682,7 +7702,7 @@ int spider_db_direct_delete( if (spider->is_bulk_access_clone) { spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->trx, conn); + spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); } else { #endif conn->need_mon = &spider->need_mons[roop_count]; @@ -7699,8 +7719,8 @@ int spider_db_direct_delete( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7717,7 +7737,8 @@ int spider_db_direct_delete( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, @@ -7733,8 +7754,8 @@ int spider_db_direct_delete( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7771,8 +7792,9 @@ int spider_db_direct_delete( spider_clear_bit(spider->db_request_phase, roop_count); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = + spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[roop_count]; request_key.next = NULL; @@ -7904,7 +7926,7 @@ int spider_db_direct_delete( if (spider->is_bulk_access_clone) { spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->trx, conn); + spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); } else { #endif conn->need_mon = &spider->need_mons[roop_count]; @@ -7921,8 +7943,8 @@ int spider_db_direct_delete( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -7939,7 +7961,8 @@ int spider_db_direct_delete( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( sql_type, @@ -7955,8 +7978,8 @@ int spider_db_direct_delete( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8041,7 +8064,8 @@ int spider_db_delete_all_rows( conn->need_mon = &spider->need_mons[roop_count]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, roop_count)) || @@ -8070,8 +8094,8 @@ int spider_db_delete_all_rows( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8099,8 +8123,8 @@ int spider_db_delete_all_rows( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8117,7 +8141,8 @@ int spider_db_delete_all_rows( } DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, roop_count, + spider->wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_DELETE_SQL, @@ -8133,8 +8158,8 @@ int spider_db_delete_all_rows( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8161,8 +8186,8 @@ int spider_db_delete_all_rows( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8199,7 +8224,7 @@ int spider_db_disable_keys( spider_db_handler *dbton_hdl; DBUG_ENTER("spider_db_disable_keys"); if ( - spider_param_internal_optimize(spider->trx->thd, + spider_param_internal_optimize(spider->wide_handler->trx->thd, share->internal_optimize) == 1 ) { for ( @@ -8220,8 +8245,8 @@ int spider_db_disable_keys( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8252,7 +8277,7 @@ int spider_db_enable_keys( spider_db_handler *dbton_hdl; DBUG_ENTER("spider_db_enable_keys"); if ( - spider_param_internal_optimize(spider->trx->thd, + spider_param_internal_optimize(spider->wide_handler->trx->thd, share->internal_optimize) == 1 ) { for ( @@ -8273,8 +8298,8 @@ int spider_db_enable_keys( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8306,7 +8331,7 @@ int spider_db_check_table( spider_db_handler *dbton_hdl; DBUG_ENTER("spider_db_check_table"); if ( - spider_param_internal_optimize(spider->trx->thd, + spider_param_internal_optimize(spider->wide_handler->trx->thd, share->internal_optimize) == 1 ) { for ( @@ -8327,8 +8352,8 @@ int spider_db_check_table( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8360,7 +8385,7 @@ int spider_db_repair_table( spider_db_handler *dbton_hdl; DBUG_ENTER("spider_db_repair_table"); if ( - spider_param_internal_optimize(spider->trx->thd, + spider_param_internal_optimize(spider->wide_handler->trx->thd, share->internal_optimize) == 1 ) { for ( @@ -8381,8 +8406,8 @@ int spider_db_repair_table( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8413,7 +8438,7 @@ int spider_db_analyze_table( spider_db_handler *dbton_hdl; DBUG_ENTER("spider_db_analyze_table"); if ( - spider_param_internal_optimize(spider->trx->thd, + spider_param_internal_optimize(spider->wide_handler->trx->thd, share->internal_optimize) == 1 ) { for ( @@ -8434,8 +8459,8 @@ int spider_db_analyze_table( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8466,7 +8491,7 @@ int spider_db_optimize_table( spider_db_handler *dbton_hdl; DBUG_ENTER("spider_db_optimize_table"); if ( - spider_param_internal_optimize(spider->trx->thd, + spider_param_internal_optimize(spider->wide_handler->trx->thd, share->internal_optimize) == 1 ) { for ( @@ -8487,8 +8512,8 @@ int spider_db_optimize_table( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8537,8 +8562,8 @@ int spider_db_flush_tables( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8585,8 +8610,8 @@ int spider_db_flush_logs( spider->need_mons[roop_count] ) { error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -8765,7 +8790,7 @@ int spider_db_print_item_type_default( spider_string *str ) { DBUG_ENTER("spider_db_print_item_type_default"); - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; SPIDER_SHARE *share = spider->share; if (spider_param_skip_default_condition(thd, share->skip_default_condition)) @@ -9626,12 +9651,13 @@ int spider_db_append_condition( DBUG_RETURN(error_num); } } else { - if (spider->cond_check) - DBUG_RETURN(spider->cond_check_error); - spider->cond_check = TRUE; - if ((spider->cond_check_error = spider->append_condition_sql_part( - NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL, TRUE))) - DBUG_RETURN(spider->cond_check_error); + if (spider->wide_handler->cond_check) + DBUG_RETURN(spider->wide_handler->cond_check_error); + spider->wide_handler->cond_check = TRUE; + if ((spider->wide_handler->cond_check_error = + spider->append_condition_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL, TRUE))) + DBUG_RETURN(spider->wide_handler->cond_check_error); } DBUG_RETURN(0); } @@ -9648,8 +9674,8 @@ int spider_db_append_update_columns( ) { int error_num; bool add_comma = FALSE; - List_iterator_fast<Item> fi(*spider->direct_update_fields), - vi(*spider->direct_update_values); + List_iterator_fast<Item> fi(*spider->wide_handler->direct_update_fields), + vi(*spider->wide_handler->direct_update_values); Item *field, *value; DBUG_ENTER("spider_db_append_update_columns"); while ((field = fi++)) @@ -10480,10 +10506,12 @@ int spider_db_udf_ping_table( int need_mon = 0; uint tmp_conn_link_idx = 0; ha_spider spider; + SPIDER_WIDE_HANDLER wide_handler; uchar db_request_phase = 0; ulonglong db_request_id = 0; spider.share = share; - spider.trx = trx; + spider.wide_handler = &wide_handler; + wide_handler.trx = trx; spider.need_mons = &need_mon; spider.conn_link_idx = &tmp_conn_link_idx; spider.db_request_phase = &db_request_phase; @@ -10763,6 +10791,7 @@ int spider_db_udf_ping_table_mon_next( int init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); ha_spider spider; + SPIDER_WIDE_HANDLER wide_handler; SPIDER_TRX trx; DBUG_ENTER("spider_db_udf_ping_table_mon_next"); char *sql_buf = (char *) my_alloca(init_sql_alloc_size); @@ -10777,7 +10806,8 @@ int spider_db_udf_ping_table_mon_next( sql_str.length(0); trx.thd = thd; spider.share = share; - spider.trx = &trx; + spider.wide_handler = &wide_handler; + wide_handler.trx = &trx; spider.need_mons = &need_mon; spider.conn_link_idx = &tmp_conn_link_idx; @@ -11378,7 +11408,8 @@ int spider_db_open_handler( goto error; } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_HANDLER, @@ -11462,10 +11493,11 @@ int spider_db_open_handler( if (spider->is_bulk_access_clone && !spider->bulk_access_executing) { spider->connection_ids[link_idx] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->trx, conn); + spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); } else { #endif - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_SELECT_HS, @@ -11483,8 +11515,9 @@ int spider_db_open_handler( spider_clear_bit(spider->db_request_phase, link_idx); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = + spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[link_idx]; request_key.next = NULL; @@ -11622,8 +11655,8 @@ int spider_db_bulk_open_handler( spider_clear_bit(spider->db_request_phase, link_idx); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = spider->db_request_id[link_idx]; request_key.next = NULL; @@ -11679,7 +11712,8 @@ int spider_db_close_handler( SPIDER_SQL_TYPE_HANDLER, link_idx))) DBUG_RETURN(error_num); - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); if (dbton_hdl->execute_sql( SPIDER_SQL_TYPE_HANDLER, diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index f759a78c3cb..0969b3678b7 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -2006,7 +2006,6 @@ typedef struct st_spider_result_list #endif int quick_phase; bool keyread; - int lock_type; TABLE *table; #ifndef WITHOUT_SPIDER_BG_SEARCH volatile int bgs_error; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index d8fdfcec081..1f115dae0a7 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -3188,7 +3188,7 @@ int spider_db_mbase::append_lock_tables( { tmp_spider = tmp_link_for_hash->spider; tmp_link_idx = tmp_link_for_hash->link_idx; - switch (tmp_spider->lock_type) + switch (tmp_spider->wide_handler->lock_type) { case TL_READ: lock_type = SPIDER_DB_TABLE_LOCK_READ_LOCAL; @@ -3204,7 +3204,8 @@ int spider_db_mbase::append_lock_tables( break; default: // no lock - DBUG_PRINT("info",("spider lock_type=%d", tmp_spider->lock_type)); + DBUG_PRINT("info",("spider lock_type=%d", + tmp_spider->wide_handler->lock_type)); DBUG_RETURN(0); } conn_link_idx = tmp_spider->conn_link_idx[tmp_link_idx]; @@ -4751,7 +4752,8 @@ int spider_db_mbase_util::open_item_func( } break; case Item_func::UDF_FUNC: - use_pushdown_udf = spider_param_use_pushdown_udf(spider->trx->thd, + use_pushdown_udf = spider_param_use_pushdown_udf( + spider->wide_handler->trx->thd, spider->share->use_pushdown_udf); if (!use_pushdown_udf) DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); @@ -4892,7 +4894,7 @@ int spider_db_mbase_util::open_item_func( DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); #endif default: - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; SPIDER_SHARE *share = spider->share; if (spider_param_skip_default_condition(thd, share->skip_default_condition)) @@ -6588,9 +6590,11 @@ int spider_mbase_share::discover_table_structure( if (!conn->disable_reconnect) { ha_spider tmp_spider; + SPIDER_WIDE_HANDLER wide_handler; int need_mon = 0; uint tmp_conn_link_idx = 0; - tmp_spider.trx = trx; + tmp_spider.wide_handler = &wide_handler; + wide_handler.trx = trx; tmp_spider.share = spider_share; tmp_spider.need_mons = &need_mon; tmp_spider.conn_link_idx = &tmp_conn_link_idx; @@ -6870,7 +6874,7 @@ spider_mariadb_handler::~spider_mariadb_handler() int spider_mbase_handler::init() { uint roop_count; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; st_spider_share *share = spider->share; int init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); @@ -7306,7 +7310,7 @@ int spider_mbase_handler::append_create_tmp_bka_table( ) { int error_num; SPIDER_SHARE *share = spider->share; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; char *bka_engine = spider_param_bka_engine(thd, share->bka_engine); uint bka_engine_length = strlen(bka_engine), cset_length = strlen(table_charset->csname), @@ -7707,10 +7711,10 @@ int spider_mbase_handler::append_insert( DBUG_ENTER("spider_mbase_handler::append_insert"); if ( ( - spider->write_can_replace || + spider->wide_handler->write_can_replace || /* for direct_dup_insert without patch for partition */ - spider->sql_command == SQLCOM_REPLACE || - spider->sql_command == SQLCOM_REPLACE_SELECT + spider->wide_handler->sql_command == SQLCOM_REPLACE || + spider->wide_handler->sql_command == SQLCOM_REPLACE_SELECT ) && spider->direct_dup_insert ) { @@ -7722,13 +7726,13 @@ int spider_mbase_handler::append_insert( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_INSERT_STR, SPIDER_SQL_INSERT_LEN); } - if (spider->low_priority) + if (spider->wide_handler->low_priority) { if (str->reserve(SPIDER_SQL_LOW_PRIORITY_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_LOW_PRIORITY_STR, SPIDER_SQL_LOW_PRIORITY_LEN); } - else if (spider->insert_delayed) + else if (spider->wide_handler->insert_delayed) { if (share->internal_delayed) { @@ -7738,28 +7742,28 @@ int spider_mbase_handler::append_insert( } } else if ( - spider->lock_type >= TL_WRITE && - !spider->write_can_replace && + spider->wide_handler->lock_type >= TL_WRITE && + !spider->wide_handler->write_can_replace && /* for direct_dup_insert without patch for partition */ - spider->sql_command != SQLCOM_REPLACE && - spider->sql_command != SQLCOM_REPLACE_SELECT + spider->wide_handler->sql_command != SQLCOM_REPLACE && + spider->wide_handler->sql_command != SQLCOM_REPLACE_SELECT ) { if (str->reserve(SPIDER_SQL_HIGH_PRIORITY_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_HIGH_PRIORITY_STR, SPIDER_SQL_HIGH_PRIORITY_LEN); } if ( - spider->ignore_dup_key && + spider->wide_handler->ignore_dup_key && spider->direct_dup_insert && - !spider->write_can_replace && + !spider->wide_handler->write_can_replace && #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - (!spider->insert_with_update || !dup_update_sql.length()) && + (!spider->wide_handler->insert_with_update || !dup_update_sql.length()) && #else - !spider->insert_with_update && + !spider->wide_handler->insert_with_update && #endif /* for direct_dup_insert without patch for partition */ - spider->sql_command != SQLCOM_REPLACE && - spider->sql_command != SQLCOM_REPLACE_SELECT + spider->wide_handler->sql_command != SQLCOM_REPLACE && + spider->wide_handler->sql_command != SQLCOM_REPLACE_SELECT ) { if (str->reserve(SPIDER_SQL_SQL_IGNORE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -7785,15 +7789,15 @@ int spider_mbase_handler::append_update( if (str->reserve(SPIDER_SQL_UPDATE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_UPDATE_STR, SPIDER_SQL_UPDATE_LEN); - if (spider->low_priority) + if (spider->wide_handler->low_priority) { if (str->reserve(SPIDER_SQL_LOW_PRIORITY_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_LOW_PRIORITY_STR, SPIDER_SQL_LOW_PRIORITY_LEN); } if ( - spider->ignore_dup_key && - !spider->insert_with_update + spider->wide_handler->ignore_dup_key && + !spider->wide_handler->insert_with_update ) { if (str->reserve(SPIDER_SQL_SQL_IGNORE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -7824,20 +7828,20 @@ int spider_mbase_handler::append_delete( if (str->reserve(SPIDER_SQL_DELETE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_DELETE_STR, SPIDER_SQL_DELETE_LEN); - if (spider->low_priority) + if (spider->wide_handler->low_priority) { if (str->reserve(SPIDER_SQL_LOW_PRIORITY_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_LOW_PRIORITY_STR, SPIDER_SQL_LOW_PRIORITY_LEN); } - if (spider->quick_mode) + if (spider->wide_handler->quick_mode) { if (str->reserve(SPIDER_SQL_SQL_QUICK_MODE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SQL_QUICK_MODE_STR, SPIDER_SQL_SQL_QUICK_MODE_LEN); } - if (spider->ignore_dup_key) + if (spider->wide_handler->ignore_dup_key) { if (str->reserve(SPIDER_SQL_SQL_IGNORE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -8000,7 +8004,7 @@ int spider_mbase_handler::append_direct_update_set( DBUG_ENTER("spider_mbase_handler::append_direct_update_set"); if ( spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && - spider->direct_update_fields + spider->wide_handler->direct_update_fields ) { if (str->reserve(SPIDER_SQL_SET_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -8143,6 +8147,7 @@ int spider_mbase_handler::append_select( ulong sql_type ) { SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_WIDE_HANDLER *wide_handler = spider->wide_handler; DBUG_ENTER("spider_mbase_handler::append_select"); if (sql_type == SPIDER_SQL_TYPE_HANDLER) { @@ -8159,13 +8164,15 @@ int spider_mbase_handler::append_select( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_DISTINCT_STR, SPIDER_SQL_DISTINCT_LEN); } - if (result_list->lock_type != F_WRLCK && spider->lock_mode < 1) + if (wide_handler->external_lock_type != F_WRLCK && + wide_handler->lock_mode < 1) { /* no lock */ #ifdef SPIDER_SQL_CACHE_IS_IN_LEX - LEX *lex = spider->trx->thd->lex; + LEX *lex = wide_handler->trx->thd->lex; #else - st_select_lex *select_lex = &spider->trx->thd->lex->select_lex; + st_select_lex *select_lex = + &wide_handler->trx->thd->lex->select_lex; #endif if ( #ifdef SPIDER_SQL_CACHE_IS_IN_LEX @@ -8203,7 +8210,7 @@ int spider_mbase_handler::append_select( SPIDER_SQL_SQL_NO_CACHE_LEN); } } - if (spider->high_priority) + if (wide_handler->high_priority) { if (str->reserve(SPIDER_SQL_HIGH_PRIORITY_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -9173,7 +9180,7 @@ int spider_mbase_handler::append_update_where( ) { uint field_name_length; Field **field; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; SPIDER_SHARE *share = spider->share; bool no_pk = (table->s->primary_key == MAX_KEY); DBUG_ENTER("spider_mbase_handler::append_update_where"); @@ -9339,7 +9346,7 @@ int spider_mbase_handler::append_condition_part( ha_where_pos = str->length(); if ( - spider->sql_command == SQLCOM_HA_READ || + spider->wide_handler->sql_command == SQLCOM_HA_READ || !spider->result_list.use_both_key ) { if (sql_part2.length()) @@ -9368,7 +9375,7 @@ int spider_mbase_handler::append_condition( ulong sql_type ) { int error_num, restart_pos = 0, start_where_pos; - SPIDER_CONDITION *tmp_cond = spider->condition; + SPIDER_CONDITION *tmp_cond = spider->wide_handler->condition; DBUG_ENTER("spider_mbase_handler::append_condition"); if (str && start_where) { @@ -9379,7 +9386,7 @@ int spider_mbase_handler::append_condition( if (spider->is_clone && !tmp_cond) { - tmp_cond = spider->pt_clone_source_handler->condition; + tmp_cond = spider->pt_clone_source_handler->wide_handler->condition; } while (tmp_cond) @@ -10850,7 +10857,7 @@ int spider_mbase_handler::append_from( str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); table_name_pos = str->length(); append_table_name_with_adjusting(str, link_idx, sql_type); - if(spider_param_index_hint_pushdown(spider->trx->thd)) + if(spider_param_index_hint_pushdown(spider->wide_handler->trx->thd)) { if((error_num = append_index_hint(str, link_idx, sql_type))) { @@ -10931,7 +10938,8 @@ int spider_mbase_handler::append_optimize_table( ) { SPIDER_SHARE *share = spider->share; int conn_link_idx = spider->conn_link_idx[link_idx]; - int local_length = spider_param_internal_optimize_local(spider->trx->thd, + int local_length = spider_param_internal_optimize_local( + spider->wide_handler->trx->thd, share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; DBUG_ENTER("spider_mbase_handler::append_optimize_table"); DBUG_PRINT("info",("spider this=%p", this)); @@ -10976,7 +10984,8 @@ int spider_mbase_handler::append_analyze_table( ) { SPIDER_SHARE *share = spider->share; int conn_link_idx = spider->conn_link_idx[link_idx]; - int local_length = spider_param_internal_optimize_local(spider->trx->thd, + int local_length = spider_param_internal_optimize_local( + spider->wide_handler->trx->thd, share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; DBUG_ENTER("spider_mbase_handler::append_analyze_table"); DBUG_PRINT("info",("spider this=%p", this)); @@ -11023,7 +11032,8 @@ int spider_mbase_handler::append_repair_table( ) { SPIDER_SHARE *share = spider->share; int conn_link_idx = spider->conn_link_idx[link_idx]; - int local_length = spider_param_internal_optimize_local(spider->trx->thd, + int local_length = spider_param_internal_optimize_local( + spider->wide_handler->trx->thd, share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; DBUG_ENTER("spider_mbase_handler::append_repair_table"); DBUG_PRINT("info",("spider this=%p", this)); @@ -11233,7 +11243,7 @@ int spider_mbase_handler::append_delete_all_rows( int error_num; DBUG_ENTER("spider_mbase_handler::append_delete_all_rows"); DBUG_PRINT("info",("spider this=%p", this)); - if (spider->sql_command == SQLCOM_TRUNCATE) + if (spider->wide_handler->sql_command == SQLCOM_TRUNCATE) { if ((error_num = append_truncate(str, sql_type, first_link_idx))) DBUG_RETURN(error_num); @@ -11539,7 +11549,7 @@ bool spider_mbase_handler::bulk_tmp_table_created() int spider_mbase_handler::mk_bulk_tmp_table_and_bulk_start() { - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; TABLE *table = spider->get_table(); DBUG_ENTER("spider_mbase_handler::mk_bulk_tmp_table_and_bulk_start"); DBUG_PRINT("info",("spider this=%p", this)); @@ -11568,7 +11578,8 @@ void spider_mbase_handler::rm_bulk_tmp_table() DBUG_PRINT("info",("spider this=%p", this)); if (upd_tmp_tbl) { - spider_rm_sys_tmp_table(spider->trx->thd, upd_tmp_tbl, &upd_tmp_tbl_prm); + spider_rm_sys_tmp_table(spider->wide_handler->trx->thd, upd_tmp_tbl, + &upd_tmp_tbl_prm); upd_tmp_tbl = NULL; } DBUG_VOID_RETURN; @@ -11642,9 +11653,12 @@ int spider_mbase_handler::append_lock_tables_list( spider_db_mbase *db_conn = (spider_db_mbase *) conn->db_conn; DBUG_ENTER("spider_mbase_handler::append_lock_tables_list"); DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider db_conn=%p", db_conn)); tmp_link_for_hash2 = &link_for_hash[link_idx]; tmp_link_for_hash2->db_table_str = &mysql_share->db_table_str[conn_link_idx]; + DBUG_PRINT("info",("spider db_table_str=%s", + tmp_link_for_hash2->db_table_str->c_ptr_safe())); #ifdef SPIDER_HAS_HASH_VALUE_TYPE tmp_link_for_hash2->db_table_str_hash_value = mysql_share->db_table_str_hash_value[conn_link_idx]; @@ -11665,7 +11679,8 @@ int spider_mbase_handler::append_lock_tables_list( DBUG_RETURN(error_num); *appended = 1; } else { - if (tmp_link_for_hash->spider->lock_type < spider->lock_type) + if (tmp_link_for_hash->spider->wide_handler->lock_type < + spider->wide_handler->lock_type) { #ifdef HASH_UPDATE_WITH_HASH_VALUE my_hash_delete_with_hash_value( @@ -11705,7 +11720,7 @@ int spider_mbase_handler::append_lock_tables_list( int spider_mbase_handler::realloc_sql( ulong *realloced ) { - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; st_spider_share *share = spider->share; int init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); @@ -12162,7 +12177,8 @@ int spider_mbase_handler::show_table_status( conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; conn->disable_connect_retry = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -12199,7 +12215,8 @@ int spider_mbase_handler::show_table_status( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12223,8 +12240,8 @@ int spider_mbase_handler::show_table_status( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -12302,7 +12319,8 @@ int spider_mbase_handler::show_table_status( conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; conn->disable_connect_retry = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -12339,7 +12357,8 @@ int spider_mbase_handler::show_table_status( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12363,8 +12382,8 @@ int spider_mbase_handler::show_table_status( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -12476,7 +12495,8 @@ int spider_mbase_handler::show_index( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -12511,7 +12531,8 @@ int spider_mbase_handler::show_index( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12533,8 +12554,8 @@ int spider_mbase_handler::show_index( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -12609,7 +12630,8 @@ int spider_mbase_handler::show_index( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -12644,7 +12666,8 @@ int spider_mbase_handler::show_index( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12666,8 +12689,8 @@ int spider_mbase_handler::show_index( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -12754,7 +12777,8 @@ int spider_mbase_handler::show_records( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -12791,7 +12815,8 @@ int spider_mbase_handler::show_records( DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12815,8 +12840,8 @@ int spider_mbase_handler::show_records( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -12849,7 +12874,7 @@ int spider_mbase_handler::show_records( DBUG_PRINT("info", ("spider error_num=%d 7", error_num)); DBUG_RETURN(error_num); } - spider->trx->direct_aggregate_count++; + spider->wide_handler->trx->direct_aggregate_count++; DBUG_RETURN(0); } @@ -12888,7 +12913,8 @@ ha_rows spider_mbase_handler::explain_select( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -12927,7 +12953,8 @@ ha_rows spider_mbase_handler::explain_select( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); if (spider_db_query( conn, @@ -12956,8 +12983,8 @@ ha_rows spider_mbase_handler::explain_select( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -13026,7 +13053,8 @@ int spider_mbase_handler::lock_tables( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); if (spider_db_query( conn, @@ -13047,7 +13075,7 @@ int spider_mbase_handler::lock_tables( if (!conn->table_locked) { conn->table_locked = TRUE; - spider->trx->locked_connections++; + spider->wide_handler->trx->locked_connections++; } DBUG_RETURN(0); } @@ -13062,7 +13090,7 @@ int spider_mbase_handler::unlock_tables( { spider_string *str = &sql; conn->table_locked = FALSE; - spider->trx->locked_connections--; + spider->wide_handler->trx->locked_connections--; str->length(0); if ((error_num = conn->db_conn->append_unlock_tables(str))) @@ -13071,7 +13099,8 @@ int spider_mbase_handler::unlock_tables( } if (str->length()) { - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); if (spider_db_query( conn, @@ -13116,7 +13145,8 @@ int spider_mbase_handler::disable_keys( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -13165,7 +13195,8 @@ int spider_mbase_handler::enable_keys( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -13215,7 +13246,8 @@ int spider_mbase_handler::check_table( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -13265,7 +13297,8 @@ int spider_mbase_handler::repair_table( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -13314,7 +13347,8 @@ int spider_mbase_handler::analyze_table( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -13363,7 +13397,8 @@ int spider_mbase_handler::optimize_table( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -13400,7 +13435,8 @@ int spider_mbase_handler::flush_tables( { DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -13425,7 +13461,8 @@ int spider_mbase_handler::flush_logs( SPIDER_SHARE *share = spider->share; DBUG_ENTER("spider_mbase_handler::flush_logs"); DBUG_PRINT("info",("spider this=%p", this)); - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -13547,16 +13584,17 @@ void spider_mbase_handler::minimum_select_bitmap_create() } } } - DBUG_PRINT("info",("spider searched_bitmap=%p", spider->searched_bitmap)); + DBUG_PRINT("info",("spider searched_bitmap=%p", + spider->wide_handler->searched_bitmap)); for (field_p = table->field; *field_p; field_p++) { uint field_index = (*field_p)->field_index; DBUG_PRINT("info",("spider field_index=%u", field_index)); DBUG_PRINT("info",("spider ft_discard_bitmap=%s", - spider_bit_is_set(spider->ft_discard_bitmap, field_index) ? + spider_bit_is_set(spider->wide_handler->ft_discard_bitmap, field_index) ? "TRUE" : "FALSE")); DBUG_PRINT("info",("spider searched_bitmap=%s", - spider_bit_is_set(spider->searched_bitmap, field_index) ? + spider_bit_is_set(spider->wide_handler->searched_bitmap, field_index) ? "TRUE" : "FALSE")); DBUG_PRINT("info",("spider read_set=%s", bitmap_is_set(table->read_set, field_index) ? @@ -13565,9 +13603,9 @@ void spider_mbase_handler::minimum_select_bitmap_create() bitmap_is_set(table->write_set, field_index) ? "TRUE" : "FALSE")); if ( - spider_bit_is_set(spider->ft_discard_bitmap, field_index) & + spider_bit_is_set(spider->wide_handler->ft_discard_bitmap, field_index) & ( - spider_bit_is_set(spider->searched_bitmap, field_index) | + spider_bit_is_set(spider->wide_handler->searched_bitmap, field_index) | bitmap_is_set(table->read_set, field_index) | bitmap_is_set(table->write_set, field_index) ) diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index e455ce0e4c0..82a4599901b 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -2289,7 +2289,7 @@ int spider_db_oracle::append_lock_tables( tmp_spider = tmp_link_for_hash->spider; tmp_link_idx = tmp_link_for_hash->link_idx; - switch (tmp_spider->lock_type) + switch (tmp_spider->wide_handler->lock_type) { case TL_READ: lock_type = SPIDER_DB_TABLE_LOCK_READ_LOCAL; @@ -2305,7 +2305,8 @@ int spider_db_oracle::append_lock_tables( break; default: // no lock - DBUG_PRINT("info",("spider lock_type=%d", tmp_spider->lock_type)); + DBUG_PRINT("info",("spider lock_type=%d", + tmp_spider->wide_handler->lock_type)); DBUG_RETURN(0); } conn_link_idx = tmp_spider->conn_link_idx[tmp_link_idx]; @@ -3928,7 +3929,8 @@ int spider_db_oracle_util::open_item_func( } break; case Item_func::UDF_FUNC: - use_pushdown_udf = spider_param_use_pushdown_udf(spider->trx->thd, + use_pushdown_udf = spider_param_use_pushdown_udf( + spider->wide_handler->trx->thd, spider->share->use_pushdown_udf); if (!use_pushdown_udf) DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); @@ -4069,7 +4071,7 @@ int spider_db_oracle_util::open_item_func( DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); #endif default: - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; SPIDER_SHARE *share = spider->share; if (spider_param_skip_default_condition(thd, share->skip_default_condition)) @@ -5400,7 +5402,7 @@ spider_oracle_handler::~spider_oracle_handler() int spider_oracle_handler::init() { uint roop_count; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; st_spider_share *share = spider->share; int init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); @@ -5782,7 +5784,7 @@ int spider_oracle_handler::append_create_tmp_bka_table( ) { int error_num; SPIDER_SHARE *share = spider->share; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; char *bka_engine = spider_param_bka_engine(thd, share->bka_engine); uint bka_engine_length = strlen(bka_engine), cset_length = strlen(table_charset->csname); @@ -7531,7 +7533,7 @@ int spider_oracle_handler::append_update_where( ) { uint field_name_length; Field **field; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; SPIDER_SHARE *share = spider->share; bool no_pk = (table->s->primary_key == MAX_KEY); DBUG_ENTER("spider_oracle_handler::append_update_where"); @@ -9729,7 +9731,8 @@ int spider_oracle_handler::append_optimize_table( ) { SPIDER_SHARE *share = spider->share; int conn_link_idx = spider->conn_link_idx[link_idx]; - int local_length = spider_param_internal_optimize_local(spider->trx->thd, + int local_length = spider_param_internal_optimize_local( + spider->wide_handler->trx->thd, share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; DBUG_ENTER("spider_oracle_handler::append_optimize_table"); DBUG_PRINT("info",("spider this=%p", this)); @@ -9774,7 +9777,8 @@ int spider_oracle_handler::append_analyze_table( ) { SPIDER_SHARE *share = spider->share; int conn_link_idx = spider->conn_link_idx[link_idx]; - int local_length = spider_param_internal_optimize_local(spider->trx->thd, + int local_length = spider_param_internal_optimize_local( + spider->wide_handler->trx->thd, share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; DBUG_ENTER("spider_oracle_handler::append_analyze_table"); DBUG_PRINT("info",("spider this=%p", this)); @@ -9821,7 +9825,8 @@ int spider_oracle_handler::append_repair_table( ) { SPIDER_SHARE *share = spider->share; int conn_link_idx = spider->conn_link_idx[link_idx]; - int local_length = spider_param_internal_optimize_local(spider->trx->thd, + int local_length = spider_param_internal_optimize_local( + spider->wide_handler->trx->thd, share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; DBUG_ENTER("spider_oracle_handler::append_repair_table"); DBUG_PRINT("info",("spider this=%p", this)); @@ -10338,7 +10343,7 @@ bool spider_oracle_handler::bulk_tmp_table_created() int spider_oracle_handler::mk_bulk_tmp_table_and_bulk_start() { - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; TABLE *table = spider->get_table(); DBUG_ENTER("spider_oracle_handler::mk_bulk_tmp_table_and_bulk_start"); DBUG_PRINT("info",("spider this=%p", this)); @@ -10367,7 +10372,8 @@ void spider_oracle_handler::rm_bulk_tmp_table() DBUG_PRINT("info",("spider this=%p", this)); if (upd_tmp_tbl) { - spider_rm_sys_tmp_table(spider->trx->thd, upd_tmp_tbl, &upd_tmp_tbl_prm); + spider_rm_sys_tmp_table(spider->wide_handler->trx->thd, upd_tmp_tbl, + &upd_tmp_tbl_prm); upd_tmp_tbl = NULL; } DBUG_VOID_RETURN; @@ -10464,7 +10470,8 @@ int spider_oracle_handler::append_lock_tables_list( DBUG_RETURN(error_num); *appended = 1; } else { - if (tmp_link_for_hash->spider->lock_type < spider->lock_type) + if (tmp_link_for_hash->spider->wide_handler->lock_type < + spider->wide_handler->lock_type) { #ifdef HASH_UPDATE_WITH_HASH_VALUE my_hash_delete_with_hash_value( @@ -10504,7 +10511,7 @@ int spider_oracle_handler::append_lock_tables_list( int spider_oracle_handler::realloc_sql( ulong *realloced ) { - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; st_spider_share *share = spider->share; int init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); @@ -11043,7 +11050,8 @@ int spider_oracle_handler::show_table_status( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -11080,7 +11088,8 @@ int spider_oracle_handler::show_table_status( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -11102,8 +11111,8 @@ int spider_oracle_handler::show_table_status( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -11158,7 +11167,8 @@ int spider_oracle_handler::show_table_status( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -11193,7 +11203,8 @@ int spider_oracle_handler::show_table_status( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -11215,8 +11226,8 @@ int spider_oracle_handler::show_table_status( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -11289,7 +11300,8 @@ int spider_oracle_handler::show_index( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -11326,7 +11338,8 @@ int spider_oracle_handler::show_index( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -11348,8 +11361,8 @@ int spider_oracle_handler::show_index( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -11408,7 +11421,8 @@ int spider_oracle_handler::show_index( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -11443,7 +11457,8 @@ int spider_oracle_handler::show_index( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -11465,8 +11480,8 @@ int spider_oracle_handler::show_index( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -11532,7 +11547,8 @@ int spider_oracle_handler::show_records( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -11569,7 +11585,8 @@ int spider_oracle_handler::show_records( DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -11593,8 +11610,8 @@ int spider_oracle_handler::show_records( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -11627,7 +11644,7 @@ int spider_oracle_handler::show_records( DBUG_PRINT("info", ("spider error_num=%d 7", error_num)); DBUG_RETURN(error_num); } - spider->trx->direct_aggregate_count++; + spider->wide_handler->trx->direct_aggregate_count++; DBUG_RETURN(0); } @@ -11649,7 +11666,8 @@ int spider_oracle_handler::show_autoinc( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -11686,7 +11704,8 @@ int spider_oracle_handler::show_autoinc( DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -11710,8 +11729,8 @@ int spider_oracle_handler::show_autoinc( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -11786,8 +11805,8 @@ int spider_oracle_handler::show_last_insert_id( DBUG_RETURN(error_num); } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -11843,7 +11862,8 @@ ha_rows spider_oracle_handler::explain_select( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); if ( (error_num = spider_db_set_names(spider, conn, link_idx)) || @@ -11882,7 +11902,8 @@ ha_rows spider_oracle_handler::explain_select( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); if (spider_db_query( conn, @@ -11911,8 +11932,8 @@ ha_rows spider_oracle_handler::explain_select( } } st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; + request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; + request_key.query_id = spider->wide_handler->trx->thd->query_id; request_key.handler = spider; request_key.request_id = 1; request_key.next = NULL; @@ -11982,7 +12003,8 @@ int spider_oracle_handler::lock_tables( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); if (spider_db_query( conn, @@ -12003,7 +12025,7 @@ int spider_oracle_handler::lock_tables( if (!conn->table_locked) { conn->table_locked = TRUE; - spider->trx->locked_connections++; + spider->wide_handler->trx->locked_connections++; } } while (str->length()); DBUG_RETURN(0); @@ -12053,7 +12075,8 @@ int spider_oracle_handler::disable_keys( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12102,7 +12125,8 @@ int spider_oracle_handler::enable_keys( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12152,7 +12176,8 @@ int spider_oracle_handler::check_table( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12202,7 +12227,8 @@ int spider_oracle_handler::repair_table( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12251,7 +12277,8 @@ int spider_oracle_handler::analyze_table( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12300,7 +12327,8 @@ int spider_oracle_handler::optimize_table( pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12337,7 +12365,8 @@ int spider_oracle_handler::flush_tables( { DBUG_RETURN(error_num); } - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, @@ -12362,7 +12391,8 @@ int spider_oracle_handler::flush_logs( SPIDER_SHARE *share = spider->share; DBUG_ENTER("spider_oracle_handler::flush_logs"); DBUG_PRINT("info",("spider this=%p", this)); - spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, share); if (spider_db_query( conn, diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 3b57092c4ce..146dbd918b2 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -794,7 +794,7 @@ void spider_fields::choose_a_conn( SPIDER_CONN_HOLDER *conn_holder; longlong balance_total = 0, balance_val; double rand_val; - THD *thd = table_holder[0].spider->trx->thd; + THD *thd = table_holder[0].spider->wide_handler->trx->thd; DBUG_ENTER("spider_fields::choose_a_conn"); DBUG_PRINT("info",("spider this=%p", this)); for (current_conn_holder = first_conn_holder; current_conn_holder; @@ -1146,8 +1146,8 @@ int spider_fields::ping_table_mon_from_table( if (tmp_share->monitoring_kind[tmp_link_idx]) { error_num_buf = spider_ping_table_mon_from_table( - tmp_spider->trx, - tmp_spider->trx->thd, + tmp_spider->wide_handler->trx, + tmp_spider->wide_handler->trx->thd, tmp_share, tmp_link_idx, (uint32) tmp_share->monitoring_sid[tmp_link_idx], @@ -1180,7 +1180,7 @@ spider_group_by_handler::spider_group_by_handler( fields->set_pos_to_first_table_holder(); SPIDER_TABLE_HOLDER *table_holder = fields->get_next_table_holder(); spider = table_holder->spider; - trx = spider->trx; + trx = spider->wide_handler->trx; DBUG_VOID_RETURN; } @@ -1917,6 +1917,12 @@ group_by_handler *spider_create_group_by_handler( delete fields; DBUG_RETURN(NULL); } + if (spider->dml_init()) + { + DBUG_PRINT("info",("spider can not init for dml")); + delete fields; + DBUG_RETURN(NULL); + } for ( roop_count = spider_conn_link_idx_next(share->link_statuses, spider->conn_link_idx, -1, share->link_count, @@ -1998,6 +2004,12 @@ group_by_handler *spider_create_group_by_handler( } DBUG_PRINT("info",("spider s->db=%s", from->table->s->db.str)); DBUG_PRINT("info",("spider s->table_name=%s", from->table->s->table_name.str)); + if (spider->dml_init()) + { + DBUG_PRINT("info",("spider can not init for dml")); + delete fields; + DBUG_RETURN(NULL); + } for ( roop_count = spider_conn_link_idx_next(share->link_statuses, spider->conn_link_idx, -1, share->link_count, diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index ead33853957..107985b7895 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -615,26 +615,19 @@ typedef struct st_spider_lgtm_tblhnd_share #ifdef WITH_PARTITION_STORAGE_ENGINE typedef struct st_spider_patition_handler_share { - uint use_count; - TABLE *table; + bool clone_bitmap_init; #ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type table_hash_value; #endif - void *creator; - void **handlers; - uchar *searched_bitmap; - uchar *ft_discard_bitmap; - uchar *idx_read_bitmap; - uchar *idx_write_bitmap; - uchar *rnd_read_bitmap; - uchar *rnd_write_bitmap; - bool between_flg; - bool idx_bitmap_is_set; - bool rnd_bitmap_is_set; query_id_t parallel_search_query_id; + uint no_parts; + TABLE *table; + ha_spider *owner; + ha_spider **handlers; } SPIDER_PARTITION_HANDLER_SHARE; +#endif -typedef struct st_spider_patition_share +typedef struct st_spider_wide_share { char *table_name; uint table_name_length; @@ -642,6 +635,7 @@ typedef struct st_spider_patition_share my_hash_value_type table_path_hash_value; #endif uint use_count; + THR_LOCK lock; pthread_mutex_t sts_mutex; pthread_mutex_t crd_mutex; pthread_mutex_t pt_handler_mutex; @@ -666,11 +660,88 @@ typedef struct st_spider_patition_share time_t update_time; longlong *cardinality; -/* - volatile SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share; -*/ -} SPIDER_PARTITION_SHARE; +} SPIDER_WIDE_SHARE; + +typedef struct st_spider_wide_handler +{ + THR_LOCK_DATA lock; + SPIDER_TRX *trx; + uchar *searched_bitmap; + uchar *ft_discard_bitmap; + uchar *position_bitmap; + uchar *idx_read_bitmap; + uchar *idx_write_bitmap; + uchar *rnd_read_bitmap; + uchar *rnd_write_bitmap; + SPIDER_CONDITION *condition; + void *owner; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + uint32 *hs_pushed_ret_fields; +#endif #endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share; +#endif +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + List<Item> *direct_update_fields; + List<Item> *direct_update_values; +#endif + TABLE *top_table; + Field **top_table_field; + enum thr_lock_type lock_type; + uchar lock_table_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + uint32 hs_pushed_strref_num; +#endif +#endif + int lock_mode; + int external_lock_type; + int cond_check_error; + uint sql_command; + uint top_table_fields; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + longlong info_limit; +#endif +#endif +#ifdef HA_CAN_BULK_ACCESS + ulonglong external_lock_cnt; +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + size_t hs_pushed_ret_fields_num; + size_t hs_pushed_ret_fields_size; + size_t hs_pushed_lcl_fields_num; +#endif +#endif + bool between_flg; + bool idx_bitmap_is_set; + bool rnd_bitmap_is_set; + bool position_bitmap_init; + bool semi_trx_isolation_chk; + bool semi_trx_chk; + bool low_priority; + bool high_priority; + bool insert_delayed; + bool consistent_snapshot; + bool quick_mode; + bool keyread; + bool update_request; + bool ignore_dup_key; + bool write_can_replace; + bool insert_with_update; + bool cond_check; + bool set_top_table_fields; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + bool hs_increment; + bool hs_decrement; +#endif +#endif + bool semi_table_lock; +} SPIDER_WIDE_HANDLER; typedef struct st_spider_transaction { @@ -807,7 +878,6 @@ typedef struct st_spider_share /* pthread_mutex_t auto_increment_mutex; */ - THR_LOCK lock; TABLE_SHARE *table_share; SPIDER_LGTM_TBLHND_SHARE *lgtm_tblhnd_share; #ifdef SPIDER_HAS_HASH_VALUE_TYPE @@ -1189,9 +1259,7 @@ typedef struct st_spider_share #endif SPIDER_ALTER_TABLE alter_table; -#ifdef WITH_PARTITION_STORAGE_ENGINE - SPIDER_PARTITION_SHARE *partition_share; -#endif + SPIDER_WIDE_SHARE *wide_share; } SPIDER_SHARE; typedef struct st_spider_link_pack diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index d17e76e5ec6..9328c44e3e3 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -144,7 +144,7 @@ SPIDER_THREAD *spider_table_crd_threads; PSI_mutex_key spd_key_mutex_tbl; PSI_mutex_key spd_key_mutex_init_error_tbl; #ifdef WITH_PARTITION_STORAGE_ENGINE -PSI_mutex_key spd_key_mutex_pt_share; +PSI_mutex_key spd_key_mutex_wide_share; #endif PSI_mutex_key spd_key_mutex_lgtm_tblhnd_share; PSI_mutex_key spd_key_mutex_conn; @@ -174,8 +174,8 @@ PSI_mutex_key spd_key_mutex_share_sts; PSI_mutex_key spd_key_mutex_share_crd; PSI_mutex_key spd_key_mutex_share_auto_increment; #ifdef WITH_PARTITION_STORAGE_ENGINE -PSI_mutex_key spd_key_mutex_pt_share_sts; -PSI_mutex_key spd_key_mutex_pt_share_crd; +PSI_mutex_key spd_key_mutex_wide_share_sts; +PSI_mutex_key spd_key_mutex_wide_share_crd; PSI_mutex_key spd_key_mutex_pt_handler; #endif PSI_mutex_key spd_key_mutex_udf_table; @@ -194,7 +194,7 @@ static PSI_mutex_info all_spider_mutexes[]= { &spd_key_mutex_tbl, "tbl", PSI_FLAG_GLOBAL}, { &spd_key_mutex_init_error_tbl, "init_error_tbl", PSI_FLAG_GLOBAL}, #ifdef WITH_PARTITION_STORAGE_ENGINE - { &spd_key_mutex_pt_share, "pt_share", PSI_FLAG_GLOBAL}, + { &spd_key_mutex_wide_share, "wide_share", PSI_FLAG_GLOBAL}, #endif { &spd_key_mutex_lgtm_tblhnd_share, "lgtm_tblhnd_share", PSI_FLAG_GLOBAL}, { &spd_key_mutex_conn, "conn", PSI_FLAG_GLOBAL}, @@ -233,8 +233,8 @@ static PSI_mutex_info all_spider_mutexes[]= { &spd_key_mutex_share_crd, "share_crd", 0}, { &spd_key_mutex_share_auto_increment, "share_auto_increment", 0}, #ifdef WITH_PARTITION_STORAGE_ENGINE - { &spd_key_mutex_pt_share_sts, "pt_share_sts", 0}, - { &spd_key_mutex_pt_share_crd, "pt_share_crd", 0}, + { &spd_key_mutex_wide_share_sts, "wide_share_sts", 0}, + { &spd_key_mutex_wide_share_crd, "wide_share_crd", 0}, { &spd_key_mutex_pt_handler, "pt_handler", 0}, #endif { &spd_key_mutex_udf_table, "udf_table", 0}, @@ -357,12 +357,12 @@ extern pthread_mutex_t spider_conn_id_mutex; extern pthread_mutex_t spider_ipport_conn_mutex; #ifdef WITH_PARTITION_STORAGE_ENGINE -HASH spider_open_pt_share; -uint spider_open_pt_share_id; -const char *spider_open_pt_share_func_name; -const char *spider_open_pt_share_file_name; -ulong spider_open_pt_share_line_no; -pthread_mutex_t spider_pt_share_mutex; +HASH spider_open_wide_share; +uint spider_open_wide_share_id; +const char *spider_open_wide_share_func_name; +const char *spider_open_wide_share_file_name; +ulong spider_open_wide_share_line_no; +pthread_mutex_t spider_wide_share_mutex; #endif HASH spider_lgtm_tblhnd_share_hash; @@ -407,25 +407,25 @@ uchar *spider_tbl_get_key( DBUG_RETURN((uchar*) share->table_name); } -#ifdef WITH_PARTITION_STORAGE_ENGINE -uchar *spider_pt_share_get_key( - SPIDER_PARTITION_SHARE *share, +uchar *spider_wide_share_get_key( + SPIDER_WIDE_SHARE *share, size_t *length, my_bool not_used __attribute__ ((unused)) ) { - DBUG_ENTER("spider_pt_share_get_key"); + DBUG_ENTER("spider_wide_share_get_key"); *length = share->table_name_length; DBUG_RETURN((uchar*) share->table_name); } +#ifdef WITH_PARTITION_STORAGE_ENGINE uchar *spider_pt_handler_share_get_key( SPIDER_PARTITION_HANDLER_SHARE *share, size_t *length, my_bool not_used __attribute__ ((unused)) ) { DBUG_ENTER("spider_pt_handler_share_get_key"); - *length = sizeof(TABLE *); - DBUG_RETURN((uchar*) &share->table); + *length = sizeof(ha_spider *); + DBUG_RETURN((uchar*) share->owner); } #endif @@ -905,10 +905,8 @@ int spider_free_share_alloc( delete [] share->key_hint; share->key_hint = NULL; } -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (share->partition_share) - spider_free_pt_share(share->partition_share); -#endif + if (share->wide_share) + spider_free_wide_share(share->wide_share); DBUG_RETURN(0); } @@ -4502,8 +4500,6 @@ SPIDER_SHARE *spider_create_share( goto error_init_crd_mutex; } - thr_lock_init(&share->lock); - #ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(share->lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share(tmp_name, length, hash_value, FALSE, TRUE, @@ -4516,11 +4512,9 @@ SPIDER_SHARE *spider_create_share( goto error_get_lgtm_tblhnd_share; } -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (!(share->partition_share = - spider_get_pt_share(share, table_share, error_num))) - goto error_get_pt_share; -#endif + if (!(share->wide_share = + spider_get_wide_share(share, table_share, error_num))) + goto error_get_wide_share; for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++) { @@ -4552,12 +4546,9 @@ error_init_dbton: share->dbton_share[roop_count] = NULL; } } -#ifdef WITH_PARTITION_STORAGE_ENGINE - spider_free_pt_share(share->partition_share); -error_get_pt_share: -#endif + spider_free_wide_share(share->wide_share); +error_get_wide_share: error_get_lgtm_tblhnd_share: - thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->crd_mutex); error_init_crd_mutex: pthread_mutex_destroy(&share->sts_mutex); @@ -4779,7 +4770,7 @@ SPIDER_SHARE *spider_get_share( else first_byte = '0'; - if (!(spider->trx = spider_get_trx(thd, TRUE, error_num))) + if (!(spider->wide_handler->trx = spider_get_trx(thd, TRUE, error_num))) { share->init_error = TRUE; share->init_error_time = (time_t) time((time_t*) 0); @@ -4796,7 +4787,7 @@ SPIDER_SHARE *spider_get_share( if (!share->sts_spider_init) { if ((*error_num = spider_create_spider_object_for_share( - spider->trx, share, &share->sts_spider))) + spider->wide_handler->trx, share, &share->sts_spider))) { pthread_mutex_unlock(&share->mutex); share->init_error = TRUE; @@ -4824,7 +4815,7 @@ SPIDER_SHARE *spider_get_share( if (!share->crd_spider_init) { if ((*error_num = spider_create_spider_object_for_share( - spider->trx, share, &share->crd_spider))) + spider->wide_handler->trx, share, &share->crd_spider))) { pthread_mutex_unlock(&share->mutex); share->init_error = TRUE; @@ -4852,7 +4843,8 @@ SPIDER_SHARE *spider_get_share( sql_command != SQLCOM_DROP_TABLE && sql_command != SQLCOM_ALTER_TABLE && sql_command != SQLCOM_SHOW_CREATE && - (*error_num = spider_create_mon_threads(spider->trx, share)) + (*error_num = spider_create_mon_threads(spider->wide_handler->trx, + share)) ) { share->init_error = TRUE; share->init_error_time = (time_t) time((time_t*) 0); @@ -5024,7 +5016,8 @@ SPIDER_SHARE *spider_get_share( if ( !(spider->conns[roop_count] = spider_get_conn(share, roop_count, spider->conn_keys[roop_count], - spider->trx, spider, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL, + spider->wide_handler->trx, spider, FALSE, TRUE, + SPIDER_CONN_KIND_MYSQL, error_num)) ) { if ( @@ -5032,8 +5025,8 @@ SPIDER_SHARE *spider_get_share( spider->need_mons[roop_count] ) { *error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5136,7 +5129,7 @@ SPIDER_SHARE *spider_get_share( pthread_mutex_lock(&share->sts_mutex); pthread_mutex_lock(&share->crd_mutex); if ((spider_init_error_table = - spider_get_init_error_table(spider->trx, share, FALSE))) + spider_get_init_error_table(spider->wide_handler->trx, share, FALSE))) { DBUG_PRINT("info",("spider diff1=%f", difftime(tmp_time, spider_init_error_table->init_error_time))); @@ -5314,7 +5307,7 @@ SPIDER_SHARE *spider_get_share( first_byte = '0'; spider->share = share; - if (!(spider->trx = spider_get_trx(thd, TRUE, error_num))) + if (!(spider->wide_handler->trx = spider_get_trx(thd, TRUE, error_num))) { spider_free_share(share); goto error_but_no_delete; @@ -5328,7 +5321,7 @@ SPIDER_SHARE *spider_get_share( if (!share->sts_spider_init) { if ((*error_num = spider_create_spider_object_for_share( - spider->trx, share, &share->sts_spider))) + spider->wide_handler->trx, share, &share->sts_spider))) { pthread_mutex_unlock(&share->mutex); spider_free_share(share); @@ -5353,7 +5346,7 @@ SPIDER_SHARE *spider_get_share( if (!share->crd_spider_init) { if ((*error_num = spider_create_spider_object_for_share( - spider->trx, share, &share->crd_spider))) + spider->wide_handler->trx, share, &share->crd_spider))) { pthread_mutex_unlock(&share->mutex); spider_free_share(share); @@ -5378,7 +5371,8 @@ SPIDER_SHARE *spider_get_share( sql_command != SQLCOM_DROP_TABLE && sql_command != SQLCOM_ALTER_TABLE && sql_command != SQLCOM_SHOW_CREATE && - (*error_num = spider_create_mon_threads(spider->trx, share)) + (*error_num = spider_create_mon_threads(spider->wide_handler->trx, + share)) ) { spider_free_share(share); goto error_but_no_delete; @@ -5540,7 +5534,8 @@ SPIDER_SHARE *spider_get_share( if ( !(spider->conns[roop_count] = spider_get_conn(share, roop_count, spider->conn_keys[roop_count], - spider->trx, spider, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL, + spider->wide_handler->trx, spider, FALSE, TRUE, + SPIDER_CONN_KIND_MYSQL, error_num)) ) { if ( @@ -5548,8 +5543,8 @@ SPIDER_SHARE *spider_get_share( spider->need_mons[roop_count] ) { *error_num = spider_ping_table_mon_from_table( - spider->trx, - spider->trx->thd, + spider->wide_handler->trx, + spider->wide_handler->trx->thd, share, roop_count, (uint32) share->monitoring_sid[roop_count], @@ -5644,7 +5639,8 @@ SPIDER_SHARE *spider_get_share( #endif time_t tmp_time = (time_t) time((time_t*) 0); if ((spider_init_error_table = - spider_get_init_error_table(spider->trx, share, FALSE))) + spider_get_init_error_table(spider->wide_handler->trx, share, + FALSE))) { DBUG_PRINT("info",("spider diff2=%f", difftime(tmp_time, spider_init_error_table->init_error_time))); @@ -5732,7 +5728,6 @@ void spider_free_share_resource_only( ) { DBUG_ENTER("spider_free_share_resource_only"); spider_free_share_alloc(share); - thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->crd_mutex); pthread_mutex_destroy(&share->sts_mutex); pthread_mutex_destroy(&share->mutex); @@ -5819,7 +5814,6 @@ int spider_free_share( #else my_hash_delete(&spider_open_tables, (uchar*) share); #endif - thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->crd_mutex); pthread_mutex_destroy(&share->sts_mutex); pthread_mutex_destroy(&share->mutex); @@ -5991,33 +5985,32 @@ void spider_free_lgtm_tblhnd_share_alloc( DBUG_VOID_RETURN; } -#ifdef WITH_PARTITION_STORAGE_ENGINE -SPIDER_PARTITION_SHARE *spider_get_pt_share( +SPIDER_WIDE_SHARE *spider_get_wide_share( SPIDER_SHARE *share, TABLE_SHARE *table_share, int *error_num ) { - SPIDER_PARTITION_SHARE *partition_share; + SPIDER_WIDE_SHARE *wide_share; char *tmp_name; longlong *tmp_cardinality; - DBUG_ENTER("spider_get_pt_share"); + DBUG_ENTER("spider_get_wide_share"); - pthread_mutex_lock(&spider_pt_share_mutex); + pthread_mutex_lock(&spider_wide_share_mutex); #ifdef SPIDER_HAS_HASH_VALUE_TYPE - if (!(partition_share = (SPIDER_PARTITION_SHARE*) + if (!(wide_share = (SPIDER_WIDE_SHARE*) my_hash_search_using_hash_value( - &spider_open_pt_share, share->table_path_hash_value, + &spider_open_wide_share, share->table_path_hash_value, (uchar*) table_share->path.str, table_share->path.length))) #else - if (!(partition_share = (SPIDER_PARTITION_SHARE*) my_hash_search( - &spider_open_pt_share, + if (!(wide_share = (SPIDER_WIDE_SHARE*) my_hash_search( + &spider_open_wide_share, (uchar*) table_share->path.str, table_share->path.length))) #endif { - DBUG_PRINT("info",("spider create new pt share")); - if (!(partition_share = (SPIDER_PARTITION_SHARE *) + DBUG_PRINT("info",("spider create new wide share")); + if (!(wide_share = (SPIDER_WIDE_SHARE *) spider_bulk_malloc(spider_current_trx, 51, MYF(MY_WME | MY_ZEROFILL), - &partition_share, sizeof(*partition_share), + &wide_share, sizeof(SPIDER_WIDE_SHARE), &tmp_name, table_share->path.length + 1, &tmp_cardinality, sizeof(*tmp_cardinality) * table_share->fields, NullS)) @@ -6026,24 +6019,24 @@ SPIDER_PARTITION_SHARE *spider_get_pt_share( goto error_alloc_share; } - partition_share->use_count = 0; - partition_share->table_name_length = table_share->path.length; - partition_share->table_name = tmp_name; - memcpy(partition_share->table_name, table_share->path.str, - partition_share->table_name_length); + wide_share->use_count = 0; + wide_share->table_name_length = table_share->path.length; + wide_share->table_name = tmp_name; + memcpy(wide_share->table_name, table_share->path.str, + wide_share->table_name_length); #ifdef SPIDER_HAS_HASH_VALUE_TYPE - partition_share->table_path_hash_value = share->table_path_hash_value; + wide_share->table_path_hash_value = share->table_path_hash_value; #endif - partition_share->cardinality = tmp_cardinality; + wide_share->cardinality = tmp_cardinality; - partition_share->crd_get_time = partition_share->sts_get_time = + wide_share->crd_get_time = wide_share->sts_get_time = share->crd_get_time; #if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&partition_share->sts_mutex, MY_MUTEX_INIT_FAST)) + if (pthread_mutex_init(&wide_share->sts_mutex, MY_MUTEX_INIT_FAST)) #else - if (mysql_mutex_init(spd_key_mutex_pt_share_sts, - &partition_share->sts_mutex, MY_MUTEX_INIT_FAST)) + if (mysql_mutex_init(spd_key_mutex_wide_share_sts, + &wide_share->sts_mutex, MY_MUTEX_INIT_FAST)) #endif { *error_num = HA_ERR_OUT_OF_MEM; @@ -6051,10 +6044,10 @@ SPIDER_PARTITION_SHARE *spider_get_pt_share( } #if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&partition_share->crd_mutex, MY_MUTEX_INIT_FAST)) + if (pthread_mutex_init(&wide_share->crd_mutex, MY_MUTEX_INIT_FAST)) #else - if (mysql_mutex_init(spd_key_mutex_pt_share_crd, - &partition_share->crd_mutex, MY_MUTEX_INIT_FAST)) + if (mysql_mutex_init(spd_key_mutex_wide_share_crd, + &wide_share->crd_mutex, MY_MUTEX_INIT_FAST)) #endif { *error_num = HA_ERR_OUT_OF_MEM; @@ -6062,11 +6055,11 @@ SPIDER_PARTITION_SHARE *spider_get_pt_share( } #if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&partition_share->pt_handler_mutex, + if (pthread_mutex_init(&wide_share->pt_handler_mutex, MY_MUTEX_INIT_FAST)) #else if (mysql_mutex_init(spd_key_mutex_pt_handler, - &partition_share->pt_handler_mutex, MY_MUTEX_INIT_FAST)) + &wide_share->pt_handler_mutex, MY_MUTEX_INIT_FAST)) #endif { *error_num = HA_ERR_OUT_OF_MEM; @@ -6074,160 +6067,138 @@ SPIDER_PARTITION_SHARE *spider_get_pt_share( } if( - my_hash_init(&partition_share->pt_handler_hash, spd_charset_utf8_bin, + my_hash_init(&wide_share->pt_handler_hash, spd_charset_utf8_bin, 32, 0, 0, (my_hash_get_key) spider_pt_handler_share_get_key, 0, 0) ) { *error_num = HA_ERR_OUT_OF_MEM; goto error_init_pt_handler_hash; } - spider_alloc_calc_mem_init(partition_share->pt_handler_hash, 142); + + thr_lock_init(&wide_share->lock); + + spider_alloc_calc_mem_init(wide_share->pt_handler_hash, 142); spider_alloc_calc_mem(spider_current_trx, - partition_share->pt_handler_hash, - partition_share->pt_handler_hash.array.max_element * - partition_share->pt_handler_hash.array.size_of_element); + wide_share->pt_handler_hash, + wide_share->pt_handler_hash.array.max_element * + wide_share->pt_handler_hash.array.size_of_element); - uint old_elements = spider_open_pt_share.array.max_element; + uint old_elements = spider_open_wide_share.array.max_element; #ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_open_pt_share, + if (my_hash_insert_with_hash_value(&spider_open_wide_share, share->table_path_hash_value, - (uchar*) partition_share)) + (uchar*) wide_share)) #else - if (my_hash_insert(&spider_open_pt_share, (uchar*) partition_share)) + if (my_hash_insert(&spider_open_wide_share, (uchar*) wide_share)) #endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_hash_insert; } - if (spider_open_pt_share.array.max_element > old_elements) + if (spider_open_wide_share.array.max_element > old_elements) { spider_alloc_calc_mem(spider_current_trx, - spider_open_pt_share, - (spider_open_pt_share.array.max_element - old_elements) * - spider_open_pt_share.array.size_of_element); + spider_open_wide_share, + (spider_open_wide_share.array.max_element - old_elements) * + spider_open_wide_share.array.size_of_element); } } - partition_share->use_count++; - pthread_mutex_unlock(&spider_pt_share_mutex); + wide_share->use_count++; + pthread_mutex_unlock(&spider_wide_share_mutex); - DBUG_PRINT("info",("spider partition_share=%p", partition_share)); - DBUG_RETURN(partition_share); + DBUG_PRINT("info",("spider wide_share=%p", wide_share)); + DBUG_RETURN(wide_share); error_hash_insert: + thr_lock_delete(&wide_share->lock); spider_free_mem_calc(spider_current_trx, - partition_share->pt_handler_hash_id, - partition_share->pt_handler_hash.array.max_element * - partition_share->pt_handler_hash.array.size_of_element); - my_hash_free(&partition_share->pt_handler_hash); + wide_share->pt_handler_hash_id, + wide_share->pt_handler_hash.array.max_element * + wide_share->pt_handler_hash.array.size_of_element); + my_hash_free(&wide_share->pt_handler_hash); error_init_pt_handler_hash: - pthread_mutex_destroy(&partition_share->pt_handler_mutex); + pthread_mutex_destroy(&wide_share->pt_handler_mutex); error_init_pt_handler_mutex: - pthread_mutex_destroy(&partition_share->crd_mutex); + pthread_mutex_destroy(&wide_share->crd_mutex); error_init_crd_mutex: - pthread_mutex_destroy(&partition_share->sts_mutex); + pthread_mutex_destroy(&wide_share->sts_mutex); error_init_sts_mutex: - spider_free(spider_current_trx, partition_share, MYF(0)); + spider_free(spider_current_trx, wide_share, MYF(0)); error_alloc_share: - pthread_mutex_unlock(&spider_pt_share_mutex); + pthread_mutex_unlock(&spider_wide_share_mutex); DBUG_RETURN(NULL); } -int spider_free_pt_share( - SPIDER_PARTITION_SHARE *partition_share +int spider_free_wide_share( + SPIDER_WIDE_SHARE *wide_share ) { - DBUG_ENTER("spider_free_pt_share"); - pthread_mutex_lock(&spider_pt_share_mutex); - if (!--partition_share->use_count) + DBUG_ENTER("spider_free_wide_share"); + pthread_mutex_lock(&spider_wide_share_mutex); + if (!--wide_share->use_count) { + thr_lock_delete(&wide_share->lock); #ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_open_pt_share, - partition_share->table_path_hash_value, (uchar*) partition_share); + my_hash_delete_with_hash_value(&spider_open_wide_share, + wide_share->table_path_hash_value, (uchar*) wide_share); #else - my_hash_delete(&spider_open_pt_share, (uchar*) partition_share); + my_hash_delete(&spider_open_wide_share, (uchar*) wide_share); #endif spider_free_mem_calc(spider_current_trx, - partition_share->pt_handler_hash_id, - partition_share->pt_handler_hash.array.max_element * - partition_share->pt_handler_hash.array.size_of_element); - my_hash_free(&partition_share->pt_handler_hash); - pthread_mutex_destroy(&partition_share->pt_handler_mutex); - pthread_mutex_destroy(&partition_share->crd_mutex); - pthread_mutex_destroy(&partition_share->sts_mutex); - spider_free(spider_current_trx, partition_share, MYF(0)); - } - pthread_mutex_unlock(&spider_pt_share_mutex); + wide_share->pt_handler_hash_id, + wide_share->pt_handler_hash.array.max_element * + wide_share->pt_handler_hash.array.size_of_element); + my_hash_free(&wide_share->pt_handler_hash); + pthread_mutex_destroy(&wide_share->pt_handler_mutex); + pthread_mutex_destroy(&wide_share->crd_mutex); + pthread_mutex_destroy(&wide_share->sts_mutex); + spider_free(spider_current_trx, wide_share, MYF(0)); + } + pthread_mutex_unlock(&spider_wide_share_mutex); DBUG_RETURN(0); } -void spider_copy_sts_to_pt_share( - SPIDER_PARTITION_SHARE *partition_share, +void spider_copy_sts_to_wide_share( + SPIDER_WIDE_SHARE *wide_share, SPIDER_SHARE *share ) { - DBUG_ENTER("spider_copy_sts_to_pt_share"); - memcpy(&partition_share->data_file_length, &share->data_file_length, + DBUG_ENTER("spider_copy_sts_to_wide_share"); + memcpy(&wide_share->data_file_length, &share->data_file_length, sizeof(ulonglong) * 4 + sizeof(ha_rows) + sizeof(ulong) + sizeof(time_t) * 3); -/* - partition_share->data_file_length = share->data_file_length; - partition_share->max_data_file_length = share->max_data_file_length; - partition_share->index_file_length = share->index_file_length; - partition_share->auto_increment_value = - share->lgtm_tblhnd_share->auto_increment_value; - partition_share->records = share->records; - partition_share->mean_rec_length = share->mean_rec_length; - partition_share->check_time = share->check_time; - partition_share->create_time = share->create_time; - partition_share->update_time = share->update_time; -*/ DBUG_VOID_RETURN; } void spider_copy_sts_to_share( SPIDER_SHARE *share, - SPIDER_PARTITION_SHARE *partition_share + SPIDER_WIDE_SHARE *wide_share ) { - DBUG_ENTER("spider_copy_sts_to_share"); - memcpy(&share->data_file_length, &partition_share->data_file_length, + DBUG_ENTER("spider_copy_sts_from_wide_share"); + memcpy(&share->data_file_length, &wide_share->data_file_length, sizeof(ulonglong) * 4 + sizeof(ha_rows) + sizeof(ulong) + sizeof(time_t) * 3); -/* - share->data_file_length = partition_share->data_file_length; - share->max_data_file_length = partition_share->max_data_file_length; - share->index_file_length = partition_share->index_file_length; - share->lgtm_tblhnd_share->auto_increment_value = - partition_share->auto_increment_value; - DBUG_PRINT("info",("spider auto_increment_value=%llu", - share->lgtm_tblhnd_share->auto_increment_value)); - share->records = partition_share->records; - share->mean_rec_length = partition_share->mean_rec_length; - share->check_time = partition_share->check_time; - share->create_time = partition_share->create_time; - share->update_time = partition_share->update_time; -*/ DBUG_VOID_RETURN; } -void spider_copy_crd_to_pt_share( - SPIDER_PARTITION_SHARE *partition_share, +void spider_copy_crd_to_wide_share( + SPIDER_WIDE_SHARE *wide_share, SPIDER_SHARE *share, int fields ) { - DBUG_ENTER("spider_copy_crd_to_pt_share"); - memcpy(partition_share->cardinality, share->cardinality, + DBUG_ENTER("spider_copy_crd_to_wide_share"); + memcpy(wide_share->cardinality, share->cardinality, sizeof(longlong) * fields); DBUG_VOID_RETURN; } void spider_copy_crd_to_share( SPIDER_SHARE *share, - SPIDER_PARTITION_SHARE *partition_share, + SPIDER_WIDE_SHARE *wide_share, int fields ) { - DBUG_ENTER("spider_copy_crd_to_share"); - memcpy(share->cardinality, partition_share->cardinality, + DBUG_ENTER("spider_copy_crd_from_wide_share"); + memcpy(share->cardinality, wide_share->cardinality, sizeof(longlong) * fields); DBUG_VOID_RETURN; } -#endif int spider_open_all_tables( SPIDER_TRX *trx, @@ -6391,7 +6362,7 @@ int spider_open_all_tables( free_root(&mem_root, MYF(0)); DBUG_RETURN(HA_ERR_OUT_OF_MEM); } - spider->lock_type = TL_READ_NO_INSERT; + spider->wide_handler->lock_type = TL_READ_NO_INSERT; if (!(share = (SPIDER_SHARE *) spider_bulk_malloc(spider_current_trx, 52, MYF(MY_WME | MY_ZEROFILL), @@ -6426,7 +6397,7 @@ int spider_open_all_tables( memcpy(longlong_info, &tmp_longlong, sizeof(longlong) * SPIDER_TMP_SHARE_LONGLONG_COUNT); spider->share = share; - spider->trx = trx; + spider->wide_handler->trx = trx; spider->conns = conns; spider->need_mons = need_mon; spider->conn_link_idx[0] = 0; @@ -6775,10 +6746,10 @@ int spider_db_done( my_hash_free(&spider_lgtm_tblhnd_share_hash); #ifdef WITH_PARTITION_STORAGE_ENGINE spider_free_mem_calc(spider_current_trx, - spider_open_pt_share_id, - spider_open_pt_share.array.max_element * - spider_open_pt_share.array.size_of_element); - my_hash_free(&spider_open_pt_share); + spider_open_wide_share_id, + spider_open_wide_share.array.max_element * + spider_open_wide_share.array.size_of_element); + my_hash_free(&spider_open_wide_share); #endif pthread_mutex_lock(&spider_init_error_tbl_mutex); while ((spider_init_error_table = (SPIDER_INIT_ERROR_TABLE*) @@ -6816,7 +6787,7 @@ int spider_db_done( pthread_mutex_destroy(&spider_conn_mutex); pthread_mutex_destroy(&spider_lgtm_tblhnd_share_mutex); #ifdef WITH_PARTITION_STORAGE_ENGINE - pthread_mutex_destroy(&spider_pt_share_mutex); + pthread_mutex_destroy(&spider_wide_share_mutex); #endif pthread_mutex_destroy(&spider_init_error_tbl_mutex); pthread_mutex_destroy(&spider_conn_id_mutex); @@ -7054,14 +7025,14 @@ int spider_db_init( } #ifdef WITH_PARTITION_STORAGE_ENGINE #if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_pt_share_mutex, MY_MUTEX_INIT_FAST)) + if (pthread_mutex_init(&spider_wide_share_mutex, MY_MUTEX_INIT_FAST)) #else - if (mysql_mutex_init(spd_key_mutex_pt_share, - &spider_pt_share_mutex, MY_MUTEX_INIT_FAST)) + if (mysql_mutex_init(spd_key_mutex_wide_share, + &spider_wide_share_mutex, MY_MUTEX_INIT_FAST)) #endif { error_num = HA_ERR_OUT_OF_MEM; - goto error_pt_share_mutex_init; + goto error_wide_share_mutex_init; } #endif #if MYSQL_VERSION_ID < 50500 @@ -7174,17 +7145,17 @@ int spider_db_init( spider_init_error_tables.array.size_of_element); #ifdef WITH_PARTITION_STORAGE_ENGINE if( - my_hash_init(&spider_open_pt_share, spd_charset_utf8_bin, 32, 0, 0, - (my_hash_get_key) spider_pt_share_get_key, 0, 0) + my_hash_init(&spider_open_wide_share, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_wide_share_get_key, 0, 0) ) { error_num = HA_ERR_OUT_OF_MEM; - goto error_open_pt_share_hash_init; + goto error_open_wide_share_hash_init; } - spider_alloc_calc_mem_init(spider_open_pt_share, 145); + spider_alloc_calc_mem_init(spider_open_wide_share, 145); spider_alloc_calc_mem(NULL, - spider_open_pt_share, - spider_open_pt_share.array.max_element * - spider_open_pt_share.array.size_of_element); + spider_open_wide_share, + spider_open_wide_share.array.max_element * + spider_open_wide_share.array.size_of_element); #endif if( my_hash_init(&spider_lgtm_tblhnd_share_hash, spd_charset_utf8_bin, @@ -7480,11 +7451,11 @@ error_open_connections_hash_init: error_lgtm_tblhnd_share_hash_init: #ifdef WITH_PARTITION_STORAGE_ENGINE spider_free_mem_calc(NULL, - spider_open_pt_share_id, - spider_open_pt_share.array.max_element * - spider_open_pt_share.array.size_of_element); - my_hash_free(&spider_open_pt_share); -error_open_pt_share_hash_init: + spider_open_wide_share_id, + spider_open_wide_share.array.max_element * + spider_open_wide_share.array.size_of_element); + my_hash_free(&spider_open_wide_share); +error_open_wide_share_hash_init: #endif spider_free_mem_calc(NULL, spider_init_error_tables_id, @@ -7517,8 +7488,8 @@ error_conn_mutex_init: pthread_mutex_destroy(&spider_lgtm_tblhnd_share_mutex); error_lgtm_tblhnd_share_mutex_init: #ifdef WITH_PARTITION_STORAGE_ENGINE - pthread_mutex_destroy(&spider_pt_share_mutex); -error_pt_share_mutex_init: + pthread_mutex_destroy(&spider_wide_share_mutex); +error_wide_share_mutex_init: #endif pthread_mutex_destroy(&spider_init_error_tbl_mutex); error_init_error_tbl_mutex_init: @@ -7698,26 +7669,26 @@ int spider_get_sts( get_type = 1; #ifdef WITH_PARTITION_STORAGE_ENGINE } else if ( - !share->partition_share->sts_init + !share->wide_share->sts_init ) { - pthread_mutex_lock(&share->partition_share->sts_mutex); - if (!share->partition_share->sts_init) + pthread_mutex_lock(&share->wide_share->sts_mutex); + if (!share->wide_share->sts_init) { /* get after mutex_lock */ get_type = 2; } else { - pthread_mutex_unlock(&share->partition_share->sts_mutex); + pthread_mutex_unlock(&share->wide_share->sts_mutex); /* copy */ get_type = 0; } } else if ( - difftime(share->sts_get_time, share->partition_share->sts_get_time) < + difftime(share->sts_get_time, share->wide_share->sts_get_time) < sts_interval ) { /* copy */ get_type = 0; } else if ( - !pthread_mutex_trylock(&share->partition_share->sts_mutex) + !pthread_mutex_trylock(&share->wide_share->sts_mutex) ) { /* get after mutex_trylock */ get_type = 3; @@ -7756,7 +7727,7 @@ int spider_get_sts( { #ifdef WITH_PARTITION_STORAGE_ENGINE if (get_type == 0) - spider_copy_sts_to_share(share, share->partition_share); + spider_copy_sts_to_share(share, share->wide_share); else { #endif error_num = spider_db_show_table_status(spider, link_idx, sts_mode, flag); @@ -7766,7 +7737,7 @@ int spider_get_sts( } #ifdef WITH_PARTITION_STORAGE_ENGINE if (get_type >= 2) - pthread_mutex_unlock(&share->partition_share->sts_mutex); + pthread_mutex_unlock(&share->wide_share->sts_mutex); #endif if (error_num) { @@ -7774,7 +7745,7 @@ int spider_get_sts( SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share = spider->partition_handler_share; if ( - !share->partition_share->sts_init && + !share->wide_share->sts_init && sts_sync >= sts_sync_level && get_type > 1 && partition_handler_share && @@ -7787,9 +7758,9 @@ int spider_get_sts( double tmp_sts_interval; int tmp_sts_mode; int tmp_sts_sync; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; for (roop_count = 1; - roop_count < (int) partition_handler_share->use_count; + roop_count < (int) partition_handler_share->no_parts; roop_count++) { tmp_spider = @@ -7801,12 +7772,12 @@ int spider_get_sts( spider_get_sts(tmp_share, tmp_spider->search_link_idx, tmp_time, tmp_spider, tmp_sts_interval, tmp_sts_mode, tmp_sts_sync, 1, flag); - if (share->partition_share->sts_init) + if (share->wide_share->sts_init) { error_num = 0; thd->clear_error(); get_type = 0; - spider_copy_sts_to_share(share, share->partition_share); + spider_copy_sts_to_share(share, share->wide_share); break; } } @@ -7818,9 +7789,9 @@ int spider_get_sts( #ifdef WITH_PARTITION_STORAGE_ENGINE if (sts_sync >= sts_sync_level && get_type > 0) { - spider_copy_sts_to_pt_share(share->partition_share, share); - share->partition_share->sts_get_time = tmp_time; - share->partition_share->sts_init = TRUE; + spider_copy_sts_to_wide_share(share->wide_share, share); + share->wide_share->sts_get_time = tmp_time; + share->wide_share->sts_init = TRUE; } #endif share->sts_get_time = tmp_time; @@ -7855,26 +7826,26 @@ int spider_get_crd( get_type = 1; #ifdef WITH_PARTITION_STORAGE_ENGINE } else if ( - !share->partition_share->crd_init + !share->wide_share->crd_init ) { - pthread_mutex_lock(&share->partition_share->crd_mutex); - if (!share->partition_share->crd_init) + pthread_mutex_lock(&share->wide_share->crd_mutex); + if (!share->wide_share->crd_init) { /* get after mutex_lock */ get_type = 2; } else { - pthread_mutex_unlock(&share->partition_share->crd_mutex); + pthread_mutex_unlock(&share->wide_share->crd_mutex); /* copy */ get_type = 0; } } else if ( - difftime(share->crd_get_time, share->partition_share->crd_get_time) < + difftime(share->crd_get_time, share->wide_share->crd_get_time) < crd_interval ) { /* copy */ get_type = 0; } else if ( - !pthread_mutex_trylock(&share->partition_share->crd_mutex) + !pthread_mutex_trylock(&share->wide_share->crd_mutex) ) { /* get after mutex_trylock */ get_type = 3; @@ -7906,7 +7877,7 @@ int spider_get_crd( { #ifdef WITH_PARTITION_STORAGE_ENGINE if (get_type == 0) - spider_copy_crd_to_share(share, share->partition_share, + spider_copy_crd_to_share(share, share->wide_share, table->s->fields); else { #endif @@ -7917,7 +7888,7 @@ int spider_get_crd( } #ifdef WITH_PARTITION_STORAGE_ENGINE if (get_type >= 2) - pthread_mutex_unlock(&share->partition_share->crd_mutex); + pthread_mutex_unlock(&share->wide_share->crd_mutex); #endif if (error_num) { @@ -7925,7 +7896,7 @@ int spider_get_crd( SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share = spider->partition_handler_share; if ( - !share->partition_share->crd_init && + !share->wide_share->crd_init && crd_sync >= crd_sync_level && get_type > 1 && partition_handler_share && @@ -7938,9 +7909,9 @@ int spider_get_crd( double tmp_crd_interval; int tmp_crd_mode; int tmp_crd_sync; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; for (roop_count = 1; - roop_count < (int) partition_handler_share->use_count; + roop_count < (int) partition_handler_share->no_parts; roop_count++) { tmp_spider = @@ -7952,12 +7923,12 @@ int spider_get_crd( spider_get_crd(tmp_share, tmp_spider->search_link_idx, tmp_time, tmp_spider, table, tmp_crd_interval, tmp_crd_mode, tmp_crd_sync, 1); - if (share->partition_share->crd_init) + if (share->wide_share->crd_init) { error_num = 0; thd->clear_error(); get_type = 0; - spider_copy_crd_to_share(share, share->partition_share, + spider_copy_crd_to_share(share, share->wide_share, table->s->fields); break; } @@ -7970,10 +7941,10 @@ int spider_get_crd( #ifdef WITH_PARTITION_STORAGE_ENGINE if (crd_sync >= crd_sync_level && get_type > 0) { - spider_copy_crd_to_pt_share(share->partition_share, share, + spider_copy_crd_to_wide_share(share->wide_share, share, table->s->fields); - share->partition_share->crd_get_time = tmp_time; - share->partition_share->crd_init = TRUE; + share->wide_share->crd_get_time = tmp_time; + share->wide_share->crd_init = TRUE; } #endif share->crd_get_time = tmp_time; @@ -7986,14 +7957,14 @@ void spider_set_result_list_param( ) { SPIDER_RESULT_LIST *result_list = &spider->result_list; SPIDER_SHARE *share = spider->share; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; DBUG_ENTER("spider_set_result_list_param"); result_list->internal_offset = spider_param_internal_offset(thd, share->internal_offset); result_list->internal_limit = #ifdef INFO_KIND_FORCE_LIMIT_BEGIN - spider->info_limit < 9223372036854775807LL ? - spider->info_limit : + spider->wide_handler->info_limit < 9223372036854775807LL ? + spider->wide_handler->info_limit : #endif spider_param_internal_limit(thd, share->internal_limit); result_list->split_read = spider_split_read_param(spider); @@ -8539,7 +8510,7 @@ longlong spider_split_read_param( ) { SPIDER_SHARE *share = spider->share; SPIDER_RESULT_LIST *result_list = &spider->result_list; - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; st_select_lex *select_lex; longlong select_limit; longlong offset_limit; @@ -8548,10 +8519,11 @@ longlong spider_split_read_param( DBUG_ENTER("spider_split_read_param"); result_list->set_split_read_count = 1; #ifdef INFO_KIND_FORCE_LIMIT_BEGIN - if (spider->info_limit < 9223372036854775807LL) + if (spider->wide_handler->info_limit < 9223372036854775807LL) { - DBUG_PRINT("info",("spider info_limit=%lld", spider->info_limit)); - longlong info_limit = spider->info_limit; + DBUG_PRINT("info",("spider info_limit=%lld", + spider->wide_handler->info_limit)); + longlong info_limit = spider->wide_handler->info_limit; result_list->split_read_base = info_limit; result_list->semi_split_read = 0; result_list->first_read = info_limit; @@ -8571,7 +8543,8 @@ longlong spider_split_read_param( { int bulk_update_mode = spider_param_bulk_update_mode(thd, share->bulk_update_mode); - DBUG_PRINT("info",("spider sql_command=%u", spider->sql_command)); + DBUG_PRINT("info",("spider sql_command=%u", + spider->wide_handler->sql_command)); DBUG_PRINT("info",("spider bulk_update_mode=%d", bulk_update_mode)); DBUG_PRINT("info",("spider support_bulk_update_sql=%s", spider->support_bulk_update_sql() ? "TRUE" : "FALSE")); @@ -8579,32 +8552,32 @@ longlong spider_split_read_param( bool inserting = ( #ifdef HS_HAS_SQLCOM - spider->sql_command == SQLCOM_HS_INSERT || + spider->wide_handler->sql_command == SQLCOM_HS_INSERT || #endif - spider->sql_command == SQLCOM_INSERT || - spider->sql_command == SQLCOM_INSERT_SELECT + spider->wide_handler->sql_command == SQLCOM_INSERT || + spider->wide_handler->sql_command == SQLCOM_INSERT_SELECT ); #endif bool updating = ( #ifdef HS_HAS_SQLCOM - spider->sql_command == SQLCOM_HS_UPDATE || + spider->wide_handler->sql_command == SQLCOM_HS_UPDATE || #endif - spider->sql_command == SQLCOM_UPDATE || - spider->sql_command == SQLCOM_UPDATE_MULTI + spider->wide_handler->sql_command == SQLCOM_UPDATE || + spider->wide_handler->sql_command == SQLCOM_UPDATE_MULTI ); bool deleting = ( #ifdef HS_HAS_SQLCOM - spider->sql_command == SQLCOM_HS_DELETE || + spider->wide_handler->sql_command == SQLCOM_HS_DELETE || #endif - spider->sql_command == SQLCOM_DELETE || - spider->sql_command == SQLCOM_DELETE_MULTI + spider->wide_handler->sql_command == SQLCOM_DELETE || + spider->wide_handler->sql_command == SQLCOM_DELETE_MULTI ); bool replacing = ( - spider->sql_command == SQLCOM_REPLACE || - spider->sql_command == SQLCOM_REPLACE_SELECT + spider->wide_handler->sql_command == SQLCOM_REPLACE || + spider->wide_handler->sql_command == SQLCOM_REPLACE_SELECT ); DBUG_PRINT("info",("spider updating=%s", updating ? "TRUE" : "FALSE")); DBUG_PRINT("info",("spider deleting=%s", deleting ? "TRUE" : "FALSE")); @@ -8790,7 +8763,7 @@ void spider_next_split_read_param( bool spider_check_direct_order_limit( ha_spider *spider ) { - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; SPIDER_SHARE *share = spider->share; st_select_lex *select_lex; longlong select_limit; @@ -8803,7 +8776,7 @@ bool spider_check_direct_order_limit( spider->use_index_merge = TRUE; } DBUG_PRINT("info",("spider SQLCOM_HA_READ=%s", - (spider->sql_command == SQLCOM_HA_READ) ? "TRUE" : "FALSE")); + (spider->wide_handler->sql_command == SQLCOM_HA_READ) ? "TRUE" : "FALSE")); DBUG_PRINT("info",("spider sql_kinds with SPIDER_SQL_KIND_HANDLER=%s", (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) ? "TRUE" : "FALSE")); DBUG_PRINT("info",("spider use_index_merge=%s", @@ -8815,7 +8788,7 @@ bool spider_check_direct_order_limit( spider->is_bulk_access_clone ? "TRUE" : "FALSE")); #endif if ( - spider->sql_command != SQLCOM_HA_READ && + spider->wide_handler->sql_command != SQLCOM_HA_READ && !spider->use_index_merge && #ifdef HA_CAN_BULK_ACCESS (!spider->is_clone || spider->is_bulk_access_clone) @@ -8973,7 +8946,7 @@ bool spider_check_direct_order_limit( DBUG_PRINT("info",("spider TRUE")); spider->result_list.internal_limit = select_limit + offset_limit; spider->result_list.split_read = select_limit + offset_limit; - spider->trx->direct_order_limit_count++; + spider->wide_handler->trx->direct_order_limit_count++; DBUG_RETURN(TRUE); } } @@ -9077,7 +9050,7 @@ int spider_set_direct_limit_offset( ha_spider *spider ) { #ifndef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON - THD *thd = spider->trx->thd; + THD *thd = spider->wide_handler->trx->thd; #endif st_select_lex *select_lex; longlong select_limit; @@ -9089,10 +9062,11 @@ int spider_set_direct_limit_offset( DBUG_RETURN(TRUE); if ( - spider->pt_handler_share_creator && - spider->pt_handler_share_creator != spider + spider->partition_handler_share && + !spider->pt_handler_share_owner ) { - if (spider->pt_handler_share_creator->result_list.direct_limit_offset == TRUE) + if (spider->partition_handler_share->owner-> + result_list.direct_limit_offset == TRUE) { spider->result_list.direct_limit_offset = TRUE; DBUG_RETURN(TRUE); @@ -9102,7 +9076,7 @@ int spider_set_direct_limit_offset( } if ( - spider->sql_command != SQLCOM_SELECT || + spider->wide_handler->sql_command != SQLCOM_SELECT || #ifdef HANDLER_HAS_DIRECT_AGGREGATE spider->result_list.direct_aggregate || #endif @@ -9145,7 +9119,8 @@ int spider_set_direct_limit_offset( OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || #endif #endif - spider->condition // conditions is null may be no where condition in rand_init + // conditions is null may be no where condition in rand_init + spider->wide_handler->condition ) DBUG_RETURN(FALSE); @@ -9698,6 +9673,7 @@ int spider_create_spider_object_for_share( char **hs_w_conn_keys; #endif spider_db_handler **dbton_hdl; + SPIDER_WIDE_HANDLER *wide_handler; DBUG_ENTER("spider_create_spider_object_for_share"); DBUG_PRINT("info",("spider trx=%p", trx)); DBUG_PRINT("info",("spider share=%p", share)); @@ -9727,6 +9703,7 @@ int spider_create_spider_object_for_share( &hs_r_conn_keys, (sizeof(char *) * share->link_count), &hs_w_conn_keys, (sizeof(char *) * share->link_count), &dbton_hdl, (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE), + &wide_handler, sizeof(SPIDER_WIDE_HANDLER), NullS)) ) #else @@ -9738,6 +9715,7 @@ int spider_create_spider_object_for_share( &conn_can_fo, (sizeof(uchar) * share->link_bitmap_size), &conn_keys, (sizeof(char *) * share->link_count), &dbton_hdl, (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE), + &wide_handler, sizeof(SPIDER_WIDE_HANDLER), NullS)) ) #endif @@ -9746,7 +9724,8 @@ int spider_create_spider_object_for_share( goto error_need_mons_alloc; } DBUG_PRINT("info",("spider need_mons=%p", need_mons)); - (*spider)->trx = trx; + (*spider)->wide_handler = wide_handler; + wide_handler->trx = trx; (*spider)->change_table_ptr(&share->table, share->table_share); (*spider)->share = share; (*spider)->conns = conns; @@ -10077,7 +10056,7 @@ void *spider_table_bg_sts_action( conns = spider->conns; if (spider->search_link_idx < 0) { - spider->trx = trx; + spider->wide_handler->trx = trx; spider_trx_set_link_idx_for_all(spider); spider->search_link_idx = spider_conn_first_link_idx(thd, share->link_statuses, share->access_balances, spider->conn_link_idx, @@ -10230,7 +10209,7 @@ void *spider_table_bg_crd_action( conns = spider->conns; if (spider->search_link_idx < 0) { - spider->trx = trx; + spider->wide_handler->trx = trx; spider_trx_set_link_idx_for_all(spider); spider->search_link_idx = spider_conn_first_link_idx(thd, share->link_statuses, share->access_balances, spider->conn_link_idx, diff --git a/storage/spider/spd_table.h b/storage/spider/spd_table.h index 647b03953f3..e409b6731ee 100644 --- a/storage/spider/spd_table.h +++ b/storage/spider/spd_table.h @@ -224,13 +224,13 @@ uchar *spider_tbl_get_key( my_bool not_used __attribute__ ((unused)) ); -#ifdef WITH_PARTITION_STORAGE_ENGINE -uchar *spider_pt_share_get_key( - SPIDER_PARTITION_SHARE *share, +uchar *spider_wide_share_get_key( + SPIDER_WIDE_SHARE *share, size_t *length, my_bool not_used __attribute__ ((unused)) ); +#ifdef WITH_PARTITION_STORAGE_ENGINE uchar *spider_pt_handler_share_get_key( SPIDER_PARTITION_HANDLER_SHARE *share, size_t *length, @@ -420,39 +420,37 @@ void spider_update_link_status_for_share( long link_status ); -#ifdef WITH_PARTITION_STORAGE_ENGINE -SPIDER_PARTITION_SHARE *spider_get_pt_share( +SPIDER_WIDE_SHARE *spider_get_wide_share( SPIDER_SHARE *share, TABLE_SHARE *table_share, int *error_num ); -int spider_free_pt_share( - SPIDER_PARTITION_SHARE *partition_share +int spider_free_wide_share( + SPIDER_WIDE_SHARE *wide_share ); -void spider_copy_sts_to_pt_share( - SPIDER_PARTITION_SHARE *partition_share, +void spider_copy_sts_to_wide_share( + SPIDER_WIDE_SHARE *wide_share, SPIDER_SHARE *share ); void spider_copy_sts_to_share( SPIDER_SHARE *share, - SPIDER_PARTITION_SHARE *partition_share + SPIDER_WIDE_SHARE *wide_share ); -void spider_copy_crd_to_pt_share( - SPIDER_PARTITION_SHARE *partition_share, +void spider_copy_crd_to_wide_share( + SPIDER_WIDE_SHARE *wide_share, SPIDER_SHARE *share, int fields ); void spider_copy_crd_to_share( SPIDER_SHARE *share, - SPIDER_PARTITION_SHARE *partition_share, + SPIDER_WIDE_SHARE *wide_share, int fields ); -#endif int spider_open_all_tables( SPIDER_TRX *trx, diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index a1f9bde6a2e..c8c38c43784 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -247,6 +247,7 @@ int spider_trx_another_lock_tables( SPIDER_CONN *conn; ha_spider tmp_spider; SPIDER_SHARE tmp_share; + SPIDER_WIDE_HANDLER tmp_wide_handler; char sql_buf[MAX_FIELD_WIDTH]; spider_string sql_str(sql_buf, sizeof(sql_buf), system_charset_info); DBUG_ENTER("spider_trx_another_lock_tables"); @@ -255,13 +256,11 @@ int spider_trx_another_lock_tables( sql_str.length(0); memset((void*)&tmp_spider, 0, sizeof(ha_spider)); memset((void*)&tmp_share, 0, sizeof(SPIDER_SHARE)); + memset((void*)&tmp_wide_handler, 0, sizeof(SPIDER_WIDE_HANDLER)); tmp_spider.share = &tmp_share; - tmp_spider.trx = trx; + tmp_spider.wide_handler = &tmp_wide_handler; + tmp_wide_handler.trx = trx; tmp_share.access_charset = system_charset_info; -/* - if ((error_num = spider_db_append_set_names(&tmp_share))) - DBUG_RETURN(error_num); -*/ tmp_spider.conns = &conn; tmp_spider.result_list.sqls = &sql_str; tmp_spider.need_mons = &need_mon; @@ -273,17 +272,11 @@ int spider_trx_another_lock_tables( SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; if (error_num) { -/* - spider_db_free_set_names(&tmp_share); -*/ DBUG_RETURN(error_num); } } roop_count++; } -/* - spider_db_free_set_names(&tmp_share); -*/ DBUG_RETURN(0); } @@ -387,10 +380,13 @@ int spider_trx_all_start_trx( THD *thd = trx->thd; SPIDER_CONN *conn; ha_spider tmp_spider; + SPIDER_WIDE_HANDLER tmp_wide_handler; DBUG_ENTER("spider_trx_all_start_trx"); SPIDER_BACKUP_DASTATUS; memset((void*)&tmp_spider, 0, sizeof(ha_spider)); - tmp_spider.trx = trx; + memset(&tmp_wide_handler, 0, sizeof(SPIDER_WIDE_HANDLER)); + tmp_spider.wide_handler = &tmp_wide_handler; + tmp_wide_handler.trx = trx; tmp_spider.need_mons = &need_mon; while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash, roop_count))) @@ -398,7 +394,8 @@ int spider_trx_all_start_trx( if ( (spider_param_sync_trx_isolation(trx->thd) && (error_num = spider_check_and_set_trx_isolation(conn, &need_mon))) || - (error_num = spider_internal_start_trx(&tmp_spider, conn, 0)) + (error_num = spider_internal_start_trx_for_connection(&tmp_spider, + conn, 0)) ) { SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; if (error_num) @@ -418,6 +415,7 @@ int spider_trx_all_flush_logs( SPIDER_CONN *conn; ha_spider tmp_spider; SPIDER_SHARE tmp_share; + SPIDER_WIDE_HANDLER tmp_wide_handler; long tmp_link_statuses = SPIDER_LINK_STATUS_OK; uint conn_link_idx = 0; long net_read_timeout = 600; @@ -425,6 +423,7 @@ int spider_trx_all_flush_logs( DBUG_ENTER("spider_trx_all_flush_logs"); SPIDER_BACKUP_DASTATUS; memset((void*)&tmp_spider, 0, sizeof(ha_spider)); + memset(&tmp_wide_handler, 0, sizeof(SPIDER_WIDE_HANDLER)); tmp_share.link_count = 1; tmp_share.all_link_count = 1; tmp_share.link_statuses = &tmp_link_statuses; @@ -437,7 +436,8 @@ int spider_trx_all_flush_logs( tmp_spider.conns = &conn; tmp_spider.need_mons = &need_mon; tmp_spider.conn_link_idx = &conn_link_idx; - tmp_spider.trx = trx; + tmp_spider.wide_handler = &tmp_wide_handler; + tmp_wide_handler.trx = trx; while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash, roop_count))) { @@ -1191,6 +1191,7 @@ SPIDER_TRX *spider_get_trx( int roop_count = 0, roop_count2; SPIDER_TRX *trx; SPIDER_SHARE *tmp_share; + SPIDER_WIDE_HANDLER *tmp_wide_handler; pthread_mutex_t *udf_table_mutexes; DBUG_ENTER("spider_get_trx"); @@ -1203,6 +1204,7 @@ SPIDER_TRX *spider_get_trx( spider_bulk_malloc(NULL, 56, MYF(MY_WME | MY_ZEROFILL), &trx, sizeof(*trx), &tmp_share, sizeof(SPIDER_SHARE), + &tmp_wide_handler, sizeof(SPIDER_WIDE_HANDLER), &udf_table_mutexes, sizeof(pthread_mutex_t) * spider_param_udf_table_lock_mutex_count(), NullS)) @@ -1374,7 +1376,8 @@ SPIDER_TRX *spider_get_trx( } trx->tmp_spider->need_mons = &trx->tmp_need_mon; trx->tmp_spider->share = trx->tmp_share; - trx->tmp_spider->trx = trx; + trx->tmp_spider->wide_handler = tmp_wide_handler; + tmp_wide_handler->trx = trx; trx->tmp_spider->dbton_handler = trx->tmp_dbton_handler; if (!(trx->tmp_spider->result_list.sqls = new spider_string[trx->tmp_share->link_count])) @@ -1850,27 +1853,14 @@ int spider_start_internal_consistent_snapshot( } int spider_internal_start_trx( - ha_spider *spider, - SPIDER_CONN *conn, - int link_idx + ha_spider *spider ) { int error_num; - SPIDER_TRX *trx = spider->trx; + SPIDER_TRX *trx = spider->wide_handler->trx; THD *thd = trx->thd; - bool sync_autocommit = spider_param_sync_autocommit(thd); - double ping_interval_at_trx_start = - spider_param_ping_interval_at_trx_start(thd); bool xa_lock = FALSE; - time_t tmp_time = (time_t) time((time_t*) 0); DBUG_ENTER("spider_internal_start_trx"); - if ( - conn->server_lost || - difftime(tmp_time, conn->ping_time) >= ping_interval_at_trx_start - ) { - spider_conn_queue_ping(spider, conn, link_idx); - } - conn->disable_reconnect = TRUE; if (!trx->trx_start) { if (!trx->trx_consistent_snapshot) @@ -1881,16 +1871,7 @@ int spider_internal_start_trx( trx->internal_xa_snapshot = spider_param_internal_xa_snapshot(thd); } } - if ( - (error_num = spider_check_and_set_sql_log_off(thd, conn, - &spider->need_mons[link_idx])) || - (error_num = spider_check_and_set_wait_timeout(thd, conn, - &spider->need_mons[link_idx])) || - (sync_autocommit && - (error_num = spider_check_and_set_autocommit(thd, conn, - &spider->need_mons[link_idx]))) - ) - goto error; + spider->wide_handler->consistent_snapshot = FALSE; if (trx->trx_consistent_snapshot) { if (trx->internal_xa && trx->internal_xa_snapshot < 2) @@ -1901,9 +1882,7 @@ int spider_internal_start_trx( goto error; } else if (!trx->internal_xa || trx->internal_xa_snapshot == 2) { - if ((error_num = spider_start_internal_consistent_snapshot(trx, conn, - &spider->need_mons[link_idx]))) - goto error; + spider->wide_handler->consistent_snapshot = TRUE; } } DBUG_PRINT("info",("spider trx->trx_start= %s", @@ -1922,7 +1901,7 @@ int spider_internal_start_trx( !trx->trx_xa && trx->internal_xa && (!trx->trx_consistent_snapshot || trx->internal_xa_snapshot == 3) && - spider->sql_command != SQLCOM_LOCK_TABLES + spider->wide_handler->sql_command != SQLCOM_LOCK_TABLES ) { trx->trx_xa = TRUE; trx->xid.formatID = 1; @@ -1975,6 +1954,51 @@ int spider_internal_start_trx( trx->updated_in_this_trx = FALSE; DBUG_PRINT("info",("spider trx->updated_in_this_trx=FALSE")); } + DBUG_RETURN(0); + +error: + if (xa_lock) + spider_xa_unlock(&trx->internal_xid_state); + DBUG_RETURN(error_num); +} + +int spider_internal_start_trx_for_connection( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_TRX *trx = spider->wide_handler->trx; + THD *thd = trx->thd; + bool sync_autocommit = spider_param_sync_autocommit(thd); + double ping_interval_at_trx_start = + spider_param_ping_interval_at_trx_start(thd); + time_t tmp_time = (time_t) time((time_t*) 0); + DBUG_ENTER("spider_internal_start_trx_for_connection"); + if ( + conn->server_lost || + difftime(tmp_time, conn->ping_time) >= ping_interval_at_trx_start + ) { + spider_conn_queue_ping(spider, conn, link_idx); + } + conn->disable_reconnect = TRUE; + if ( + (error_num = spider_check_and_set_sql_log_off(thd, conn, + &spider->need_mons[link_idx])) || + (error_num = spider_check_and_set_wait_timeout(thd, conn, + &spider->need_mons[link_idx])) || + (sync_autocommit && + (error_num = spider_check_and_set_autocommit(thd, conn, + &spider->need_mons[link_idx]))) + ) + goto error; + + if (spider->wide_handler->consistent_snapshot) + { + if ((error_num = spider_start_internal_consistent_snapshot(trx, conn, + &spider->need_mons[link_idx]))) + goto error; + } DBUG_PRINT("info",("spider sync_autocommit = %d", sync_autocommit)); DBUG_PRINT("info",("spider conn->semi_trx_chk = %d", conn->semi_trx_chk)); @@ -2040,8 +2064,6 @@ int spider_internal_start_trx( DBUG_RETURN(0); error: - if (xa_lock) - spider_xa_unlock(&trx->internal_xid_state); DBUG_RETURN(error_num); } @@ -3722,11 +3744,11 @@ int spider_check_trx_and_get_conn( DBUG_PRINT("info",("spider get trx error")); DBUG_RETURN(error_num); } - spider->trx = trx; + spider->wide_handler->trx = trx; spider->set_error_mode(); if ( - spider->sql_command != SQLCOM_DROP_TABLE && - spider->sql_command != SQLCOM_ALTER_TABLE + spider->wide_handler->sql_command != SQLCOM_DROP_TABLE && + spider->wide_handler->sql_command != SQLCOM_ALTER_TABLE ) { SPIDER_TRX_HA *trx_ha = spider_check_trx_ha(trx, spider); if (!trx_ha || trx_ha->wait_for_reusing) @@ -3782,9 +3804,9 @@ int spider_check_trx_and_get_conn( SPIDER_LINK_STATUS_NG ) { DBUG_PRINT("info",(first_byte != *spider->conn_keys[0] ? - "spider change conn type" : trx != spider->trx ? "spider change thd" : - "spider next trx")); - spider->trx = trx; + "spider change conn type" : trx != spider->wide_handler->trx ? + "spider change thd" : "spider next trx")); + spider->wide_handler->trx = trx; spider->trx_conn_adjustment = trx->trx_conn_adjustment; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) if (use_conn_kind) diff --git a/storage/spider/spd_trx.h b/storage/spider/spd_trx.h index 8e7822e12e1..0ecb429cc8d 100644 --- a/storage/spider/spd_trx.h +++ b/storage/spider/spd_trx.h @@ -119,6 +119,10 @@ int spider_start_internal_consistent_snapshot( ); int spider_internal_start_trx( + ha_spider *spider +); + +int spider_internal_start_trx_for_connection( ha_spider *spider, SPIDER_CONN *conn, int link_idx |