MDEV-19002 Spider performance optimization with partition

Change the following function for batch call instead of each partition
- store_lock
- external_lock
- start_stmt
- extra
- cond_push
- info_push
- top_table
This commit is contained in:
Kentoku SHIBA 2020-03-03 02:50:40 +09:00
parent 8e6e5acef1
commit e954d9de88
19 changed files with 2805 additions and 1943 deletions

View file

@ -473,6 +473,10 @@ public:
{
return m_file;
}
ha_partition *get_clone_source()
{
return m_is_clone_of;
}
virtual part_id_range *get_part_spec()
{
return &m_part_spec;

File diff suppressed because it is too large Load diff

View file

@ -52,9 +52,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)
@ -90,18 +88,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;
@ -116,10 +112,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;
@ -161,22 +155,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_action;
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;
@ -189,12 +172,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;
@ -216,14 +196,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
@ -232,11 +205,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
@ -283,10 +251,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,
@ -302,6 +273,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
@ -525,6 +500,7 @@ public:
#endif
const char *table_type() const;
ulonglong table_flags() const;
ulong table_flags_for_partition();
const char *index_type(
uint key_number
);
@ -869,6 +845,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
);
@ -1255,4 +1237,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
};

View file

@ -0,0 +1,16 @@
--connection master_1
set session spider_direct_dup_insert= @old_spider_direct_dup_insert;
--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP
--let $MASTER_1_COMMENT_2_1_2= $MASTER_1_COMMENT_2_1_2_BACKUP
--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP
--let $CHILD2_1_DROP_TABLES2= $CHILD2_1_DROP_TABLES2_BACKUP
--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP
--let $CHILD2_1_CREATE_TABLES2= $CHILD2_1_CREATE_TABLES2_BACKUP
--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings

View file

@ -0,0 +1,43 @@
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_init.inc
--enable_result_log
--enable_query_log
--enable_warnings
--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1
let $MASTER_1_COMMENT_2_1=
COMMENT='table "tbl_a", srv "s_2_1"';
--let $MASTER_1_COMMENT_2_1_2_BACKUP= $MASTER_1_COMMENT_2_1_2
let $MASTER_1_COMMENT_2_1_2=
COMMENT='table "tbl_b", srv "s_2_1"';
--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES
let $CHILD2_1_DROP_TABLES=
DROP TABLE IF EXISTS tbl_a;
--let $CHILD2_1_DROP_TABLES2_BACKUP= $CHILD2_1_DROP_TABLES2
let $CHILD2_1_DROP_TABLES2=
DROP TABLE IF EXISTS tbl_b;
--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
let $CHILD2_1_CREATE_TABLES=
CREATE TABLE tbl_a (
skey int NOT NULL,
dt date NOT NULL,
tm time NOT NULL,
KEY idx1 (skey,dt,tm)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
--let $CHILD2_1_CREATE_TABLES2_BACKUP= $CHILD2_1_CREATE_TABLES2
let $CHILD2_1_CREATE_TABLES2=
CREATE TABLE tbl_b (
pkey int NOT NULL,
dt datetime NOT NULL,
PRIMARY KEY (pkey),
KEY idx1 (dt)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES
let $CHILD2_1_SELECT_TABLES=
SELECT pkey, dt FROM tbl_b ORDER BY pkey;
let $CHILD2_1_SELECT_ARGUMENT1=
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
--connection master_1
set @old_spider_direct_dup_insert= @@spider_direct_dup_insert;
set session spider_direct_dup_insert= 1;

View file

@ -0,0 +1,3 @@
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf

View file

@ -0,0 +1,99 @@
--source ../include/insert_select_init.inc
--echo
--echo this test is for MDEV-16399
--echo
--echo drop and create databases
--connection master_1
--disable_warnings
CREATE DATABASE auto_test_local;
USE auto_test_local;
--connection child2_1
SET @old_log_output = @@global.log_output;
SET GLOBAL log_output = 'TABLE,FILE';
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
--enable_warnings
--echo
--echo create table and insert
--connection child2_1
--disable_query_log
echo CHILD2_1_CREATE_TABLES;
eval $CHILD2_1_CREATE_TABLES;
echo CHILD2_1_CREATE_TABLES2;
eval $CHILD2_1_CREATE_TABLES2;
--enable_query_log
TRUNCATE TABLE mysql.general_log;
--connection master_1
--disable_query_log
echo CREATE TABLE tbl_a (
skey int NOT NULL,
dt date NOT NULL,
tm time NOT NULL,
KEY idx1 (skey,dt,tm)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
eval CREATE TABLE tbl_a (
skey int NOT NULL,
dt date NOT NULL,
tm time NOT NULL,
KEY idx1 (skey,dt,tm)
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
echo CREATE TABLE tbl_b (
pkey int NOT NULL,
dt datetime NOT NULL,
PRIMARY KEY (pkey),
KEY idx1 (dt)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1_2;
eval CREATE TABLE tbl_b (
pkey int NOT NULL,
dt datetime NOT NULL,
PRIMARY KEY (pkey),
KEY idx1 (dt)
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1_2;
--enable_query_log
INSERT INTO tbl_a (skey, dt, tm) VALUES (0, '2012-01-01', '12:00:00'),(1, '2012-02-01', '12:00:00'),(2, '2012-03-01', '12:00:00'),(3, '2012-04-01', '12:00:00'),(4, '2012-05-01', '12:00:00'),(5, '2012-06-01', '12:00:00'),(6, '2012-07-01', '12:00:00'),(7, '2012-08-01', '12:00:00'),(8, '2012-09-01', '12:00:00'),(9, '2012-10-01', '12:00:00');
INSERT INTO tbl_a (skey, dt, tm) VALUES (0, '2013-01-01', '13:00:00'),(1, '2013-02-01', '13:00:00'),(2, '2013-03-01', '13:00:00'),(3, '2013-04-01', '13:00:00'),(4, '2013-05-01', '13:00:00'),(5, '2013-06-01', '13:00:00'),(6, '2013-07-01', '13:00:00'),(7, '2013-08-01', '13:00:00'),(8, '2013-09-01', '13:00:00'),(9, '2013-10-01', '13:00:00');
INSERT INTO tbl_a (skey, dt, tm) VALUES (0, '2012-11-01', '11:00:00'),(1, '2012-12-01', '11:00:00'),(2, '2012-11-30', '11:00:00'),(3, '2012-11-29', '11:00:00'),(4, '2012-11-28', '11:00:00'),(5, '2012-11-27', '11:00:00'),(6, '2012-11-26', '11:00:00'),(7, '2012-11-25', '11:00:00'),(8, '2012-11-24', '11:00:00'),(9, '2012-11-23', '11:00:00');
FLUSH TABLES;
--echo
--echo select test 1
--connection child2_1
TRUNCATE TABLE mysql.general_log;
--connection master_1
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 4 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 3 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 2 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 1 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 0 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 9 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 8 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 7 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 6 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 5 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY));
--connection child2_1
eval $CHILD2_1_SELECT_ARGUMENT1;
eval $CHILD2_1_SELECT_TABLES;
--echo
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
SET GLOBAL log_output = @old_log_output;
--enable_warnings
--source ../include/insert_select_deinit.inc
--echo
--echo end of test

View file

@ -312,6 +312,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)
@ -1283,7 +1287,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))
) {
@ -1745,7 +1749,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 =
@ -1754,10 +1759,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;
@ -1804,12 +1810,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])))
@ -2688,7 +2694,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,
@ -2706,7 +2712,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,
@ -2949,6 +2955,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;
@ -3042,7 +3049,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;
@ -3314,6 +3322,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;
@ -3411,7 +3420,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;
@ -4097,11 +4107,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);
}
@ -4124,7 +4135,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");
@ -4197,7 +4208,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) ||
(
@ -4212,7 +4223,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 &&

View file

@ -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
@ -839,6 +840,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;
@ -1128,13 +1130,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))
{
@ -1147,7 +1151,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] =
@ -1172,13 +1176,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))
{
@ -1191,7 +1197,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] =

View file

@ -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]));
@ -984,7 +984,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]));
}
@ -1017,8 +1018,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],
@ -1035,7 +1036,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,
@ -1051,8 +1053,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],
@ -1104,8 +1106,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],
@ -1122,7 +1124,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(
@ -1142,8 +1145,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],
@ -1159,7 +1162,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 ||
@ -1167,7 +1170,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);
@ -1187,8 +1190,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],
@ -2798,7 +2801,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())
@ -3526,7 +3529,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",
@ -3708,7 +3712,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");
@ -4064,8 +4068,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;
@ -4163,8 +4168,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;
@ -4428,8 +4434,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;
@ -4474,8 +4480,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;
@ -4500,8 +4506,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;
@ -4809,7 +4815,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,
@ -4899,8 +4905,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],
@ -4919,7 +4925,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,
@ -4934,8 +4940,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],
@ -4967,8 +4973,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],
@ -5153,8 +5159,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],
@ -5171,7 +5177,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,
@ -5187,8 +5194,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],
@ -5218,8 +5225,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],
@ -5356,8 +5363,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],
@ -5374,7 +5381,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,
@ -5390,8 +5398,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],
@ -5421,8 +5429,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],
@ -5521,7 +5529,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;
@ -5893,7 +5901,7 @@ int spider_db_simple_action(
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_simple_action");
if (pre_call)
@ -6043,7 +6051,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) &&
@ -6063,8 +6072,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],
@ -6084,7 +6093,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)
@ -6118,7 +6128,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");
@ -6236,8 +6246,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],
@ -6254,7 +6264,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,
@ -6286,8 +6297,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],
@ -6327,8 +6338,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;
@ -6447,7 +6459,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,
@ -6496,8 +6508,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;
@ -6568,7 +6581,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();
@ -6730,7 +6743,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();
@ -6905,7 +6918,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))
@ -6938,8 +6951,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],
@ -6956,7 +6969,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,
@ -6975,8 +6989,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],
@ -7009,7 +7023,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,
@ -7028,8 +7043,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],
@ -7255,7 +7270,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];
@ -7272,8 +7287,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],
@ -7290,7 +7305,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(
@ -7312,8 +7328,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],
@ -7350,8 +7366,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;
@ -7515,7 +7532,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];
@ -7532,8 +7549,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],
@ -7550,7 +7567,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(
@ -7559,7 +7577,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;
@ -7572,8 +7591,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],
@ -7673,8 +7692,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;
@ -7909,7 +7929,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];
@ -7926,8 +7946,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],
@ -7944,7 +7964,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,
@ -7960,8 +7981,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],
@ -7998,8 +8019,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;
@ -8131,7 +8153,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];
@ -8148,8 +8170,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],
@ -8166,7 +8188,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,
@ -8182,8 +8205,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],
@ -8268,7 +8291,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)) ||
@ -8297,8 +8321,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],
@ -8326,8 +8350,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],
@ -8344,7 +8368,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,
@ -8360,8 +8385,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],
@ -8388,8 +8413,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],
@ -8426,7 +8451,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 (
@ -8447,8 +8472,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],
@ -8479,7 +8504,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 (
@ -8500,8 +8525,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],
@ -8533,7 +8558,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 (
@ -8554,8 +8579,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],
@ -8587,7 +8612,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 (
@ -8608,8 +8633,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],
@ -8640,7 +8665,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 (
@ -8661,8 +8686,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],
@ -8693,7 +8718,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 (
@ -8714,8 +8739,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],
@ -8764,8 +8789,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],
@ -8812,8 +8837,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],
@ -8992,7 +9017,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))
@ -9854,12 +9879,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);
}
@ -9876,8 +9902,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++))
@ -10708,10 +10734,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;
@ -10991,6 +11019,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);
@ -11005,7 +11034,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;
@ -11606,7 +11636,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,
@ -11690,10 +11721,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,
@ -11711,8 +11743,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;
@ -11850,8 +11883,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;
@ -11907,7 +11940,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,

View file

@ -2045,7 +2045,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;

View file

@ -3416,7 +3416,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;
@ -3432,7 +3432,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];
@ -6135,7 +6136,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);
@ -6276,7 +6278,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))
@ -7972,9 +7974,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;
@ -8263,7 +8267,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);
@ -8699,7 +8703,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),
@ -9101,10 +9105,10 @@ int spider_mbase_handler::append_insert(
direct_insert_kind = SPIDER_SQL_DIRECT_INSERT_KIND_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
) {
@ -9117,13 +9121,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)
{
@ -9133,28 +9137,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
) {
direct_insert_kind = SPIDER_SQL_DIRECT_INSERT_KIND_IGNORE;
if (str->reserve(SPIDER_SQL_SQL_IGNORE_LEN))
@ -9181,15 +9185,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);
@ -9220,20 +9224,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);
@ -9396,7 +9400,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);
@ -9539,6 +9543,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)
{
@ -9555,13 +9560,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
@ -9599,7 +9606,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);
@ -10597,7 +10604,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");
@ -10763,7 +10770,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())
@ -10792,7 +10799,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)
{
@ -10803,7 +10810,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)
@ -12275,7 +12282,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)))
{
@ -12356,7 +12363,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));
@ -12401,7 +12409,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));
@ -12448,7 +12457,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));
@ -12658,7 +12668,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);
@ -12964,7 +12974,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));
@ -12993,7 +13003,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;
@ -13067,9 +13078,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];
@ -13090,7 +13104,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(
@ -13130,7 +13145,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);
@ -13587,7 +13602,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)) ||
@ -13624,7 +13640,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,
@ -13648,8 +13665,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;
@ -13720,7 +13737,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)) ||
@ -13757,7 +13775,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,
@ -13781,8 +13800,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;
@ -13887,7 +13906,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)) ||
@ -13922,7 +13942,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,
@ -13944,8 +13965,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;
@ -14020,7 +14041,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)) ||
@ -14055,7 +14077,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,
@ -14077,8 +14100,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;
@ -14208,7 +14231,8 @@ int spider_mbase_handler::simple_action(
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)) ||
@ -14245,7 +14269,8 @@ int spider_mbase_handler::simple_action(
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,
@ -14269,8 +14294,8 @@ int spider_mbase_handler::simple_action(
}
}
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;
@ -14329,7 +14354,7 @@ int spider_mbase_handler::show_records(
DBUG_PRINT("info", ("spider error_num=%d", error_num));
DBUG_RETURN(error_num);
}
spider->trx->direct_aggregate_count++;
spider->wide_handler->trx->direct_aggregate_count++;
DBUG_RETURN(0);
}
@ -14378,7 +14403,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)) ||
@ -14417,7 +14443,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,
@ -14446,8 +14473,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;
@ -14516,7 +14543,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,
@ -14537,7 +14565,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);
}
@ -14552,7 +14580,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)))
@ -14561,7 +14589,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,
@ -14606,7 +14635,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,
@ -14655,7 +14685,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,
@ -14705,7 +14736,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,
@ -14755,7 +14787,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,
@ -14804,7 +14837,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,
@ -14853,7 +14887,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,
@ -14890,7 +14925,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,
@ -14915,7 +14951,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,
@ -15037,16 +15074,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) ?
@ -15055,10 +15093,10 @@ 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) ||
bitmap_is_set(table->read_set, 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)
)
) {

View file

@ -2315,7 +2315,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;
@ -2331,7 +2331,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];
@ -4015,7 +4016,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);
@ -4156,7 +4158,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))
@ -5487,7 +5489,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);
@ -5869,7 +5871,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);
@ -6479,7 +6481,7 @@ int spider_oracle_handler::append_direct_update_set(
DBUG_ENTER("spider_oracle_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);
@ -6587,8 +6589,8 @@ int spider_oracle_handler::append_update_columns(
uint alias_length
) {
int error_num;
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_oracle_handler::append_update_columns");
while ((field = fi++))
@ -7618,7 +7620,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");
@ -9816,7 +9818,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));
@ -9861,7 +9864,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));
@ -9908,7 +9912,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));
@ -10425,7 +10430,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));
@ -10454,7 +10459,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;
@ -10551,7 +10557,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(
@ -10591,7 +10598,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);
@ -11130,7 +11137,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)) ||
@ -11167,7 +11175,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,
@ -11189,8 +11198,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;
@ -11245,7 +11254,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)) ||
@ -11280,7 +11290,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,
@ -11302,8 +11313,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;
@ -11369,7 +11380,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)) ||
@ -11406,7 +11418,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,
@ -11428,8 +11441,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;
@ -11488,7 +11501,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)) ||
@ -11523,7 +11537,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,
@ -11545,8 +11560,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;
@ -11612,7 +11627,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)) ||
@ -11649,7 +11665,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,
@ -11673,8 +11690,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;
@ -11707,7 +11724,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);
}
@ -11729,7 +11746,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)) ||
@ -11766,7 +11784,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,
@ -11790,8 +11809,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;
@ -11866,8 +11885,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;
@ -11923,7 +11942,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)) ||
@ -11962,7 +11982,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,
@ -11991,8 +12012,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;
@ -12062,7 +12083,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,
@ -12083,7 +12105,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);
@ -12133,7 +12155,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,
@ -12182,7 +12205,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,
@ -12232,7 +12256,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,
@ -12282,7 +12307,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,
@ -12331,7 +12357,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,
@ -12380,7 +12407,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,
@ -12417,7 +12445,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,
@ -12442,7 +12471,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,

View file

@ -795,7 +795,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;
@ -1147,8 +1147,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],
@ -1181,7 +1181,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;
}
@ -1924,6 +1924,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,
@ -2006,6 +2012,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,

View file

@ -621,26 +621,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;
@ -648,6 +641,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;
@ -664,11 +658,103 @@ typedef struct st_spider_patition_share
ha_statistics stat;
longlong *cardinality;
/*
volatile SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share;
*/
} SPIDER_PARTITION_SHARE;
} SPIDER_WIDE_SHARE;
enum spider_hnd_stage {
SPD_HND_STAGE_NONE,
SPD_HND_STAGE_STORE_LOCK,
SPD_HND_STAGE_EXTERNAL_LOCK,
SPD_HND_STAGE_START_STMT,
SPD_HND_STAGE_EXTRA,
SPD_HND_STAGE_COND_PUSH,
SPD_HND_STAGE_COND_POP,
SPD_HND_STAGE_INFO_PUSH,
SPD_HND_STAGE_SET_TOP_TABLE_AND_FIELDS,
SPD_HND_STAGE_CLEAR_TOP_TABLE_FIELDS
};
typedef struct st_spider_wide_handler
{
spider_hnd_stage stage;
handler *stage_executor;
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
{
@ -805,7 +891,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
@ -1177,9 +1262,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

File diff suppressed because it is too large Load diff

View file

@ -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,

View file

@ -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)))
{
@ -1200,6 +1200,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");
@ -1212,6 +1213,7 @@ SPIDER_TRX *spider_get_trx(
spider_bulk_malloc(NULL, 56, MYF(MY_WME | MY_ZEROFILL),
&trx, (uint) (sizeof(*trx)),
&tmp_share, (uint) (sizeof(SPIDER_SHARE)),
&tmp_wide_handler, (uint) sizeof(SPIDER_WIDE_HANDLER),
&udf_table_mutexes, (uint) (sizeof(pthread_mutex_t) *
spider_param_udf_table_lock_mutex_count()),
NullS))
@ -1387,7 +1389,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]))
@ -1875,27 +1878,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)
@ -1906,19 +1896,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])) ||
(spider_param_sync_sql_mode(thd) &&
(error_num = spider_check_and_set_sql_mode(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)
@ -1929,9 +1907,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",
@ -1950,7 +1926,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;
@ -2003,6 +1979,54 @@ 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])) ||
(spider_param_sync_sql_mode(thd) &&
(error_num = spider_check_and_set_sql_mode(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));
@ -2068,8 +2092,6 @@ int spider_internal_start_trx(
DBUG_RETURN(0);
error:
if (xa_lock)
spider_xa_unlock(&trx->internal_xid_state);
DBUG_RETURN(error_num);
}
@ -3750,11 +3772,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)
@ -3810,9 +3832,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)

View file

@ -126,6 +126,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