mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
MDEV-6088 - Merge spider 3.2
This commit is contained in:
commit
15b443b095
34 changed files with 37220 additions and 35437 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -125,6 +125,7 @@ public:
|
|||
bool clone_bitmap_init;
|
||||
ha_spider *pt_clone_source_handler;
|
||||
ha_spider *pt_clone_last_searcher;
|
||||
bool has_clone_for_merge;
|
||||
|
||||
bool init_index_handler;
|
||||
bool init_rnd_handler;
|
||||
|
|
@ -165,6 +166,7 @@ public:
|
|||
bool high_priority;
|
||||
bool insert_delayed;
|
||||
bool use_pre_call;
|
||||
bool use_pre_records;
|
||||
enum thr_lock_type lock_type;
|
||||
int lock_mode;
|
||||
uint sql_command;
|
||||
|
|
@ -172,6 +174,9 @@ public:
|
|||
bool bulk_insert;
|
||||
#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
|
||||
bool info_auto_called;
|
||||
#endif
|
||||
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
bool auto_inc_temporary;
|
||||
#endif
|
||||
int bulk_size;
|
||||
int direct_dup_insert;
|
||||
|
|
@ -232,6 +237,7 @@ public:
|
|||
SPIDER_ITEM_HLD *direct_aggregate_item_first;
|
||||
SPIDER_ITEM_HLD *direct_aggregate_item_current;
|
||||
#endif
|
||||
ha_rows table_rows;
|
||||
|
||||
/* for fulltext search */
|
||||
bool ft_init_and_first;
|
||||
|
|
@ -463,6 +469,9 @@ public:
|
|||
bool use_parallel
|
||||
);
|
||||
#ifdef HA_MRR_USE_DEFAULT_IMPL
|
||||
int pre_multi_range_read_next(
|
||||
bool use_parallel
|
||||
);
|
||||
#else
|
||||
int pre_read_multi_range_first(
|
||||
KEY_MULTI_RANGE **found_range_p,
|
||||
|
|
@ -491,6 +500,7 @@ public:
|
|||
key_range *end_key
|
||||
);
|
||||
int check_crd();
|
||||
int pre_records();
|
||||
ha_rows records();
|
||||
const char *table_type() const;
|
||||
ulonglong table_flags() const;
|
||||
|
|
@ -510,6 +520,9 @@ public:
|
|||
uint8 table_cache_type();
|
||||
#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
|
||||
bool need_info_for_auto_inc();
|
||||
#endif
|
||||
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
bool can_use_for_auto_inc_init();
|
||||
#endif
|
||||
int update_auto_increment();
|
||||
void get_auto_increment(
|
||||
|
|
@ -541,6 +554,12 @@ public:
|
|||
int pre_write_row(
|
||||
uchar *buf
|
||||
);
|
||||
#endif
|
||||
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
|
||||
void direct_update_init(
|
||||
THD *thd,
|
||||
bool hs_request
|
||||
);
|
||||
#endif
|
||||
bool start_bulk_update();
|
||||
int exec_bulk_update(
|
||||
|
|
@ -721,6 +740,7 @@ public:
|
|||
);
|
||||
uint check_partitioned();
|
||||
void check_direct_order_limit();
|
||||
int check_ha_range_eof();
|
||||
int drop_tmp_tables();
|
||||
bool handler_opened(
|
||||
int link_idx,
|
||||
|
|
@ -845,7 +865,7 @@ public:
|
|||
int append_direct_update_set_hs_part();
|
||||
#endif
|
||||
#endif
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
|
||||
int append_dup_update_pushdown_sql_part(
|
||||
const char *alias,
|
||||
uint alias_length
|
||||
|
|
@ -944,6 +964,13 @@ public:
|
|||
void set_order_to_pos_sql(
|
||||
ulong sql_type
|
||||
);
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
int append_group_by_sql_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
ulong sql_type
|
||||
);
|
||||
#endif
|
||||
int append_key_order_for_merge_with_alias_sql_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -233,6 +233,7 @@ void spider_free_conn_from_trx(
|
|||
) {
|
||||
/* conn_recycle_mode == 1 */
|
||||
*conn->conn_key = '0';
|
||||
conn->casual_read_base_conn = NULL;
|
||||
if (
|
||||
conn->quick_target &&
|
||||
spider_db_free_result((ha_spider *) conn->quick_target, FALSE)
|
||||
|
|
@ -1100,6 +1101,91 @@ int spider_free_conn(
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
int spider_check_and_get_casual_read_conn(
|
||||
THD *thd,
|
||||
ha_spider *spider,
|
||||
int link_idx
|
||||
) {
|
||||
int error_num;
|
||||
DBUG_ENTER("spider_check_and_get_casual_read_conn");
|
||||
if (spider->result_list.casual_read[link_idx])
|
||||
{
|
||||
SPIDER_CONN *conn = spider->conns[link_idx];
|
||||
if (conn->casual_read_query_id != thd->query_id)
|
||||
{
|
||||
conn->casual_read_query_id = thd->query_id;
|
||||
conn->casual_read_current_id = 2;
|
||||
}
|
||||
if (spider->result_list.casual_read[link_idx] == 1)
|
||||
{
|
||||
spider->result_list.casual_read[link_idx] = conn->casual_read_current_id;
|
||||
++conn->casual_read_current_id;
|
||||
if (conn->casual_read_current_id > 63)
|
||||
{
|
||||
conn->casual_read_current_id = 2;
|
||||
}
|
||||
}
|
||||
char first_byte_bak = *spider->conn_keys[link_idx];
|
||||
*spider->conn_keys[link_idx] =
|
||||
'0' + spider->result_list.casual_read[link_idx];
|
||||
if (
|
||||
!(spider->conns[link_idx] =
|
||||
spider_get_conn(spider->share, link_idx,
|
||||
spider->conn_keys[link_idx], spider->trx,
|
||||
spider, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL,
|
||||
&error_num))
|
||||
) {
|
||||
*spider->conn_keys[link_idx] = first_byte_bak;
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
*spider->conn_keys[link_idx] = first_byte_bak;
|
||||
spider->conns[link_idx]->casual_read_base_conn = conn;
|
||||
conn = spider->conns[link_idx];
|
||||
spider_check_and_set_autocommit(thd, conn, NULL);
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
int spider_check_and_init_casual_read(
|
||||
THD *thd,
|
||||
ha_spider *spider,
|
||||
int link_idx
|
||||
) {
|
||||
int error_num;
|
||||
SPIDER_RESULT_LIST *result_list = &spider->result_list;
|
||||
SPIDER_SHARE *share = spider->share;
|
||||
DBUG_ENTER("spider_check_and_init_casual_read");
|
||||
if (
|
||||
spider_param_sync_autocommit(thd) &&
|
||||
(!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
|
||||
(
|
||||
result_list->direct_order_limit
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
|| result_list->direct_aggregate
|
||||
#endif
|
||||
)
|
||||
) {
|
||||
if (!result_list->casual_read[link_idx])
|
||||
{
|
||||
result_list->casual_read[link_idx] =
|
||||
spider_param_casual_read(thd, share->casual_read);
|
||||
}
|
||||
if ((error_num = spider_check_and_get_casual_read_conn(thd, spider,
|
||||
link_idx)))
|
||||
{
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
SPIDER_CONN *conn = spider->conns[link_idx];
|
||||
if (
|
||||
conn->casual_read_base_conn &&
|
||||
(error_num = spider_create_conn_thread(conn))
|
||||
) {
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
void spider_conn_queue_connect(
|
||||
SPIDER_SHARE *share,
|
||||
SPIDER_CONN *conn,
|
||||
|
|
@ -2096,18 +2182,38 @@ int spider_bg_conn_search(
|
|||
|
||||
void spider_bg_conn_simple_action(
|
||||
SPIDER_CONN *conn,
|
||||
uint simple_action
|
||||
uint simple_action,
|
||||
bool caller_wait,
|
||||
void *target,
|
||||
uint link_idx,
|
||||
int *error_num
|
||||
) {
|
||||
DBUG_ENTER("spider_bg_conn_simple_action");
|
||||
pthread_mutex_lock(&conn->bg_conn_mutex);
|
||||
conn->bg_caller_wait = TRUE;
|
||||
conn->bg_target = target;
|
||||
conn->link_idx = link_idx;
|
||||
conn->bg_simple_action = simple_action;
|
||||
conn->bg_error_num = error_num;
|
||||
if (caller_wait)
|
||||
{
|
||||
conn->bg_caller_wait = TRUE;
|
||||
pthread_mutex_lock(&conn->bg_conn_sync_mutex);
|
||||
} else {
|
||||
conn->bg_caller_sync_wait = TRUE;
|
||||
pthread_mutex_lock(&conn->bg_conn_sync_mutex);
|
||||
}
|
||||
pthread_cond_signal(&conn->bg_conn_cond);
|
||||
pthread_mutex_unlock(&conn->bg_conn_mutex);
|
||||
if (caller_wait)
|
||||
{
|
||||
pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex);
|
||||
pthread_mutex_unlock(&conn->bg_conn_sync_mutex);
|
||||
conn->bg_caller_wait = FALSE;
|
||||
} else {
|
||||
pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex);
|
||||
pthread_mutex_unlock(&conn->bg_conn_sync_mutex);
|
||||
conn->bg_caller_sync_wait = FALSE;
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
|
@ -2450,6 +2556,13 @@ void *spider_bg_conn_action(
|
|||
case SPIDER_BG_SIMPLE_DISCONNECT:
|
||||
conn->db_conn->bg_disconnect();
|
||||
break;
|
||||
case SPIDER_BG_SIMPLE_RECORDS:
|
||||
DBUG_PRINT("info",("spider bg simple records"));
|
||||
spider = (ha_spider*) conn->bg_target;
|
||||
*conn->bg_error_num =
|
||||
spider->dbton_handler[conn->dbton_id]->
|
||||
show_records(conn->link_idx);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -2761,10 +2874,15 @@ void *spider_bg_sts_action(
|
|||
if (spider.search_link_idx == -1)
|
||||
{
|
||||
spider_trx_set_link_idx_for_all(&spider);
|
||||
/*
|
||||
spider.search_link_idx = spider_conn_next_link_idx(
|
||||
thd, share->link_statuses, share->access_balances,
|
||||
spider.conn_link_idx, spider.search_link_idx, share->link_count,
|
||||
SPIDER_LINK_STATUS_OK);
|
||||
*/
|
||||
spider.search_link_idx = spider_conn_first_link_idx(thd,
|
||||
share->link_statuses, share->access_balances, spider.conn_link_idx,
|
||||
share->link_count, SPIDER_LINK_STATUS_OK);
|
||||
}
|
||||
if (spider.search_link_idx >= 0)
|
||||
{
|
||||
|
|
@ -2780,6 +2898,7 @@ void *spider_bg_sts_action(
|
|||
&error_num);
|
||||
conns[spider.search_link_idx]->error_mode = 0;
|
||||
pthread_mutex_unlock(&spider_global_trx_mutex);
|
||||
/*
|
||||
if (
|
||||
error_num &&
|
||||
share->monitoring_kind[spider.search_link_idx] &&
|
||||
|
|
@ -2802,8 +2921,10 @@ void *spider_bg_sts_action(
|
|||
);
|
||||
lex_end(thd->lex);
|
||||
}
|
||||
*/
|
||||
spider.search_link_idx = -1;
|
||||
}
|
||||
if (conns[spider.search_link_idx])
|
||||
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
|
||||
{
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (spider_get_sts(share, spider.search_link_idx,
|
||||
|
|
@ -2818,6 +2939,7 @@ void *spider_bg_sts_action(
|
|||
2, HA_STATUS_CONST | HA_STATUS_VARIABLE))
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
if (
|
||||
share->monitoring_kind[spider.search_link_idx] &&
|
||||
need_mons[spider.search_link_idx]
|
||||
|
|
@ -2839,6 +2961,7 @@ void *spider_bg_sts_action(
|
|||
);
|
||||
lex_end(thd->lex);
|
||||
}
|
||||
*/
|
||||
spider.search_link_idx = -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -3143,10 +3266,15 @@ void *spider_bg_crd_action(
|
|||
if (spider.search_link_idx == -1)
|
||||
{
|
||||
spider_trx_set_link_idx_for_all(&spider);
|
||||
/*
|
||||
spider.search_link_idx = spider_conn_next_link_idx(
|
||||
thd, share->link_statuses, share->access_balances,
|
||||
spider.conn_link_idx, spider.search_link_idx, share->link_count,
|
||||
SPIDER_LINK_STATUS_OK);
|
||||
*/
|
||||
spider.search_link_idx = spider_conn_first_link_idx(thd,
|
||||
share->link_statuses, share->access_balances, spider.conn_link_idx,
|
||||
share->link_count, SPIDER_LINK_STATUS_OK);
|
||||
}
|
||||
if (spider.search_link_idx >= 0)
|
||||
{
|
||||
|
|
@ -3162,6 +3290,7 @@ void *spider_bg_crd_action(
|
|||
&error_num);
|
||||
conns[spider.search_link_idx]->error_mode = 0;
|
||||
pthread_mutex_unlock(&spider_global_trx_mutex);
|
||||
/*
|
||||
if (
|
||||
error_num &&
|
||||
share->monitoring_kind[spider.search_link_idx] &&
|
||||
|
|
@ -3184,8 +3313,10 @@ void *spider_bg_crd_action(
|
|||
);
|
||||
lex_end(thd->lex);
|
||||
}
|
||||
*/
|
||||
spider.search_link_idx = -1;
|
||||
}
|
||||
if (conns[spider.search_link_idx])
|
||||
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
|
||||
{
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (spider_get_crd(share, spider.search_link_idx,
|
||||
|
|
@ -3200,6 +3331,7 @@ void *spider_bg_crd_action(
|
|||
2))
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
if (
|
||||
share->monitoring_kind[spider.search_link_idx] &&
|
||||
need_mons[spider.search_link_idx]
|
||||
|
|
@ -3221,6 +3353,7 @@ void *spider_bg_crd_action(
|
|||
);
|
||||
lex_end(thd->lex);
|
||||
}
|
||||
*/
|
||||
spider.search_link_idx = -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -3718,28 +3851,35 @@ bool spider_conn_use_handler(
|
|||
#endif
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
#endif
|
||||
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
|
||||
if (spider->do_direct_update)
|
||||
{
|
||||
spider->sql_kinds |= SPIDER_SQL_KIND_SQL;
|
||||
spider->sql_kind[link_idx] = SPIDER_SQL_KIND_SQL;
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
if (spider_bit_is_set(spider->do_hs_direct_update, link_idx))
|
||||
{
|
||||
spider->direct_update_kinds |= SPIDER_SQL_KIND_HS;
|
||||
DBUG_PRINT("info",("spider TRUE by using HS direct_update"));
|
||||
DBUG_RETURN(TRUE);
|
||||
} else
|
||||
} else {
|
||||
#endif
|
||||
spider->direct_update_kinds |= SPIDER_SQL_KIND_SQL;
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
}
|
||||
if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL)
|
||||
{
|
||||
#endif
|
||||
DBUG_PRINT("info",("spider FALSE by using direct_update"));
|
||||
DBUG_RETURN(FALSE);
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
} else {
|
||||
DBUG_PRINT("info",("spider TRUE by using BOTH"));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
if (spider->use_spatial_index)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
#define SPIDER_BG_SIMPLE_NO_ACTION 0
|
||||
#define SPIDER_BG_SIMPLE_CONNECT 1
|
||||
#define SPIDER_BG_SIMPLE_DISCONNECT 2
|
||||
#define SPIDER_BG_SIMPLE_RECORDS 3
|
||||
|
||||
uchar *spider_conn_get_key(
|
||||
SPIDER_CONN *conn,
|
||||
|
|
@ -69,6 +70,18 @@ int spider_free_conn(
|
|||
SPIDER_CONN *conn
|
||||
);
|
||||
|
||||
int spider_check_and_get_casual_read_conn(
|
||||
THD *thd,
|
||||
ha_spider *spider,
|
||||
int link_idx
|
||||
);
|
||||
|
||||
int spider_check_and_init_casual_read(
|
||||
THD *thd,
|
||||
ha_spider *spider,
|
||||
int link_idx
|
||||
);
|
||||
|
||||
void spider_conn_queue_connect(
|
||||
SPIDER_SHARE *share,
|
||||
SPIDER_CONN *conn,
|
||||
|
|
@ -220,7 +233,11 @@ int spider_bg_conn_search(
|
|||
|
||||
void spider_bg_conn_simple_action(
|
||||
SPIDER_CONN *conn,
|
||||
uint simple_action
|
||||
uint simple_action,
|
||||
bool caller_wait,
|
||||
void *target,
|
||||
uint link_idx,
|
||||
int *error_num
|
||||
);
|
||||
|
||||
void *spider_bg_conn_action(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2009-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2009-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -719,7 +719,7 @@ int spider_udf_copy_tables_create_table_list(
|
|||
©_tables->link_idxs[1],
|
||||
sizeof(int) * copy_tables->link_idx_count[1],
|
||||
&tmp_name_ptr, sizeof(char) * (
|
||||
spider_table_name_length * 2 + copy_tables->database_length + 2
|
||||
spider_table_name_length * 2 + copy_tables->database_length + 3
|
||||
),
|
||||
NullS))
|
||||
) {
|
||||
|
|
@ -849,6 +849,7 @@ long long spider_copy_tables_body(
|
|||
MEM_ROOT mem_root;
|
||||
longlong bulk_insert_rows;
|
||||
Reprepare_observer *reprepare_observer_backup;
|
||||
uint tmp_conn_link_idx = 0;
|
||||
DBUG_ENTER("spider_copy_tables_body");
|
||||
if (
|
||||
thd->open_tables != 0 ||
|
||||
|
|
@ -989,6 +990,7 @@ long long spider_copy_tables_body(
|
|||
table_list->table_name_length));
|
||||
reprepare_observer_backup = thd->m_reprepare_observer;
|
||||
thd->m_reprepare_observer = NULL;
|
||||
copy_tables->trx->trx_start = TRUE;
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
if (open_and_lock_tables(thd, table_list))
|
||||
#else
|
||||
|
|
@ -1003,12 +1005,14 @@ long long spider_copy_tables_body(
|
|||
#endif
|
||||
{
|
||||
thd->m_reprepare_observer = reprepare_observer_backup;
|
||||
copy_tables->trx->trx_start = FALSE;
|
||||
my_printf_error(ER_SPIDER_UDF_CANT_OPEN_TABLE_NUM,
|
||||
ER_SPIDER_UDF_CANT_OPEN_TABLE_STR, MYF(0), table_list->db,
|
||||
table_list->table_name);
|
||||
goto error;
|
||||
}
|
||||
thd->m_reprepare_observer = reprepare_observer_backup;
|
||||
copy_tables->trx->trx_start = FALSE;
|
||||
|
||||
table = table_list->table;
|
||||
table_share = table->s;
|
||||
|
|
@ -1093,6 +1097,7 @@ long long spider_copy_tables_body(
|
|||
for (roop_count = 0; roop_count < all_link_cnt; roop_count++)
|
||||
{
|
||||
spider[roop_count].conns = NULL;
|
||||
spider[roop_count].change_table_ptr(table, table_share);
|
||||
}
|
||||
for (roop_count = 0, table_conn = copy_tables->table_conn[0];
|
||||
table_conn; roop_count++, table_conn = table_conn->next)
|
||||
|
|
@ -1123,6 +1128,7 @@ long long spider_copy_tables_body(
|
|||
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->conn_link_idx = &tmp_conn_link_idx;
|
||||
uint dbton_id = tmp_spider->share->use_dbton_ids[0];
|
||||
if (!(tmp_spider->dbton_handler[dbton_id] =
|
||||
spider_dbton[dbton_id].create_db_handler(tmp_spider,
|
||||
|
|
@ -1166,6 +1172,7 @@ long long spider_copy_tables_body(
|
|||
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->conn_link_idx = &tmp_conn_link_idx;
|
||||
uint dbton_id = tmp_spider->share->use_dbton_ids[0];
|
||||
if (!(tmp_spider->dbton_handler[dbton_id] =
|
||||
spider_dbton[dbton_id].create_db_handler(tmp_spider,
|
||||
|
|
@ -1293,7 +1300,9 @@ error:
|
|||
delete [] tmp_sql;
|
||||
}
|
||||
if (copy_tables)
|
||||
{
|
||||
spider_udf_free_copy_tables_alloc(copy_tables);
|
||||
}
|
||||
*error = 1;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
|
@ -1338,6 +1347,6 @@ void spider_copy_tables_deinit_body(
|
|||
!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) &&
|
||||
(trx = spider_get_trx(thd, TRUE, &error_num))
|
||||
)
|
||||
spider_free_trx_conn(trx, FALSE);
|
||||
spider_copy_table_free_trx_conn(trx);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2010-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2010-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -1205,7 +1205,7 @@ void spider_db_append_xid_str(
|
|||
DBUG_ENTER("spider_db_append_xid_str");
|
||||
|
||||
format_id_length =
|
||||
my_sprintf(format_id, (format_id, "0x%lx", xid->formatID));
|
||||
my_sprintf(format_id, (format_id, "%lu", xid->formatID));
|
||||
spider_db_append_hex_string(tmp_str, (uchar *) xid->data, xid->gtrid_length);
|
||||
/*
|
||||
tmp_str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
|
||||
|
|
@ -1595,9 +1595,10 @@ int spider_db_append_key_where_internal(
|
|||
start_key_part_map = 0;
|
||||
use_both = FALSE;
|
||||
}
|
||||
if (end_key)
|
||||
if (end_key) {
|
||||
end_key_part_map = end_key->keypart_map & full_key_part_map;
|
||||
else {
|
||||
result_list->end_key = end_key;
|
||||
} else {
|
||||
end_key_part_map = 0;
|
||||
use_both = FALSE;
|
||||
}
|
||||
|
|
@ -1657,6 +1658,8 @@ int spider_db_append_key_where_internal(
|
|||
tgt_key_part_map = end_key_part_map;
|
||||
}
|
||||
DBUG_PRINT("info", ("spider tgt_key_part_map=%lu", tgt_key_part_map));
|
||||
if (start_key_part_map == end_key_part_map)
|
||||
result_list->use_both_key = TRUE;
|
||||
|
||||
if (sql_kind == SPIDER_SQL_KIND_SQL)
|
||||
{
|
||||
|
|
@ -1707,6 +1710,7 @@ int spider_db_append_key_where_internal(
|
|||
#endif
|
||||
}
|
||||
} else {
|
||||
DBUG_PRINT("info", ("spider tgt_key_part_map=%lu", tgt_key_part_map));
|
||||
if (tgt_key_part_map > 1)
|
||||
key_eq = TRUE;
|
||||
else
|
||||
|
|
@ -1716,10 +1720,11 @@ int spider_db_append_key_where_internal(
|
|||
(key_eq && use_key == start_key) ||
|
||||
(!key_eq && start_key_part_map)
|
||||
) {
|
||||
bool tgt_final = (use_key == start_key && tgt_key_part_map == 1);
|
||||
ptr = start_key->key + length;
|
||||
if (
|
||||
(error_num = dbton_hdl->append_is_null_part(sql_type, key_part,
|
||||
start_key, &ptr, key_eq))
|
||||
start_key, &ptr, key_eq, tgt_final))
|
||||
) {
|
||||
if (error_num > 0)
|
||||
DBUG_RETURN(error_num);
|
||||
|
|
@ -1759,11 +1764,14 @@ int spider_db_append_key_where_internal(
|
|||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
if (use_key == start_key)
|
||||
{
|
||||
if (spider_dbton[dbton_id].db_util->
|
||||
append_column_value(spider, str_part, field, ptr,
|
||||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
else {
|
||||
if (spider_dbton[share->use_hs_dbton_ids[0]].db_util->
|
||||
|
|
@ -1807,14 +1815,20 @@ int spider_db_append_key_where_internal(
|
|||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
if (use_key == start_key)
|
||||
{
|
||||
if (tgt_key_part_map == 1)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_EQUAL_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN);
|
||||
}
|
||||
if (spider_dbton[dbton_id].db_util->
|
||||
append_column_value(spider, str_part, field, ptr,
|
||||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
else {
|
||||
if (spider_dbton[share->use_hs_dbton_ids[0]].db_util->
|
||||
|
|
@ -1860,14 +1874,20 @@ int spider_db_append_key_where_internal(
|
|||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
if (use_key == start_key)
|
||||
{
|
||||
if (tgt_key_part_map == 1)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_GT_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN);
|
||||
}
|
||||
if (spider_dbton[dbton_id].db_util->
|
||||
append_column_value(spider, str_part, field, ptr,
|
||||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
else {
|
||||
if (spider_dbton[share->use_hs_dbton_ids[0]].db_util->
|
||||
|
|
@ -1914,14 +1934,20 @@ int spider_db_append_key_where_internal(
|
|||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
if (use_key == start_key)
|
||||
{
|
||||
if (tgt_key_part_map == 1)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_LT_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN);
|
||||
}
|
||||
if (spider_dbton[dbton_id].db_util->
|
||||
append_column_value(spider, str_part, field, ptr,
|
||||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
else {
|
||||
if (spider_dbton[share->use_hs_dbton_ids[0]].db_util->
|
||||
|
|
@ -1974,14 +2000,21 @@ int spider_db_append_key_where_internal(
|
|||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
if (use_key == start_key)
|
||||
{
|
||||
if (tgt_key_part_map == 1)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_LTEQUAL_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN);
|
||||
str->q_append(SPIDER_SQL_LTEQUAL_STR,
|
||||
SPIDER_SQL_LTEQUAL_LEN);
|
||||
}
|
||||
if (spider_dbton[dbton_id].db_util->
|
||||
append_column_value(spider, str_part, field, ptr,
|
||||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
else {
|
||||
if (spider_dbton[share->use_hs_dbton_ids[0]].db_util->
|
||||
|
|
@ -2116,14 +2149,21 @@ int spider_db_append_key_where_internal(
|
|||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
if (use_key == start_key)
|
||||
{
|
||||
if (tgt_key_part_map == 1)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_GTEQUAL_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_GTEQUAL_STR, SPIDER_SQL_GTEQUAL_LEN);
|
||||
str->q_append(SPIDER_SQL_GTEQUAL_STR,
|
||||
SPIDER_SQL_GTEQUAL_LEN);
|
||||
}
|
||||
if (spider_dbton[dbton_id].db_util->
|
||||
append_column_value(spider, str_part, field, ptr,
|
||||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
else {
|
||||
if (spider_dbton[share->use_hs_dbton_ids[0]].db_util->
|
||||
|
|
@ -2152,11 +2192,14 @@ int spider_db_append_key_where_internal(
|
|||
str_part2->q_append(SPIDER_SQL_AND_STR,
|
||||
SPIDER_SQL_AND_LEN);
|
||||
|
||||
if (use_key == start_key)
|
||||
{
|
||||
if (str_part->reserve(SPIDER_SQL_COMMA_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str_part->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
if (sql_kind != SPIDER_SQL_KIND_HS)
|
||||
|
|
@ -2166,9 +2209,10 @@ int spider_db_append_key_where_internal(
|
|||
(key_eq && use_key == end_key) ||
|
||||
(!key_eq && end_key_part_map)
|
||||
) {
|
||||
bool tgt_final = (use_key == end_key && tgt_key_part_map == 1);
|
||||
ptr = end_key->key + length;
|
||||
if ((error_num = dbton_hdl->append_is_null_part(sql_type, key_part,
|
||||
end_key, &ptr, key_eq)))
|
||||
end_key, &ptr, key_eq, tgt_final)))
|
||||
{
|
||||
if (error_num > 0)
|
||||
DBUG_RETURN(error_num);
|
||||
|
|
@ -2207,14 +2251,22 @@ int spider_db_append_key_where_internal(
|
|||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
if (use_key == end_key)
|
||||
{
|
||||
/*
|
||||
if (tgt_key_part_map == 1)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_EQUAL_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN);
|
||||
}
|
||||
*/
|
||||
if (spider_dbton[dbton_id].db_util->
|
||||
append_column_value(spider, str_part, field, ptr,
|
||||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DBUG_PRINT("info", ("spider end_key->flag=%d", end_key->flag));
|
||||
switch (end_key->flag)
|
||||
|
|
@ -2251,14 +2303,20 @@ int spider_db_append_key_where_internal(
|
|||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
if (use_key == end_key)
|
||||
{
|
||||
if (tgt_key_part_map == 1)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_LT_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN);
|
||||
}
|
||||
if (spider_dbton[dbton_id].db_util->
|
||||
append_column_value(spider, str_part, field, ptr,
|
||||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (sql_kind == SPIDER_SQL_KIND_SQL)
|
||||
|
|
@ -2291,14 +2349,21 @@ int spider_db_append_key_where_internal(
|
|||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
if (use_key == end_key)
|
||||
{
|
||||
if (tgt_key_part_map == 1)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_LTEQUAL_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN);
|
||||
str->q_append(SPIDER_SQL_LTEQUAL_STR,
|
||||
SPIDER_SQL_LTEQUAL_LEN);
|
||||
}
|
||||
if (spider_dbton[dbton_id].db_util->
|
||||
append_column_value(spider, str_part, field, ptr,
|
||||
share->access_charset))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -2314,11 +2379,14 @@ int spider_db_append_key_where_internal(
|
|||
str_part2->q_append(SPIDER_SQL_AND_STR,
|
||||
SPIDER_SQL_AND_LEN);
|
||||
|
||||
if (use_key == end_key)
|
||||
{
|
||||
if (str_part->reserve(SPIDER_SQL_COMMA_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str_part->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (use_both && (!start_key_part_map || !end_key_part_map))
|
||||
break;
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
|
|
@ -2745,6 +2813,13 @@ int spider_db_fetch_table(
|
|||
{
|
||||
if (!row->is_null())
|
||||
spider->multi_range_hit_point = row->val_int();
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
else if (result_list->direct_aggregate)
|
||||
{
|
||||
table->status = STATUS_NOT_FOUND;
|
||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM);
|
||||
row->next();
|
||||
|
|
@ -2926,6 +3001,13 @@ int spider_db_fetch_key(
|
|||
DBUG_PRINT("info", ("spider mrr_with_cnt"));
|
||||
if (!row->is_null())
|
||||
spider->multi_range_hit_point = row->val_int();
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
else if (result_list->direct_aggregate)
|
||||
{
|
||||
table->status = STATUS_NOT_FOUND;
|
||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM);
|
||||
row->next();
|
||||
|
|
@ -3026,6 +3108,13 @@ int spider_db_fetch_minimum_columns(
|
|||
DBUG_PRINT("info", ("spider mrr_with_cnt"));
|
||||
if (!row->is_null())
|
||||
spider->multi_range_hit_point = row->val_int();
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
else if (result_list->direct_aggregate)
|
||||
{
|
||||
table->status = STATUS_NOT_FOUND;
|
||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM);
|
||||
row->next();
|
||||
|
|
@ -3555,12 +3644,13 @@ int spider_db_store_result(
|
|||
}
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
if (
|
||||
error_num != HA_ERR_END_OF_FILE &&
|
||||
(error_num = spider_db_errorno(conn))
|
||||
)
|
||||
bool call_db_errorno = FALSE;
|
||||
if (error_num != HA_ERR_END_OF_FILE)
|
||||
{
|
||||
call_db_errorno = TRUE;
|
||||
if ((error_num = spider_db_errorno(conn)))
|
||||
DBUG_RETURN(error_num);
|
||||
else {
|
||||
}
|
||||
DBUG_PRINT("info",("spider set finish_flg point 1"));
|
||||
DBUG_PRINT("info",("spider current->finish_flg = TRUE"));
|
||||
DBUG_PRINT("info",("spider result_list->finish_flg = TRUE"));
|
||||
|
|
@ -3575,13 +3665,12 @@ int spider_db_store_result(
|
|||
#ifndef WITHOUT_SPIDER_BG_SEARCH
|
||||
}
|
||||
#endif
|
||||
if (!conn->mta_conn_mutex_unlock_later)
|
||||
if (!conn->mta_conn_mutex_unlock_later && !call_db_errorno)
|
||||
{
|
||||
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
pthread_mutex_unlock(&conn->mta_conn_mutex);
|
||||
}
|
||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||
}
|
||||
} else {
|
||||
if (!conn->mta_conn_mutex_unlock_later)
|
||||
{
|
||||
|
|
@ -3594,14 +3683,14 @@ int spider_db_store_result(
|
|||
current->record_num));
|
||||
DBUG_PRINT("info",("spider result_list->record_num=%lld",
|
||||
result_list->record_num));
|
||||
if (
|
||||
result_list->internal_limit <= result_list->record_num ||
|
||||
result_list->split_read > current->record_num
|
||||
) {
|
||||
DBUG_PRINT("info",("spider result_list->internal_limit=%lld",
|
||||
result_list->internal_limit));
|
||||
DBUG_PRINT("info",("spider result_list->split_read=%lld",
|
||||
result_list->split_read));
|
||||
if (
|
||||
result_list->internal_limit <= result_list->record_num ||
|
||||
result_list->split_read > current->record_num
|
||||
) {
|
||||
DBUG_PRINT("info",("spider set finish_flg point 2"));
|
||||
DBUG_PRINT("info",("spider current->finish_flg = TRUE"));
|
||||
DBUG_PRINT("info",("spider result_list->finish_flg = TRUE"));
|
||||
|
|
@ -4785,7 +4874,7 @@ int spider_db_seek_tmp(
|
|||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
pos->row->first();
|
||||
}
|
||||
if (spider->sql_kind[spider->result_link_idx] == SPIDER_SQL_KIND_SQL)
|
||||
if (pos->sql_kind == SPIDER_SQL_KIND_SQL)
|
||||
{
|
||||
if (!spider->select_column_mode)
|
||||
{
|
||||
|
|
@ -5087,14 +5176,55 @@ int spider_db_show_table_status(
|
|||
|
||||
int spider_db_show_records(
|
||||
ha_spider *spider,
|
||||
int link_idx
|
||||
int link_idx,
|
||||
bool pre_call
|
||||
) {
|
||||
int error_num;
|
||||
SPIDER_CONN *conn = spider->conns[link_idx];
|
||||
THD *thd = spider->trx->thd;
|
||||
SPIDER_CONN *conn;
|
||||
DBUG_ENTER("spider_db_show_records");
|
||||
if (pre_call)
|
||||
{
|
||||
if (spider_param_bgs_mode(thd, spider->share->bgs_mode))
|
||||
{
|
||||
if ((error_num = spider_check_and_get_casual_read_conn(thd, spider,
|
||||
link_idx)))
|
||||
{
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
conn = spider->conns[link_idx];
|
||||
if (!(error_num = spider_create_conn_thread(conn)))
|
||||
{
|
||||
spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_RECORDS, FALSE,
|
||||
spider, link_idx, (int *) &spider->result_list.bgs_error);
|
||||
}
|
||||
} else {
|
||||
conn = spider->conns[link_idx];
|
||||
error_num = spider->dbton_handler[conn->dbton_id]->show_records(
|
||||
link_idx
|
||||
);
|
||||
}
|
||||
} else {
|
||||
conn = spider->conns[link_idx];
|
||||
if (spider->use_pre_records)
|
||||
{
|
||||
if (spider_param_bgs_mode(thd, spider->share->bgs_mode))
|
||||
{
|
||||
spider_bg_conn_wait(conn);
|
||||
error_num = spider->result_list.bgs_error;
|
||||
if (conn->casual_read_base_conn)
|
||||
{
|
||||
spider->conns[link_idx] = conn->casual_read_base_conn;
|
||||
}
|
||||
} else {
|
||||
error_num = 0;
|
||||
}
|
||||
} else {
|
||||
error_num = spider->dbton_handler[conn->dbton_id]->show_records(
|
||||
link_idx
|
||||
);
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
@ -5584,7 +5714,6 @@ int spider_db_bulk_bulk_insert(
|
|||
) {
|
||||
int error_num = 0, first_insert_link_idx = -1, tmp_error_num;
|
||||
int roop_count2;
|
||||
SPIDER_RESULT_LIST *result_list = &spider->result_list;
|
||||
SPIDER_SHARE *share = spider->share;
|
||||
SPIDER_CONN *conn, *first_insert_conn = NULL;
|
||||
TABLE *table = spider->get_table();
|
||||
|
|
@ -5624,6 +5753,7 @@ int spider_db_bulk_bulk_insert(
|
|||
if (conn->conn_kind != SPIDER_CONN_KIND_MYSQL)
|
||||
{
|
||||
uint roop_count;
|
||||
SPIDER_RESULT_LIST *result_list = &spider->result_list;
|
||||
DBUG_PRINT("info",("spider conn=%p", conn));
|
||||
DBUG_PRINT("info",("spider result_list->hs_upd_rows=%llu",
|
||||
result_list->hs_upd_rows));
|
||||
|
|
@ -6283,12 +6413,14 @@ int spider_db_direct_update(
|
|||
) {
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
if (
|
||||
(spider->direct_update_kinds & SPIDER_SQL_KIND_HS) &&
|
||||
(error_num = spider->append_direct_update_set_hs_part())
|
||||
) {
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
|
|
@ -6323,6 +6455,7 @@ int spider_db_direct_update(
|
|||
DBUG_RETURN(error_num);
|
||||
}
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS)
|
||||
{
|
||||
if (
|
||||
|
|
@ -6337,6 +6470,7 @@ int spider_db_direct_update(
|
|||
DBUG_RETURN(error_num);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (
|
||||
roop_count = spider_conn_link_idx_next(share->link_statuses,
|
||||
|
|
@ -6455,9 +6589,9 @@ int spider_db_direct_update(
|
|||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count))
|
||||
{
|
||||
#endif
|
||||
if (!counted)
|
||||
{
|
||||
#endif
|
||||
*update_rows = spider->conns[roop_count]->db_conn->affected_rows();
|
||||
DBUG_PRINT("info", ("spider update_rows = %u", *update_rows));
|
||||
counted = TRUE;
|
||||
|
|
@ -6559,9 +6693,9 @@ int spider_db_bulk_direct_update(
|
|||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count))
|
||||
{
|
||||
#endif
|
||||
if (!counted)
|
||||
{
|
||||
#endif
|
||||
*update_rows = spider->conns[roop_count]->db_conn->affected_rows();
|
||||
DBUG_PRINT("info", ("spider update_rows = %u", *update_rows));
|
||||
counted = TRUE;
|
||||
|
|
@ -6747,6 +6881,7 @@ int spider_db_direct_delete(
|
|||
DBUG_RETURN(error_num);
|
||||
}
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS)
|
||||
{
|
||||
if (
|
||||
|
|
@ -6761,6 +6896,7 @@ int spider_db_direct_delete(
|
|||
DBUG_RETURN(error_num);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (
|
||||
roop_count = spider_conn_link_idx_next(share->link_statuses,
|
||||
|
|
@ -6926,6 +7062,7 @@ int spider_db_direct_delete(
|
|||
if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL)))
|
||||
error_num2 = error_num;
|
||||
}
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS)
|
||||
{
|
||||
if ((error_num = spider->reset_hs_sql(SPIDER_SQL_TYPE_DELETE_HS)))
|
||||
|
|
@ -6933,6 +7070,7 @@ int spider_db_direct_delete(
|
|||
if ((error_num = spider->reset_hs_keys(SPIDER_SQL_TYPE_DELETE_HS)))
|
||||
error_num2 = error_num;
|
||||
}
|
||||
#endif
|
||||
DBUG_RETURN(error_num2);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -7932,10 +8070,27 @@ int spider_db_open_item_int(
|
|||
{
|
||||
char tmp_buf[MAX_FIELD_WIDTH];
|
||||
spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset());
|
||||
String *tmp_str2;
|
||||
tmp_str.init_calc_mem(127);
|
||||
if (str->append(*item->val_str(tmp_str.get_str())))
|
||||
if (!(tmp_str2 = item->val_str(tmp_str.get_str())))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
tmp_str.mem_calc();
|
||||
#ifdef SPIDER_ITEM_HAS_CMP_TYPE
|
||||
DBUG_PRINT("info",("spider cmp_type=%u", item->cmp_type()));
|
||||
if (item->cmp_type() == TIME_RESULT)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 + tmp_str2->length()))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
|
||||
str->append(*tmp_str2);
|
||||
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
|
||||
} else {
|
||||
#endif
|
||||
if (str->append(*tmp_str2))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
#ifdef SPIDER_ITEM_HAS_CMP_TYPE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
|
@ -7951,6 +8106,7 @@ int spider_db_open_item_cache(
|
|||
DBUG_ENTER("spider_db_open_item_cache");
|
||||
if (!item_cache->const_item())
|
||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||
DBUG_PRINT("info",("spider result_type=%u", item_cache->result_type()));
|
||||
switch (item_cache->result_type())
|
||||
{
|
||||
case STRING_RESULT:
|
||||
|
|
@ -8534,8 +8690,10 @@ int spider_db_udf_direct_sql(
|
|||
}
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#else
|
||||
if (table->pos_in_table_list)
|
||||
{
|
||||
if (
|
||||
table->s->tmp_table == NO_TMP_TABLE &&
|
||||
table->pos_in_table_list
|
||||
) {
|
||||
TABLE_LIST *next_tables =
|
||||
table->pos_in_table_list->next_global;
|
||||
while (next_tables && next_tables->parent_l)
|
||||
|
|
@ -8622,8 +8780,10 @@ int spider_db_udf_direct_sql(
|
|||
table->file->ha_external_lock(table->in_use, F_UNLCK);
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#else
|
||||
if (table->pos_in_table_list)
|
||||
{
|
||||
if (
|
||||
table->s->tmp_table == NO_TMP_TABLE &&
|
||||
table->pos_in_table_list
|
||||
) {
|
||||
TABLE_LIST *next_tables =
|
||||
table->pos_in_table_list->next_global;
|
||||
while (next_tables && next_tables->parent_l)
|
||||
|
|
@ -8865,16 +9025,19 @@ int spider_db_udf_ping_table(
|
|||
bool use_where,
|
||||
longlong limit
|
||||
) {
|
||||
int error_num, need_mon = 0;
|
||||
uint tmp_conn_link_idx = 0;
|
||||
ha_spider spider;
|
||||
int error_num;
|
||||
DBUG_ENTER("spider_db_udf_ping_table");
|
||||
if (!pthread_mutex_trylock(&table_mon_list->monitor_mutex))
|
||||
{
|
||||
int need_mon = 0;
|
||||
uint tmp_conn_link_idx = 0;
|
||||
ha_spider spider;
|
||||
uchar db_request_phase = 0;
|
||||
spider.share = share;
|
||||
spider.trx = trx;
|
||||
spider.need_mons = &need_mon;
|
||||
spider.conn_link_idx = &tmp_conn_link_idx;
|
||||
spider.db_request_phase = &db_request_phase;
|
||||
pthread_mutex_lock(&conn->mta_conn_mutex);
|
||||
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
conn->need_mon = &need_mon;
|
||||
|
|
@ -9279,6 +9442,8 @@ int spider_db_udf_copy_tables(
|
|||
{
|
||||
tmp_spider = &spider[roop_count];
|
||||
tmp_conn = tmp_spider->conns[0];
|
||||
/* disable transaction */
|
||||
spider_conn_clear_queue_at_commit(tmp_conn);
|
||||
if (!tmp_conn->trx_start)
|
||||
{
|
||||
if (spider_db_ping(tmp_spider, tmp_conn, 0))
|
||||
|
|
@ -9301,6 +9466,8 @@ int spider_db_udf_copy_tables(
|
|||
{
|
||||
tmp_spider = &spider[roop_count];
|
||||
tmp_conn = tmp_spider->conns[0];
|
||||
/* disable transaction */
|
||||
spider_conn_clear_queue_at_commit(tmp_conn);
|
||||
spider_db_handler *tmp_dbton_hdl =
|
||||
tmp_spider->dbton_handler[tmp_conn->dbton_id];
|
||||
if ((error_num = tmp_dbton_hdl->insert_lock_tables_list(tmp_conn, 0)))
|
||||
|
|
@ -9916,7 +10083,9 @@ int spider_db_bulk_open_handler(
|
|||
int link_idx
|
||||
) {
|
||||
int error_num = 0;
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
bool opening_index = FALSE;
|
||||
#endif
|
||||
DBUG_ENTER("spider_db_bulk_open_handler");
|
||||
DBUG_PRINT("info",("spider spider=%p", spider));
|
||||
DBUG_PRINT("info",("spider conn=%p", conn));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -639,7 +639,8 @@ int spider_db_show_table_status(
|
|||
|
||||
int spider_db_show_records(
|
||||
ha_spider *spider,
|
||||
int link_idx
|
||||
int link_idx,
|
||||
bool pre_call
|
||||
);
|
||||
|
||||
void spider_db_set_cardinarity(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2012-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2012-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -3262,10 +3262,15 @@ int spider_db_handlersocket_util::open_item_func(
|
|||
func_name_length = strlen(func_name);
|
||||
DBUG_PRINT("info",("spider func_name = %s", func_name));
|
||||
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
|
||||
if (str->reserve(SPIDER_SQL_MBR_LEN + func_name_length +
|
||||
SPIDER_SQL_OPEN_PAREN_LEN))
|
||||
if (str->reserve(
|
||||
#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
|
||||
SPIDER_SQL_MBR_LEN +
|
||||
#endif
|
||||
func_name_length + SPIDER_SQL_OPEN_PAREN_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
|
||||
str->q_append(SPIDER_SQL_MBR_STR, SPIDER_SQL_MBR_LEN);
|
||||
#endif
|
||||
str->q_append(func_name, func_name_length);
|
||||
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
|
||||
}
|
||||
|
|
@ -3540,7 +3545,10 @@ int spider_handlersocket_share::init()
|
|||
|
||||
if (
|
||||
(error_num = create_table_names_str()) ||
|
||||
(
|
||||
spider_share->table_share &&
|
||||
(error_num = create_column_name_str())
|
||||
)
|
||||
) {
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
|
|
@ -3859,6 +3867,7 @@ spider_handlersocket_handler::~spider_handlersocket_handler()
|
|||
int spider_handlersocket_handler::init()
|
||||
{
|
||||
st_spider_share *share = spider->share;
|
||||
TABLE *table = spider->get_table();
|
||||
DBUG_ENTER("spider_handlersocket_handler::init");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *)
|
||||
|
|
@ -3866,6 +3875,8 @@ int spider_handlersocket_handler::init()
|
|||
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
|
||||
&link_for_hash,
|
||||
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
|
||||
&minimum_select_bitmap,
|
||||
table ? sizeof(uchar) * no_bytes_in_map(table->read_set) : 0,
|
||||
NullS))
|
||||
) {
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
|
@ -4072,10 +4083,12 @@ int spider_handlersocket_handler::append_minimum_select_without_quote(
|
|||
int field_length;
|
||||
bool appended = FALSE;
|
||||
DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_without_quote");
|
||||
minimum_select_bitmap_create();
|
||||
for (field = table->field; *field; field++)
|
||||
{
|
||||
if (minimum_select_bit_is_set((*field)->field_index))
|
||||
{
|
||||
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||
field_length =
|
||||
handlersocket_share->column_name_str[(*field)->field_index].length();
|
||||
if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN))
|
||||
|
|
@ -4331,7 +4344,8 @@ int spider_handlersocket_handler::append_is_null_part(
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
) {
|
||||
int error_num;
|
||||
spider_string *str;
|
||||
|
|
@ -4349,7 +4363,7 @@ int spider_handlersocket_handler::append_is_null_part(
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
error_num = append_is_null(sql_type, str, NULL, NULL, key_part, key, ptr,
|
||||
key_eq);
|
||||
key_eq, tgt_final);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
@ -4361,7 +4375,8 @@ int spider_handlersocket_handler::append_is_null(
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
) {
|
||||
DBUG_ENTER("spider_handlersocket_handler::append_is_null");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
|
|
@ -4448,6 +4463,19 @@ void spider_handlersocket_handler::set_order_to_pos(
|
|||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
int spider_handlersocket_handler::append_group_by_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
ulong sql_type
|
||||
) {
|
||||
DBUG_ENTER("spider_handlersocket_handler::append_group_by_part");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
DBUG_ASSERT(0);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int spider_handlersocket_handler::append_key_order_for_merge_with_alias_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
|
|
@ -5485,16 +5513,68 @@ bool spider_handlersocket_handler::support_use_handler(
|
|||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
bool spider_handlersocket_handler::minimum_select_bit_is_set(
|
||||
uint field_index
|
||||
) {
|
||||
void spider_handlersocket_handler::minimum_select_bitmap_create()
|
||||
{
|
||||
TABLE *table = spider->get_table();
|
||||
DBUG_ENTER("spider_handlersocket_handler::minimum_select_bit_is_set");
|
||||
DBUG_RETURN(
|
||||
Field **field_p;
|
||||
DBUG_ENTER("spider_handlersocket_handler::minimum_select_bitmap_create");
|
||||
memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set));
|
||||
if (
|
||||
spider->has_clone_for_merge ||
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
(spider->is_clone && !spider->is_bulk_access_clone)
|
||||
#else
|
||||
spider->is_clone
|
||||
#endif
|
||||
) {
|
||||
/* need preparing for cmp_ref */
|
||||
TABLE_SHARE *table_share = table->s;
|
||||
if (
|
||||
table_share->primary_key == MAX_KEY
|
||||
) {
|
||||
/* need all columns */
|
||||
memset(minimum_select_bitmap, 0xFF, no_bytes_in_map(table->read_set));
|
||||
DBUG_VOID_RETURN;
|
||||
} else {
|
||||
/* need primary key columns */
|
||||
uint roop_count;
|
||||
KEY *key_info;
|
||||
KEY_PART_INFO *key_part;
|
||||
Field *field;
|
||||
key_info = &table_share->key_info[table_share->primary_key];
|
||||
key_part = key_info->key_part;
|
||||
for (roop_count = 0;
|
||||
roop_count < spider_user_defined_key_parts(key_info);
|
||||
roop_count++)
|
||||
{
|
||||
field = key_part[roop_count].field;
|
||||
spider_set_bit(minimum_select_bitmap, field->field_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (field_p = table->field; *field_p; field_p++)
|
||||
{
|
||||
uint field_index = (*field_p)->field_index;
|
||||
if (
|
||||
spider_bit_is_set(spider->searched_bitmap, field_index) |
|
||||
bitmap_is_set(table->read_set, field_index) |
|
||||
bitmap_is_set(table->write_set, field_index)
|
||||
);
|
||||
) {
|
||||
spider_set_bit(minimum_select_bitmap, field_index);
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
bool spider_handlersocket_handler::minimum_select_bit_is_set(
|
||||
uint field_index
|
||||
) {
|
||||
DBUG_ENTER("spider_handlersocket_handler::minimum_select_bit_is_set");
|
||||
DBUG_PRINT("info",("spider field_index=%u", field_index));
|
||||
DBUG_PRINT("info",("spider minimum_select_bitmap=%s",
|
||||
spider_bit_is_set(minimum_select_bitmap, field_index) ?
|
||||
"TRUE" : "FALSE"));
|
||||
DBUG_RETURN(spider_bit_is_set(minimum_select_bitmap, field_index));
|
||||
}
|
||||
|
||||
void spider_handlersocket_handler::copy_minimum_select_bitmap(
|
||||
|
|
@ -5508,18 +5588,10 @@ void spider_handlersocket_handler::copy_minimum_select_bitmap(
|
|||
roop_count++)
|
||||
{
|
||||
bitmap[roop_count] =
|
||||
spider->searched_bitmap[roop_count] |
|
||||
((uchar *) table->read_set->bitmap)[roop_count] |
|
||||
((uchar *) table->write_set->bitmap)[roop_count];
|
||||
minimum_select_bitmap[roop_count];
|
||||
DBUG_PRINT("info",("spider roop_count=%d", roop_count));
|
||||
DBUG_PRINT("info",("spider bitmap=%d",
|
||||
bitmap[roop_count]));
|
||||
DBUG_PRINT("info",("spider searched_bitmap=%d",
|
||||
spider->searched_bitmap[roop_count]));
|
||||
DBUG_PRINT("info",("spider read_set=%d",
|
||||
((uchar *) table->read_set->bitmap)[roop_count]));
|
||||
DBUG_PRINT("info",("spider write_set=%d",
|
||||
((uchar *) table->write_set->bitmap)[roop_count]));
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2012-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2012-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -493,6 +493,7 @@ public:
|
|||
int hs_skip;
|
||||
spider_handlersocket_share *handlersocket_share;
|
||||
SPIDER_LINK_FOR_HASH *link_for_hash;
|
||||
uchar *minimum_select_bitmap;
|
||||
spider_handlersocket_handler(
|
||||
ha_spider *spider,
|
||||
spider_handlersocket_share *db_share
|
||||
|
|
@ -627,7 +628,8 @@ public:
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
);
|
||||
int append_is_null(
|
||||
ulong sql_type,
|
||||
|
|
@ -637,7 +639,8 @@ public:
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
);
|
||||
int append_where_terminator_part(
|
||||
ulong sql_type,
|
||||
|
|
@ -671,6 +674,13 @@ public:
|
|||
void set_order_to_pos(
|
||||
ulong sql_type
|
||||
);
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
int append_group_by_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
ulong sql_type
|
||||
);
|
||||
#endif
|
||||
int append_key_order_for_merge_with_alias_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
|
|
@ -928,6 +938,7 @@ public:
|
|||
bool support_use_handler(
|
||||
int use_handler
|
||||
);
|
||||
void minimum_select_bitmap_create();
|
||||
bool minimum_select_bit_is_set(
|
||||
uint field_index
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -26,11 +26,20 @@
|
|||
#define SPIDER_HAS_SHOW_SIMPLE_FUNC
|
||||
#endif
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100007
|
||||
#define SPIDER_HAS_DISCOVER_TABLE_STRUCTURE_COMMENT
|
||||
#define SPIDER_ITEM_HAS_CMP_TYPE
|
||||
#endif
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100004
|
||||
#define SPIDER_HAS_TIME_STATUS
|
||||
#define SPIDER_HAS_DECIMAL_OPERATION_RESULTS_VALUE_TYPE
|
||||
#endif
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION)
|
||||
#define SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
|
||||
#endif
|
||||
|
||||
class spider_db_conn;
|
||||
typedef spider_db_conn SPIDER_DB_CONN;
|
||||
class spider_db_result;
|
||||
|
|
@ -1120,7 +1129,8 @@ public:
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
) = 0;
|
||||
virtual int append_where_terminator_part(
|
||||
ulong sql_type,
|
||||
|
|
@ -1154,6 +1164,13 @@ public:
|
|||
virtual void set_order_to_pos(
|
||||
ulong sql_type
|
||||
) = 0;
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
virtual int append_group_by_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
ulong sql_type
|
||||
) = 0;
|
||||
#endif
|
||||
virtual int append_key_order_for_merge_with_alias_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
|
|
@ -1578,6 +1595,8 @@ typedef struct st_spider_result_list
|
|||
uint *sql_kind_backup;
|
||||
uint sql_kinds_backup;
|
||||
bool use_union;
|
||||
bool use_both_key;
|
||||
const key_range *end_key;
|
||||
spider_string *insert_sqls;
|
||||
spider_string *update_sqls;
|
||||
TABLE **upd_tmp_tbls;
|
||||
|
|
@ -1624,6 +1643,7 @@ typedef struct st_spider_result_list
|
|||
longlong first_read;
|
||||
longlong second_read;
|
||||
int set_split_read_count;
|
||||
int *casual_read;
|
||||
#ifndef WITHOUT_SPIDER_BG_SEARCH
|
||||
/* 0:nomal 1:store 2:store end */
|
||||
volatile
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2012-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2012-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -109,6 +109,8 @@ static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR;
|
|||
#define SPIDER_SQL_SHOW_TABLE_STATUS_LEN sizeof(SPIDER_SQL_SHOW_TABLE_STATUS_STR) - 1
|
||||
#define SPIDER_SQL_SELECT_TABLES_STATUS_STR "select `table_rows`,`avg_row_length`,`data_length`,`max_data_length`,`index_length`,`auto_increment`,`create_time`,`update_time`,`check_time` from `information_schema`.`tables` where `table_schema` = "
|
||||
#define SPIDER_SQL_SELECT_TABLES_STATUS_LEN sizeof(SPIDER_SQL_SELECT_TABLES_STATUS_STR) - 1
|
||||
#define SPIDER_SQL_SHOW_WARNINGS_STR "show warnings"
|
||||
#define SPIDER_SQL_SHOW_WARNINGS_LEN sizeof(SPIDER_SQL_SHOW_WARNINGS_STR) - 1
|
||||
|
||||
#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE
|
||||
#define SPIDER_SQL_SHOW_COLUMNS_STR "show columns from "
|
||||
|
|
@ -1441,7 +1443,9 @@ int spider_db_mysql::connect(
|
|||
if (connect_mutex)
|
||||
pthread_mutex_lock(&spider_open_conn_mutex);
|
||||
/* tgt_db not use */
|
||||
if (!mysql_real_connect(
|
||||
if (
|
||||
!spider_param_dry_access() &&
|
||||
!mysql_real_connect(
|
||||
db_conn,
|
||||
tgt_host,
|
||||
tgt_username,
|
||||
|
|
@ -1450,7 +1454,8 @@ int spider_db_mysql::connect(
|
|||
tgt_port,
|
||||
tgt_socket,
|
||||
CLIENT_MULTI_STATEMENTS
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
if (connect_mutex)
|
||||
pthread_mutex_unlock(&spider_open_conn_mutex);
|
||||
error_num = mysql_errno(db_conn);
|
||||
|
|
@ -1482,6 +1487,8 @@ int spider_db_mysql::ping(
|
|||
) {
|
||||
DBUG_ENTER("spider_db_mysql::ping");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (spider_param_dry_access())
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(simple_command(db_conn, COM_PING, 0, 0, 0));
|
||||
}
|
||||
|
||||
|
|
@ -1520,17 +1527,20 @@ int spider_db_mysql::exec_query(
|
|||
uint length,
|
||||
int quick_mode
|
||||
) {
|
||||
int error_num;
|
||||
int error_num = 0;
|
||||
uint log_result_errors = spider_param_log_result_errors();
|
||||
DBUG_ENTER("spider_db_mysql::exec_query");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (spider_param_general_log())
|
||||
{
|
||||
const char *tgt_str = conn->tgt_host;
|
||||
uint32 tgt_len = conn->tgt_host_length;
|
||||
spider_string tmp_query_str(length + conn->tgt_wrapper_length +
|
||||
tgt_len + (SPIDER_SQL_SPACE_LEN * 2));
|
||||
spider_string tmp_query_str;
|
||||
tmp_query_str.init_calc_mem(230);
|
||||
tmp_query_str.length(0);
|
||||
if (tmp_query_str.reserve(
|
||||
length + conn->tgt_wrapper_length +
|
||||
tgt_len + (SPIDER_SQL_SPACE_LEN * 2)))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
tmp_query_str.q_append(conn->tgt_wrapper, conn->tgt_wrapper_length);
|
||||
tmp_query_str.q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN);
|
||||
tmp_query_str.q_append(tgt_str, tgt_len);
|
||||
|
|
@ -1539,8 +1549,58 @@ int spider_db_mysql::exec_query(
|
|||
general_log_write(current_thd, COM_QUERY, tmp_query_str.ptr(),
|
||||
tmp_query_str.length());
|
||||
}
|
||||
if (!spider_param_dry_access())
|
||||
{
|
||||
error_num = mysql_real_query(db_conn, query, length);
|
||||
if (spider_param_log_result_errors() >= 2 && db_conn->warning_count > 0)
|
||||
}
|
||||
if (
|
||||
(error_num && log_result_errors >= 1) ||
|
||||
(log_result_errors >= 2 && db_conn->warning_count > 0) ||
|
||||
(log_result_errors >= 4)
|
||||
) {
|
||||
THD *thd = current_thd;
|
||||
uint log_result_error_with_sql = spider_param_log_result_error_with_sql();
|
||||
if (log_result_error_with_sql)
|
||||
{
|
||||
time_t cur_time = (time_t) time((time_t*) 0);
|
||||
struct tm lt;
|
||||
struct tm *l_time = localtime_r(&cur_time, <);
|
||||
spider_string tmp_query_str;
|
||||
tmp_query_str.init_calc_mem(243);
|
||||
uint query_length = thd->query_length();
|
||||
if ((log_result_error_with_sql & 2) && query_length)
|
||||
{
|
||||
Security_context *security_ctx = thd->security_ctx;
|
||||
tmp_query_str.length(0);
|
||||
if (tmp_query_str.reserve(query_length + 1))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
tmp_query_str.q_append(thd->query(), query_length);
|
||||
fprintf(stderr, "%04d%02d%02d %02d:%02d:%02d [RECV SPIDER SQL] "
|
||||
"from [%s][%s] to %ld: "
|
||||
"sql: %s\n",
|
||||
l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday,
|
||||
l_time->tm_hour, l_time->tm_min, l_time->tm_sec,
|
||||
security_ctx->user ? security_ctx->user : "system user",
|
||||
security_ctx->host_or_ip,
|
||||
thd->thread_id,
|
||||
tmp_query_str.c_ptr_safe());
|
||||
}
|
||||
if (log_result_error_with_sql & 1)
|
||||
{
|
||||
tmp_query_str.length(0);
|
||||
if (tmp_query_str.reserve(length + 1))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
tmp_query_str.q_append(query, length);
|
||||
fprintf(stderr, "%04d%02d%02d %02d:%02d:%02d [SEND SPIDER SQL] "
|
||||
"from %ld to [%s] %ld: "
|
||||
"sql: %s\n",
|
||||
l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday,
|
||||
l_time->tm_hour, l_time->tm_min, l_time->tm_sec,
|
||||
thd->thread_id, conn->tgt_host, db_conn->thread_id,
|
||||
tmp_query_str.c_ptr_safe());
|
||||
}
|
||||
}
|
||||
if (log_result_errors >= 2 && db_conn->warning_count > 0)
|
||||
{
|
||||
time_t cur_time = (time_t) time((time_t*) 0);
|
||||
struct tm lt;
|
||||
|
|
@ -1550,10 +1610,12 @@ int spider_db_mysql::exec_query(
|
|||
"affected_rows: %llu id: %llu status: %u warning_count: %u\n",
|
||||
l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday,
|
||||
l_time->tm_hour, l_time->tm_min, l_time->tm_sec,
|
||||
conn->tgt_host, db_conn->thread_id, current_thd->thread_id,
|
||||
conn->tgt_host, db_conn->thread_id, thd->thread_id,
|
||||
db_conn->affected_rows, db_conn->insert_id,
|
||||
db_conn->server_status, db_conn->warning_count);
|
||||
} else if (spider_param_log_result_errors() >= 4)
|
||||
if (spider_param_log_result_errors() >= 3)
|
||||
print_warnings(l_time);
|
||||
} else if (log_result_errors >= 4)
|
||||
{
|
||||
time_t cur_time = (time_t) time((time_t*) 0);
|
||||
struct tm lt;
|
||||
|
|
@ -1563,10 +1625,11 @@ int spider_db_mysql::exec_query(
|
|||
"affected_rows: %llu id: %llu status: %u warning_count: %u\n",
|
||||
l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday,
|
||||
l_time->tm_hour, l_time->tm_min, l_time->tm_sec,
|
||||
conn->tgt_host, db_conn->thread_id, current_thd->thread_id,
|
||||
conn->tgt_host, db_conn->thread_id, thd->thread_id,
|
||||
db_conn->affected_rows, db_conn->insert_id,
|
||||
db_conn->server_status, db_conn->warning_count);
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
@ -1633,6 +1696,81 @@ bool spider_db_mysql::is_xa_nota_error(
|
|||
DBUG_RETURN(xa_nota);
|
||||
}
|
||||
|
||||
void spider_db_mysql::print_warnings(
|
||||
struct tm *l_time
|
||||
) {
|
||||
DBUG_ENTER("spider_db_mysql::print_warnings");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (db_conn->status == MYSQL_STATUS_READY)
|
||||
{
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
if (!(db_conn->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS))
|
||||
#else
|
||||
if (!(db_conn->server_status & SERVER_MORE_RESULTS_EXISTS))
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
pthread_mutex_lock(&conn->mta_conn_mutex);
|
||||
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
*/
|
||||
if (
|
||||
spider_param_dry_access() ||
|
||||
!mysql_real_query(db_conn, SPIDER_SQL_SHOW_WARNINGS_STR,
|
||||
SPIDER_SQL_SHOW_WARNINGS_LEN)
|
||||
) {
|
||||
MYSQL_RES *res = NULL;
|
||||
MYSQL_ROW row = NULL;
|
||||
uint num_fields;
|
||||
if (
|
||||
spider_param_dry_access() ||
|
||||
!(res = mysql_store_result(db_conn)) ||
|
||||
!(row = mysql_fetch_row(res))
|
||||
) {
|
||||
if (mysql_errno(db_conn))
|
||||
{
|
||||
if (res)
|
||||
mysql_free_result(res);
|
||||
/*
|
||||
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
pthread_mutex_unlock(&conn->mta_conn_mutex);
|
||||
*/
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
/* no record is ok */
|
||||
}
|
||||
/*
|
||||
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
pthread_mutex_unlock(&conn->mta_conn_mutex);
|
||||
*/
|
||||
num_fields = mysql_num_fields(res);
|
||||
if (num_fields != 3)
|
||||
{
|
||||
mysql_free_result(res);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
while (row)
|
||||
{
|
||||
fprintf(stderr, "%04d%02d%02d %02d:%02d:%02d [WARN SPIDER RESULT] "
|
||||
"from [%s] %ld to %ld: %s %s %s\n",
|
||||
l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday,
|
||||
l_time->tm_hour, l_time->tm_min, l_time->tm_sec,
|
||||
conn->tgt_host, db_conn->thread_id,
|
||||
current_thd->thread_id, row[0], row[1], row[2]);
|
||||
row = mysql_fetch_row(res);
|
||||
}
|
||||
if (res)
|
||||
mysql_free_result(res);
|
||||
} else {
|
||||
/*
|
||||
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
pthread_mutex_unlock(&conn->mta_conn_mutex);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
spider_db_result *spider_db_mysql::store_result(
|
||||
spider_db_result_buffer **spider_res_buf,
|
||||
st_spider_db_request_key *request_key,
|
||||
|
|
@ -1645,8 +1783,10 @@ spider_db_result *spider_db_mysql::store_result(
|
|||
if ((result = new spider_db_mysql_result()))
|
||||
{
|
||||
*error_num = 0;
|
||||
if (!(result->db_result = mysql_store_result(db_conn)))
|
||||
{
|
||||
if (
|
||||
spider_param_dry_access() ||
|
||||
!(result->db_result = mysql_store_result(db_conn))
|
||||
) {
|
||||
delete result;
|
||||
result = NULL;
|
||||
} else {
|
||||
|
|
@ -1669,8 +1809,10 @@ spider_db_result *spider_db_mysql::use_result(
|
|||
if ((result = new spider_db_mysql_result()))
|
||||
{
|
||||
*error_num = 0;
|
||||
if (!(result->db_result = db_conn->methods->use_result(db_conn)))
|
||||
{
|
||||
if (
|
||||
spider_param_dry_access() ||
|
||||
!(result->db_result = db_conn->methods->use_result(db_conn))
|
||||
) {
|
||||
delete result;
|
||||
result = NULL;
|
||||
} else {
|
||||
|
|
@ -1742,6 +1884,8 @@ int spider_db_mysql::set_character_set(
|
|||
) {
|
||||
DBUG_ENTER("spider_db_mysql::set_character_set");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (spider_param_dry_access())
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(mysql_set_character_set(db_conn, csname));
|
||||
}
|
||||
|
||||
|
|
@ -1750,6 +1894,8 @@ int spider_db_mysql::select_db(
|
|||
) {
|
||||
DBUG_ENTER("spider_db_mysql::select_db");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (spider_param_dry_access())
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(mysql_select_db(db_conn, dbname));
|
||||
}
|
||||
|
||||
|
|
@ -3503,10 +3649,15 @@ int spider_db_mysql_util::open_item_func(
|
|||
func_name_length = strlen(func_name);
|
||||
DBUG_PRINT("info",("spider func_name = %s", func_name));
|
||||
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
|
||||
if (str->reserve(SPIDER_SQL_MBR_LEN + func_name_length +
|
||||
SPIDER_SQL_OPEN_PAREN_LEN))
|
||||
if (str->reserve(
|
||||
#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
|
||||
SPIDER_SQL_MBR_LEN +
|
||||
#endif
|
||||
func_name_length + SPIDER_SQL_OPEN_PAREN_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
|
||||
str->q_append(SPIDER_SQL_MBR_STR, SPIDER_SQL_MBR_LEN);
|
||||
#endif
|
||||
str->q_append(func_name, func_name_length);
|
||||
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
|
||||
}
|
||||
|
|
@ -4687,6 +4838,7 @@ int spider_mysql_handler::init()
|
|||
st_spider_share *share = spider->share;
|
||||
int init_sql_alloc_size =
|
||||
spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size);
|
||||
TABLE *table = spider->get_table();
|
||||
DBUG_ENTER("spider_mysql_handler::init");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
sql.init_calc_mem(59);
|
||||
|
|
@ -4718,6 +4870,8 @@ int spider_mysql_handler::init()
|
|||
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
|
||||
&link_for_hash,
|
||||
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
|
||||
&minimum_select_bitmap,
|
||||
table ? sizeof(uchar) * no_bytes_in_map(table->read_set) : 0,
|
||||
NullS))
|
||||
) {
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
|
@ -4970,14 +5124,24 @@ int spider_mysql_handler::append_tmp_table_and_sql_for_bka(
|
|||
table_dot_aliases, table_dot_alias_lengths)) ||
|
||||
(error_num = append_condition_part(
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN,
|
||||
SPIDER_SQL_TYPE_SELECT_SQL, FALSE)) ||
|
||||
(
|
||||
spider->result_list.direct_order_limit &&
|
||||
(error_num = append_key_order_for_direct_order_limit_with_alias(&sql,
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))
|
||||
)
|
||||
SPIDER_SQL_TYPE_SELECT_SQL, FALSE))
|
||||
)
|
||||
DBUG_RETURN(error_num);
|
||||
if (spider->result_list.direct_order_limit)
|
||||
{
|
||||
if ((error_num = append_key_order_for_direct_order_limit_with_alias(&sql,
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
else if (spider->result_list.direct_aggregate)
|
||||
{
|
||||
if ((error_num =
|
||||
append_group_by(&sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#endif
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
|
@ -5184,14 +5348,26 @@ int spider_mysql_handler::append_union_table_and_sql_for_bka(
|
|||
table_dot_aliases, table_dot_alias_lengths)) ||
|
||||
(error_num = append_condition_part(
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN,
|
||||
SPIDER_SQL_TYPE_TMP_SQL, FALSE)) ||
|
||||
(
|
||||
spider->result_list.direct_order_limit &&
|
||||
(error_num = append_key_order_for_direct_order_limit_with_alias(&tmp_sql,
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))
|
||||
)
|
||||
SPIDER_SQL_TYPE_TMP_SQL, FALSE))
|
||||
)
|
||||
DBUG_RETURN(error_num);
|
||||
if (spider->result_list.direct_order_limit)
|
||||
{
|
||||
if ((error_num =
|
||||
append_key_order_for_direct_order_limit_with_alias(&tmp_sql,
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))
|
||||
)
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
else if (spider->result_list.direct_aggregate)
|
||||
{
|
||||
if ((error_num =
|
||||
append_group_by(&tmp_sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#endif
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
|
@ -5695,10 +5871,12 @@ int spider_mysql_handler::append_direct_update_set_part()
|
|||
int spider_mysql_handler::append_direct_update_set(
|
||||
spider_string *str
|
||||
) {
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
uint field_name_length;
|
||||
SPIDER_SHARE *share = spider->share;
|
||||
#ifndef DBUG_OFF
|
||||
TABLE *table = spider->get_table();
|
||||
#endif
|
||||
#endif
|
||||
DBUG_ENTER("spider_mysql_handler::append_direct_update_set");
|
||||
if (
|
||||
|
|
@ -5715,6 +5893,7 @@ int spider_mysql_handler::append_direct_update_set(
|
|||
if (
|
||||
(spider->direct_update_kinds & SPIDER_SQL_KIND_SQL)
|
||||
) {
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
size_t roop_count;
|
||||
Field *field;
|
||||
if (str->reserve(SPIDER_SQL_SET_LEN))
|
||||
|
|
@ -5766,6 +5945,9 @@ int spider_mysql_handler::append_direct_update_set(
|
|||
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
|
||||
}
|
||||
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
|
||||
#else
|
||||
DBUG_ASSERT(0);
|
||||
#endif
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
|
@ -5967,10 +6149,12 @@ int spider_mysql_handler::append_minimum_select(
|
|||
int field_length;
|
||||
bool appended = FALSE;
|
||||
DBUG_ENTER("spider_mysql_handler::append_minimum_select");
|
||||
minimum_select_bitmap_create();
|
||||
for (field = table->field; *field; field++)
|
||||
{
|
||||
if (minimum_select_bit_is_set((*field)->field_index))
|
||||
{
|
||||
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||
field_length =
|
||||
mysql_share->column_name_str[(*field)->field_index].length();
|
||||
if (str->reserve(field_length +
|
||||
|
|
@ -6052,10 +6236,12 @@ int spider_mysql_handler::append_minimum_select_with_alias(
|
|||
int field_length;
|
||||
bool appended = FALSE;
|
||||
DBUG_ENTER("spider_mysql_handler::append_minimum_select_with_alias");
|
||||
minimum_select_bitmap_create();
|
||||
for (field = table->field; *field; field++)
|
||||
{
|
||||
if (minimum_select_bit_is_set((*field)->field_index))
|
||||
{
|
||||
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||
field_length =
|
||||
mysql_share->column_name_str[(*field)->field_index].length();
|
||||
if (str->reserve(alias_length + field_length +
|
||||
|
|
@ -6578,7 +6764,8 @@ int spider_mysql_handler::append_is_null_part(
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
) {
|
||||
int error_num;
|
||||
spider_string *str, *str_part = NULL, *str_part2 = NULL;
|
||||
|
|
@ -6605,7 +6792,7 @@ int spider_mysql_handler::append_is_null_part(
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
error_num = append_is_null(sql_type, str, str_part, str_part2,
|
||||
key_part, key, ptr, key_eq);
|
||||
key_part, key, ptr, key_eq, tgt_final);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
@ -6617,32 +6804,54 @@ int spider_mysql_handler::append_is_null(
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
) {
|
||||
DBUG_ENTER("spider_mysql_handler::append_is_null");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
DBUG_PRINT("info",("spider key_eq=%s", key_eq ? "TRUE" : "FALSE"));
|
||||
if (key_part->null_bit)
|
||||
{
|
||||
if (*(*ptr)++)
|
||||
{
|
||||
if (sql_type == SPIDER_SQL_TYPE_HANDLER)
|
||||
{
|
||||
str = str_part;
|
||||
if (
|
||||
key_eq ||
|
||||
key->flag == HA_READ_KEY_EXACT ||
|
||||
key->flag == HA_READ_KEY_OR_NEXT
|
||||
) {
|
||||
if (str->reserve(SPIDER_SQL_IS_NULL_LEN))
|
||||
if (tgt_final)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_EQUAL_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_IS_NULL_STR, SPIDER_SQL_IS_NULL_LEN);
|
||||
str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN);
|
||||
}
|
||||
str = str_part;
|
||||
if (str->reserve(SPIDER_SQL_NULL_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN);
|
||||
} else {
|
||||
if (str_part->length() == SPIDER_SQL_OPEN_PAREN_LEN)
|
||||
{
|
||||
str = str_part;
|
||||
/* first index column */
|
||||
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
|
||||
ha_next_pos = str->length();
|
||||
if (str->reserve(SPIDER_SQL_FIRST_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_FIRST_STR, SPIDER_SQL_FIRST_LEN);
|
||||
spider->result_list.ha_read_kind = 1;
|
||||
} else if (tgt_final)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_GT_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN);
|
||||
str = str_part;
|
||||
if (str->reserve(SPIDER_SQL_NULL_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN);
|
||||
}
|
||||
}
|
||||
str = str_part2;
|
||||
}
|
||||
|
|
@ -6916,11 +7125,18 @@ int spider_mysql_handler::append_condition_part(
|
|||
}
|
||||
ha_where_pos = str->length();
|
||||
|
||||
if (
|
||||
spider->sql_command == SQLCOM_HA_READ ||
|
||||
!spider->result_list.use_both_key
|
||||
) {
|
||||
if (sql_part2.length())
|
||||
{
|
||||
str->append(sql_part2);
|
||||
start_where = FALSE;
|
||||
}
|
||||
} else {
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -7245,6 +7461,37 @@ void spider_mysql_handler::set_order_to_pos(
|
|||
}
|
||||
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
int spider_mysql_handler::append_group_by_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
ulong sql_type
|
||||
) {
|
||||
int error_num;
|
||||
spider_string *str;
|
||||
DBUG_ENTER("spider_mysql_handler::append_group_by_part");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
switch (sql_type)
|
||||
{
|
||||
case SPIDER_SQL_TYPE_SELECT_SQL:
|
||||
case SPIDER_SQL_TYPE_TMP_SQL:
|
||||
str = &sql;
|
||||
break;
|
||||
case SPIDER_SQL_TYPE_INSERT_SQL:
|
||||
case SPIDER_SQL_TYPE_UPDATE_SQL:
|
||||
case SPIDER_SQL_TYPE_DELETE_SQL:
|
||||
case SPIDER_SQL_TYPE_BULK_UPDATE_SQL:
|
||||
str = &update_sql;
|
||||
break;
|
||||
case SPIDER_SQL_TYPE_HANDLER:
|
||||
str = &ha_sql;
|
||||
break;
|
||||
default:
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
error_num = append_group_by(str, alias, alias_length);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
int spider_mysql_handler::append_group_by(
|
||||
spider_string *str,
|
||||
const char *alias,
|
||||
|
|
@ -9664,6 +9911,14 @@ int spider_mysql_handler::show_table_status(
|
|||
request_key.handler = spider;
|
||||
request_key.request_id = 1;
|
||||
request_key.next = NULL;
|
||||
if (spider_param_dry_access())
|
||||
{
|
||||
conn->mta_conn_mutex_lock_already = FALSE;
|
||||
conn->mta_conn_mutex_unlock_later = FALSE;
|
||||
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
pthread_mutex_unlock(&conn->mta_conn_mutex);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
|
||||
{
|
||||
conn->mta_conn_mutex_lock_already = FALSE;
|
||||
|
|
@ -9789,6 +10044,14 @@ int spider_mysql_handler::show_table_status(
|
|||
request_key.handler = spider;
|
||||
request_key.request_id = 1;
|
||||
request_key.next = NULL;
|
||||
if (spider_param_dry_access())
|
||||
{
|
||||
conn->mta_conn_mutex_lock_already = FALSE;
|
||||
conn->mta_conn_mutex_unlock_later = FALSE;
|
||||
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
pthread_mutex_unlock(&conn->mta_conn_mutex);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
|
||||
{
|
||||
conn->mta_conn_mutex_lock_already = FALSE;
|
||||
|
|
@ -10239,7 +10502,7 @@ int spider_mysql_handler::show_records(
|
|||
pthread_mutex_unlock(&conn->mta_conn_mutex);
|
||||
error_num = res->fetch_table_records(
|
||||
1,
|
||||
share->records
|
||||
spider->table_rows
|
||||
);
|
||||
res->free_result();
|
||||
delete res;
|
||||
|
|
@ -10907,12 +11170,49 @@ bool spider_mysql_handler::support_use_handler(
|
|||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
bool spider_mysql_handler::minimum_select_bit_is_set(
|
||||
uint field_index
|
||||
) {
|
||||
void spider_mysql_handler::minimum_select_bitmap_create()
|
||||
{
|
||||
TABLE *table = spider->get_table();
|
||||
DBUG_ENTER("spider_mysql_handler::minimum_select_bit_is_set");
|
||||
Field **field_p;
|
||||
DBUG_ENTER("spider_mysql_handler::minimum_select_bitmap_create");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set));
|
||||
if (
|
||||
spider->has_clone_for_merge ||
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
(spider->is_clone && !spider->is_bulk_access_clone)
|
||||
#else
|
||||
spider->is_clone
|
||||
#endif
|
||||
) {
|
||||
/* need preparing for cmp_ref */
|
||||
TABLE_SHARE *table_share = table->s;
|
||||
if (
|
||||
table_share->primary_key == MAX_KEY
|
||||
) {
|
||||
/* need all columns */
|
||||
memset(minimum_select_bitmap, 0xFF, no_bytes_in_map(table->read_set));
|
||||
DBUG_VOID_RETURN;
|
||||
} else {
|
||||
/* need primary key columns */
|
||||
uint roop_count;
|
||||
KEY *key_info;
|
||||
KEY_PART_INFO *key_part;
|
||||
Field *field;
|
||||
key_info = &table_share->key_info[table_share->primary_key];
|
||||
key_part = key_info->key_part;
|
||||
for (roop_count = 0;
|
||||
roop_count < spider_user_defined_key_parts(key_info);
|
||||
roop_count++)
|
||||
{
|
||||
field = key_part[roop_count].field;
|
||||
spider_set_bit(minimum_select_bitmap, field->field_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
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) ?
|
||||
|
|
@ -10926,14 +11226,30 @@ bool spider_mysql_handler::minimum_select_bit_is_set(
|
|||
DBUG_PRINT("info",("spider write_set=%s",
|
||||
bitmap_is_set(table->write_set, field_index) ?
|
||||
"TRUE" : "FALSE"));
|
||||
DBUG_RETURN(
|
||||
if (
|
||||
spider_bit_is_set(spider->ft_discard_bitmap, field_index) &
|
||||
(
|
||||
spider_bit_is_set(spider->searched_bitmap, field_index) |
|
||||
bitmap_is_set(table->read_set, field_index) |
|
||||
bitmap_is_set(table->write_set, field_index)
|
||||
)
|
||||
);
|
||||
) {
|
||||
spider_set_bit(minimum_select_bitmap, field_index);
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
bool spider_mysql_handler::minimum_select_bit_is_set(
|
||||
uint field_index
|
||||
) {
|
||||
DBUG_ENTER("spider_mysql_handler::minimum_select_bit_is_set");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
DBUG_PRINT("info",("spider field_index=%u", field_index));
|
||||
DBUG_PRINT("info",("spider minimum_select_bitmap=%s",
|
||||
spider_bit_is_set(minimum_select_bitmap, field_index) ?
|
||||
"TRUE" : "FALSE"));
|
||||
DBUG_RETURN(spider_bit_is_set(minimum_select_bitmap, field_index));
|
||||
}
|
||||
|
||||
void spider_mysql_handler::copy_minimum_select_bitmap(
|
||||
|
|
@ -10947,23 +11263,10 @@ void spider_mysql_handler::copy_minimum_select_bitmap(
|
|||
roop_count++)
|
||||
{
|
||||
bitmap[roop_count] =
|
||||
spider->ft_discard_bitmap[roop_count] &
|
||||
(
|
||||
spider->searched_bitmap[roop_count] |
|
||||
((uchar *) table->read_set->bitmap)[roop_count] |
|
||||
((uchar *) table->write_set->bitmap)[roop_count]
|
||||
);
|
||||
minimum_select_bitmap[roop_count];
|
||||
DBUG_PRINT("info",("spider roop_count=%d", roop_count));
|
||||
DBUG_PRINT("info",("spider bitmap=%d",
|
||||
bitmap[roop_count]));
|
||||
DBUG_PRINT("info",("spider ft_discard_bitmap=%d",
|
||||
spider->ft_discard_bitmap[roop_count]));
|
||||
DBUG_PRINT("info",("spider searched_bitmap=%d",
|
||||
spider->searched_bitmap[roop_count]));
|
||||
DBUG_PRINT("info",("spider read_set=%d",
|
||||
((uchar *) table->read_set->bitmap)[roop_count]));
|
||||
DBUG_PRINT("info",("spider write_set=%d",
|
||||
((uchar *) table->write_set->bitmap)[roop_count]));
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2012-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2012-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -271,6 +271,9 @@ public:
|
|||
bool is_xa_nota_error(
|
||||
int error_num
|
||||
);
|
||||
void print_warnings(
|
||||
struct tm *l_time
|
||||
);
|
||||
spider_db_result *store_result(
|
||||
spider_db_result_buffer **spider_res_buf,
|
||||
st_spider_db_request_key *request_key,
|
||||
|
|
@ -539,6 +542,7 @@ class spider_mysql_handler: public spider_db_handler
|
|||
public:
|
||||
spider_mysql_share *mysql_share;
|
||||
SPIDER_LINK_FOR_HASH *link_for_hash;
|
||||
uchar *minimum_select_bitmap;
|
||||
spider_mysql_handler(
|
||||
ha_spider *spider,
|
||||
spider_mysql_share *share
|
||||
|
|
@ -787,7 +791,8 @@ public:
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
);
|
||||
int append_is_null(
|
||||
ulong sql_type,
|
||||
|
|
@ -797,7 +802,8 @@ public:
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
);
|
||||
int append_where_terminator_part(
|
||||
ulong sql_type,
|
||||
|
|
@ -877,6 +883,11 @@ public:
|
|||
ulong sql_type
|
||||
);
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
int append_group_by_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
ulong sql_type
|
||||
);
|
||||
int append_group_by(
|
||||
spider_string *str,
|
||||
const char *alias,
|
||||
|
|
@ -1277,6 +1288,7 @@ public:
|
|||
bool support_use_handler(
|
||||
int use_handler
|
||||
);
|
||||
void minimum_select_bitmap_create();
|
||||
bool minimum_select_bit_is_set(
|
||||
uint field_index
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2012-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2012-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -1311,7 +1311,8 @@ int spider_db_oracle::connect(
|
|||
this->connect_retry_interval = connect_retry_interval;
|
||||
if ((error_num = spider_create_conn_thread(conn)))
|
||||
DBUG_RETURN(error_num);
|
||||
spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_CONNECT);
|
||||
spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_CONNECT, TRUE, NULL,
|
||||
0, NULL);
|
||||
|
||||
if (stored_error_num)
|
||||
{
|
||||
|
|
@ -1401,7 +1402,8 @@ void spider_db_oracle::disconnect()
|
|||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (!conn->bg_init)
|
||||
DBUG_VOID_RETURN;
|
||||
spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_DISCONNECT);
|
||||
spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_DISCONNECT, TRUE, NULL,
|
||||
0, NULL);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
|
@ -3548,10 +3550,15 @@ int spider_db_oracle_util::open_item_func(
|
|||
func_name_length = strlen(func_name);
|
||||
DBUG_PRINT("info",("spider func_name = %s", func_name));
|
||||
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
|
||||
if (str->reserve(SPIDER_SQL_MBR_LEN + func_name_length +
|
||||
SPIDER_SQL_OPEN_PAREN_LEN))
|
||||
if (str->reserve(
|
||||
#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
|
||||
SPIDER_SQL_MBR_LEN +
|
||||
#endif
|
||||
func_name_length + SPIDER_SQL_OPEN_PAREN_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
|
||||
str->q_append(SPIDER_SQL_MBR_STR, SPIDER_SQL_MBR_LEN);
|
||||
#endif
|
||||
str->q_append(func_name, func_name_length);
|
||||
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
|
||||
}
|
||||
|
|
@ -4773,6 +4780,7 @@ int spider_oracle_handler::init()
|
|||
st_spider_share *share = spider->share;
|
||||
int init_sql_alloc_size =
|
||||
spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size);
|
||||
TABLE *table = spider->get_table();
|
||||
DBUG_ENTER("spider_oracle_handler::init");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
sql.init_calc_mem(67);
|
||||
|
|
@ -4804,6 +4812,8 @@ int spider_oracle_handler::init()
|
|||
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
|
||||
&link_for_hash,
|
||||
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
|
||||
&minimum_select_bitmap,
|
||||
table ? sizeof(uchar) * no_bytes_in_map(table->read_set) : 0,
|
||||
NullS))
|
||||
) {
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
|
@ -5047,14 +5057,24 @@ int spider_oracle_handler::append_tmp_table_and_sql_for_bka(
|
|||
table_dot_aliases, table_dot_alias_lengths)) ||
|
||||
(error_num = append_condition_part(
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN,
|
||||
SPIDER_SQL_TYPE_SELECT_SQL, FALSE)) ||
|
||||
(
|
||||
spider->result_list.direct_order_limit &&
|
||||
(error_num = append_key_order_for_direct_order_limit_with_alias(&sql,
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))
|
||||
)
|
||||
SPIDER_SQL_TYPE_SELECT_SQL, FALSE))
|
||||
)
|
||||
DBUG_RETURN(error_num);
|
||||
if (spider->result_list.direct_order_limit)
|
||||
{
|
||||
if ((error_num = append_key_order_for_direct_order_limit_with_alias(&sql,
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
else if (spider->result_list.direct_aggregate)
|
||||
{
|
||||
if ((error_num =
|
||||
append_group_by(&sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#endif
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
|
@ -5257,14 +5277,24 @@ int spider_oracle_handler::append_union_table_and_sql_for_bka(
|
|||
table_dot_aliases, table_dot_alias_lengths)) ||
|
||||
(error_num = append_condition_part(
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN,
|
||||
SPIDER_SQL_TYPE_TMP_SQL, FALSE)) ||
|
||||
(
|
||||
spider->result_list.direct_order_limit &&
|
||||
(error_num = append_key_order_for_direct_order_limit_with_alias(&tmp_sql,
|
||||
SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))
|
||||
)
|
||||
SPIDER_SQL_TYPE_TMP_SQL, FALSE))
|
||||
)
|
||||
DBUG_RETURN(error_num);
|
||||
if (spider->result_list.direct_order_limit)
|
||||
{
|
||||
if ((error_num = append_key_order_for_direct_order_limit_with_alias(
|
||||
&tmp_sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
else if (spider->result_list.direct_aggregate)
|
||||
{
|
||||
if ((error_num =
|
||||
append_group_by(&tmp_sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
#endif
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
|
@ -5694,10 +5724,12 @@ int spider_oracle_handler::append_direct_update_set_part()
|
|||
int spider_oracle_handler::append_direct_update_set(
|
||||
spider_string *str
|
||||
) {
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
uint field_name_length;
|
||||
SPIDER_SHARE *share = spider->share;
|
||||
#ifndef DBUG_OFF
|
||||
TABLE *table = spider->get_table();
|
||||
#endif
|
||||
#endif
|
||||
DBUG_ENTER("spider_oracle_handler::append_direct_update_set");
|
||||
if (
|
||||
|
|
@ -5713,6 +5745,7 @@ int spider_oracle_handler::append_direct_update_set(
|
|||
if (
|
||||
(spider->direct_update_kinds & SPIDER_SQL_KIND_SQL)
|
||||
) {
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
size_t roop_count;
|
||||
Field *field;
|
||||
if (str->reserve(SPIDER_SQL_SET_LEN))
|
||||
|
|
@ -5764,6 +5797,9 @@ int spider_oracle_handler::append_direct_update_set(
|
|||
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
|
||||
}
|
||||
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
|
||||
#else
|
||||
DBUG_ASSERT(0);
|
||||
#endif
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
|
@ -5981,10 +6017,12 @@ int spider_oracle_handler::append_minimum_select(
|
|||
int field_length;
|
||||
bool appended = FALSE;
|
||||
DBUG_ENTER("spider_oracle_handler::append_minimum_select");
|
||||
minimum_select_bitmap_create();
|
||||
for (field = table->field; *field; field++)
|
||||
{
|
||||
if (minimum_select_bit_is_set((*field)->field_index))
|
||||
{
|
||||
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||
field_length =
|
||||
oracle_share->column_name_str[(*field)->field_index].length();
|
||||
if (str->reserve(field_length +
|
||||
|
|
@ -6066,10 +6104,12 @@ int spider_oracle_handler::append_minimum_select_with_alias(
|
|||
int field_length;
|
||||
bool appended = FALSE;
|
||||
DBUG_ENTER("spider_oracle_handler::append_minimum_select_with_alias");
|
||||
minimum_select_bitmap_create();
|
||||
for (field = table->field; *field; field++)
|
||||
{
|
||||
if (minimum_select_bit_is_set((*field)->field_index))
|
||||
{
|
||||
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||
field_length =
|
||||
oracle_share->column_name_str[(*field)->field_index].length();
|
||||
if (str->reserve(alias_length + field_length +
|
||||
|
|
@ -6592,7 +6632,8 @@ int spider_oracle_handler::append_is_null_part(
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
) {
|
||||
int error_num;
|
||||
spider_string *str, *str_part = NULL, *str_part2 = NULL;
|
||||
|
|
@ -6619,7 +6660,7 @@ int spider_oracle_handler::append_is_null_part(
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
error_num = append_is_null(sql_type, str, str_part, str_part2,
|
||||
key_part, key, ptr, key_eq);
|
||||
key_part, key, ptr, key_eq, tgt_final);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
@ -6631,7 +6672,8 @@ int spider_oracle_handler::append_is_null(
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
) {
|
||||
DBUG_ENTER("spider_oracle_handler::append_is_null");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
|
|
@ -7272,6 +7314,37 @@ void spider_oracle_handler::set_order_to_pos(
|
|||
}
|
||||
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
int spider_oracle_handler::append_group_by_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
ulong sql_type
|
||||
) {
|
||||
int error_num;
|
||||
spider_string *str;
|
||||
DBUG_ENTER("spider_oracle_handler::append_group_by_part");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
switch (sql_type)
|
||||
{
|
||||
case SPIDER_SQL_TYPE_SELECT_SQL:
|
||||
case SPIDER_SQL_TYPE_TMP_SQL:
|
||||
str = &sql;
|
||||
break;
|
||||
case SPIDER_SQL_TYPE_INSERT_SQL:
|
||||
case SPIDER_SQL_TYPE_UPDATE_SQL:
|
||||
case SPIDER_SQL_TYPE_DELETE_SQL:
|
||||
case SPIDER_SQL_TYPE_BULK_UPDATE_SQL:
|
||||
str = &update_sql;
|
||||
break;
|
||||
case SPIDER_SQL_TYPE_HANDLER:
|
||||
str = &ha_sql;
|
||||
break;
|
||||
default:
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
error_num = append_group_by(str, alias, alias_length);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
int spider_oracle_handler::append_group_by(
|
||||
spider_string *str,
|
||||
const char *alias,
|
||||
|
|
@ -10714,7 +10787,7 @@ int spider_oracle_handler::show_records(
|
|||
pthread_mutex_unlock(&conn->mta_conn_mutex);
|
||||
error_num = res->fetch_table_records(
|
||||
1,
|
||||
share->records
|
||||
spider->table_rows
|
||||
);
|
||||
res->free_result();
|
||||
delete res;
|
||||
|
|
@ -11538,16 +11611,68 @@ bool spider_oracle_handler::support_use_handler(
|
|||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
bool spider_oracle_handler::minimum_select_bit_is_set(
|
||||
uint field_index
|
||||
) {
|
||||
void spider_oracle_handler::minimum_select_bitmap_create()
|
||||
{
|
||||
TABLE *table = spider->get_table();
|
||||
DBUG_ENTER("spider_oracle_handler::minimum_select_bit_is_set");
|
||||
DBUG_RETURN(
|
||||
Field **field_p;
|
||||
DBUG_ENTER("spider_oracle_handler::minimum_select_bitmap_create");
|
||||
memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set));
|
||||
if (
|
||||
spider->has_clone_for_merge ||
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
(spider->is_clone && !spider->is_bulk_access_clone)
|
||||
#else
|
||||
spider->is_clone
|
||||
#endif
|
||||
) {
|
||||
/* need preparing for cmp_ref */
|
||||
TABLE_SHARE *table_share = table->s;
|
||||
if (
|
||||
table_share->primary_key == MAX_KEY
|
||||
) {
|
||||
/* need all columns */
|
||||
memset(minimum_select_bitmap, 0xFF, no_bytes_in_map(table->read_set));
|
||||
DBUG_VOID_RETURN;
|
||||
} else {
|
||||
/* need primary key columns */
|
||||
uint roop_count;
|
||||
KEY *key_info;
|
||||
KEY_PART_INFO *key_part;
|
||||
Field *field;
|
||||
key_info = &table_share->key_info[table_share->primary_key];
|
||||
key_part = key_info->key_part;
|
||||
for (roop_count = 0;
|
||||
roop_count < spider_user_defined_key_parts(key_info);
|
||||
roop_count++)
|
||||
{
|
||||
field = key_part[roop_count].field;
|
||||
spider_set_bit(minimum_select_bitmap, field->field_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (field_p = table->field; *field_p; field_p++)
|
||||
{
|
||||
uint field_index = (*field_p)->field_index;
|
||||
if (
|
||||
spider_bit_is_set(spider->searched_bitmap, field_index) |
|
||||
bitmap_is_set(table->read_set, field_index) |
|
||||
bitmap_is_set(table->write_set, field_index)
|
||||
);
|
||||
) {
|
||||
spider_set_bit(minimum_select_bitmap, field_index);
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
bool spider_oracle_handler::minimum_select_bit_is_set(
|
||||
uint field_index
|
||||
) {
|
||||
DBUG_ENTER("spider_oracle_handler::minimum_select_bit_is_set");
|
||||
DBUG_PRINT("info",("spider field_index=%u", field_index));
|
||||
DBUG_PRINT("info",("spider minimum_select_bitmap=%s",
|
||||
spider_bit_is_set(minimum_select_bitmap, field_index) ?
|
||||
"TRUE" : "FALSE"));
|
||||
DBUG_RETURN(spider_bit_is_set(minimum_select_bitmap, field_index));
|
||||
}
|
||||
|
||||
void spider_oracle_handler::copy_minimum_select_bitmap(
|
||||
|
|
@ -11561,18 +11686,10 @@ void spider_oracle_handler::copy_minimum_select_bitmap(
|
|||
roop_count++)
|
||||
{
|
||||
bitmap[roop_count] =
|
||||
spider->searched_bitmap[roop_count] |
|
||||
((uchar *) table->read_set->bitmap)[roop_count] |
|
||||
((uchar *) table->write_set->bitmap)[roop_count];
|
||||
minimum_select_bitmap[roop_count];
|
||||
DBUG_PRINT("info",("spider roop_count=%d", roop_count));
|
||||
DBUG_PRINT("info",("spider bitmap=%d",
|
||||
bitmap[roop_count]));
|
||||
DBUG_PRINT("info",("spider searched_bitmap=%d",
|
||||
spider->searched_bitmap[roop_count]));
|
||||
DBUG_PRINT("info",("spider read_set=%d",
|
||||
((uchar *) table->read_set->bitmap)[roop_count]));
|
||||
DBUG_PRINT("info",("spider write_set=%d",
|
||||
((uchar *) table->write_set->bitmap)[roop_count]));
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2012-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2012-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -622,6 +622,7 @@ class spider_oracle_handler: public spider_db_handler
|
|||
public:
|
||||
spider_oracle_share *oracle_share;
|
||||
SPIDER_LINK_FOR_HASH *link_for_hash;
|
||||
uchar *minimum_select_bitmap;
|
||||
spider_oracle_handler(
|
||||
ha_spider *spider,
|
||||
spider_oracle_share *share
|
||||
|
|
@ -870,7 +871,8 @@ public:
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
);
|
||||
int append_is_null(
|
||||
ulong sql_type,
|
||||
|
|
@ -880,7 +882,8 @@ public:
|
|||
KEY_PART_INFO *key_part,
|
||||
const key_range *key,
|
||||
const uchar **ptr,
|
||||
bool key_eq
|
||||
bool key_eq,
|
||||
bool tgt_final
|
||||
);
|
||||
int append_where_terminator_part(
|
||||
ulong sql_type,
|
||||
|
|
@ -960,6 +963,11 @@ public:
|
|||
ulong sql_type
|
||||
);
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
int append_group_by_part(
|
||||
const char *alias,
|
||||
uint alias_length,
|
||||
ulong sql_type
|
||||
);
|
||||
int append_group_by(
|
||||
spider_string *str,
|
||||
const char *alias,
|
||||
|
|
@ -1363,6 +1371,7 @@ public:
|
|||
bool support_use_handler(
|
||||
int use_handler
|
||||
);
|
||||
void minimum_select_bitmap_create();
|
||||
bool minimum_select_bit_is_set(
|
||||
uint field_index
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2009-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2009-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -40,6 +40,10 @@
|
|||
#include "spd_udf.h"
|
||||
#include "spd_malloc.h"
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100004
|
||||
#define SPIDER_NEED_INIT_ONE_TABLE_FOR_FIND_TEMPORARY_TABLE
|
||||
#endif
|
||||
|
||||
extern const char **spd_defaults_extra_file;
|
||||
extern const char **spd_defaults_file;
|
||||
|
||||
|
|
@ -1604,8 +1608,16 @@ long long spider_direct_sql_body(
|
|||
#endif
|
||||
for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++)
|
||||
{
|
||||
#ifdef SPIDER_NEED_INIT_ONE_TABLE_FOR_FIND_TEMPORARY_TABLE
|
||||
table_list.init_one_table(direct_sql->db_names[roop_count],
|
||||
strlen(direct_sql->db_names[roop_count]),
|
||||
direct_sql->table_names[roop_count],
|
||||
strlen(direct_sql->table_names[roop_count]),
|
||||
direct_sql->table_names[roop_count], TL_WRITE);
|
||||
#else
|
||||
table_list.db = direct_sql->db_names[roop_count];
|
||||
table_list.table_name = direct_sql->table_names[roop_count];
|
||||
#endif
|
||||
if (!(direct_sql->tables[roop_count] =
|
||||
find_temporary_table(thd, &table_list)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2009-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2009-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -61,6 +61,8 @@
|
|||
#define ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR "Can't use wrapper '%s' for NOSQL connection"
|
||||
#define ER_SPIDER_REQUEST_KEY_NUM 12523
|
||||
#define ER_SPIDER_REQUEST_KEY_STR "Request key not found"
|
||||
#define ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM 12524
|
||||
#define ER_SPIDER_CANT_OPEN_SYS_TABLE_STR "Can't open system table %s.%s"
|
||||
|
||||
#define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_NUM 12601
|
||||
#define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_STR "Can't use both spider_use_consistent_snapshot = 1 and spider_internal_xa = 1"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2012-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2012-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -128,7 +128,7 @@ static int spider_i_s_alloc_mem_deinit(
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
struct st_maria_plugin spider_i_s_alloc_mem =
|
||||
struct st_mysql_plugin spider_i_s_alloc_mem =
|
||||
{
|
||||
MYSQL_INFORMATION_SCHEMA_PLUGIN,
|
||||
&spider_i_s_info,
|
||||
|
|
@ -141,6 +141,27 @@ struct st_maria_plugin spider_i_s_alloc_mem =
|
|||
0x0001,
|
||||
NULL,
|
||||
NULL,
|
||||
"0.1",
|
||||
MariaDB_PLUGIN_MATURITY_BETA
|
||||
NULL,
|
||||
#if MYSQL_VERSION_ID >= 50600
|
||||
0,
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef MARIADB_BASE_VERSION
|
||||
struct st_maria_plugin spider_i_s_alloc_mem_maria =
|
||||
{
|
||||
MYSQL_INFORMATION_SCHEMA_PLUGIN,
|
||||
&spider_i_s_info,
|
||||
"SPIDER_ALLOC_MEM",
|
||||
"Kentoku Shiba",
|
||||
"Spider memory allocating viewer",
|
||||
PLUGIN_LICENSE_GPL,
|
||||
spider_i_s_alloc_mem_init,
|
||||
spider_i_s_alloc_mem_deinit,
|
||||
0x0100,
|
||||
NULL,
|
||||
NULL,
|
||||
"1.0",
|
||||
MariaDB_PLUGIN_MATURITY_GAMMA,
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -13,6 +13,9 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define SPIDER_DETAIL_VERSION "3.2.0"
|
||||
#define SPIDER_HEX_VERSION 0x0302
|
||||
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#else
|
||||
#define my_free(A,B) my_free(A)
|
||||
|
|
@ -77,8 +80,13 @@
|
|||
#define spider_stmt_da_message(A) (A)->main_da.message()
|
||||
#define spider_stmt_da_sql_errno(A) (A)->main_da.sql_errno()
|
||||
#else
|
||||
#if MYSQL_VERSION_ID < 50600
|
||||
#define spider_stmt_da_message(A) (A)->stmt_da->message()
|
||||
#define spider_stmt_da_sql_errno(A) (A)->stmt_da->sql_errno()
|
||||
#else
|
||||
#define spider_stmt_da_message(A) (A)->get_stmt_da()->message()
|
||||
#define spider_stmt_da_sql_errno(A) (A)->get_stmt_da()->sql_errno()
|
||||
#endif
|
||||
#endif
|
||||
#define spider_user_defined_key_parts(A) (A)->key_parts
|
||||
#define SPIDER_ALTER_ADD_PARTITION ALTER_ADD_PARTITION
|
||||
|
|
@ -91,6 +99,12 @@
|
|||
#define SPIDER_WARN_LEVEL_NOTE MYSQL_ERROR::WARN_LEVEL_NOTE
|
||||
#endif
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100009
|
||||
#define SPIDER_TEST(A) MY_TEST(A)
|
||||
#else
|
||||
#define SPIDER_TEST(A) test(A)
|
||||
#endif
|
||||
|
||||
#if MYSQL_VERSION_ID >= 50500
|
||||
#define SPIDER_HAS_HASH_VALUE_TYPE
|
||||
#endif
|
||||
|
|
@ -118,7 +132,7 @@
|
|||
#define SPIDER_TMP_SHARE_LONG_COUNT 15
|
||||
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
|
||||
|
||||
#define SPIDER_MEM_CALC_LIST_NUM 243
|
||||
#define SPIDER_MEM_CALC_LIST_NUM 244
|
||||
|
||||
#define SPIDER_BACKUP_DASTATUS \
|
||||
bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE;
|
||||
|
|
@ -134,7 +148,7 @@
|
|||
#define SPIDER_SET_FILE_POS(A) \
|
||||
{(A)->thd = current_thd; (A)->func_name = __func__; (A)->file_name = __FILE__; (A)->line_no = __LINE__;}
|
||||
#define SPIDER_CLEAR_FILE_POS(A) \
|
||||
{(A)->thd = NULL; (A)->func_name = NULL; (A)->file_name = NULL; (A)->line_no = 0;}
|
||||
{DBUG_PRINT("info", ("spider thd=%p func_name=%s file_name=%s line_no=%lu", (A)->thd, (A)->func_name ? (A)->func_name : "NULL", (A)->file_name ? (A)->file_name : "NULL", (A)->line_no)); (A)->thd = NULL; (A)->func_name = NULL; (A)->file_name = NULL; (A)->line_no = 0;}
|
||||
|
||||
class ha_spider;
|
||||
typedef struct st_spider_share SPIDER_SHARE;
|
||||
|
|
@ -261,6 +275,9 @@ typedef struct st_spider_conn
|
|||
uint opened_handlers;
|
||||
ulonglong conn_id;
|
||||
ulonglong connection_id;
|
||||
query_id_t casual_read_query_id;
|
||||
uint casual_read_current_id;
|
||||
st_spider_conn *casual_read_base_conn;
|
||||
pthread_mutex_t mta_conn_mutex;
|
||||
volatile bool mta_conn_mutex_lock_already;
|
||||
volatile bool mta_conn_mutex_unlock_later;
|
||||
|
|
@ -473,6 +490,7 @@ typedef struct st_spider_transaction
|
|||
bool trx_start;
|
||||
bool trx_xa;
|
||||
bool trx_consistent_snapshot;
|
||||
bool trx_xa_prepared;
|
||||
|
||||
bool use_consistent_snapshot;
|
||||
bool internal_xa;
|
||||
|
|
@ -571,6 +589,18 @@ typedef struct st_spider_transaction
|
|||
longlong current_alloc_mem_buffer[SPIDER_MEM_CALC_LIST_NUM];
|
||||
ulonglong alloc_mem_count_buffer[SPIDER_MEM_CALC_LIST_NUM];
|
||||
ulonglong free_mem_count_buffer[SPIDER_MEM_CALC_LIST_NUM];
|
||||
|
||||
MEM_ROOT mem_root;
|
||||
|
||||
/* for transaction level query */
|
||||
SPIDER_SHARE *tmp_share;
|
||||
char *tmp_connect_info[SPIDER_TMP_SHARE_CHAR_PTR_COUNT];
|
||||
uint tmp_connect_info_length[SPIDER_TMP_SHARE_UINT_COUNT];
|
||||
long tmp_long[SPIDER_TMP_SHARE_LONG_COUNT];
|
||||
longlong tmp_longlong[SPIDER_TMP_SHARE_LONGLONG_COUNT];
|
||||
ha_spider *tmp_spider;
|
||||
int tmp_need_mon;
|
||||
spider_db_handler *tmp_dbton_handler[SPIDER_DBTON_SIZE];
|
||||
} SPIDER_TRX;
|
||||
|
||||
typedef struct st_spider_share
|
||||
|
|
@ -734,6 +764,8 @@ typedef struct st_spider_share
|
|||
#ifdef HA_CAN_FORCE_BULK_DELETE
|
||||
int force_bulk_delete;
|
||||
#endif
|
||||
int casual_read;
|
||||
int delete_all_rows_type;
|
||||
|
||||
int bka_mode;
|
||||
char *bka_engine;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2012-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2012-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2012-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2012-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -32,7 +32,10 @@
|
|||
#include "spd_table.h"
|
||||
#include "spd_trx.h"
|
||||
|
||||
extern struct st_maria_plugin spider_i_s_alloc_mem;
|
||||
extern struct st_mysql_plugin spider_i_s_alloc_mem;
|
||||
#ifdef MARIADB_BASE_VERSION
|
||||
extern struct st_maria_plugin spider_i_s_alloc_mem_maria;
|
||||
#endif
|
||||
|
||||
extern volatile ulonglong spider_mon_table_cache_version;
|
||||
extern volatile ulonglong spider_mon_table_cache_version_req;
|
||||
|
|
@ -2827,6 +2830,136 @@ uint spider_param_log_result_errors()
|
|||
DBUG_RETURN(spider_log_result_errors);
|
||||
}
|
||||
|
||||
static uint spider_log_result_error_with_sql;
|
||||
/*
|
||||
0: no log
|
||||
1: log spider sql at logging result errors
|
||||
2: log user sql at logging result errors
|
||||
3: log both sql at logging result errors
|
||||
*/
|
||||
static MYSQL_SYSVAR_UINT(
|
||||
log_result_error_with_sql,
|
||||
spider_log_result_error_with_sql,
|
||||
PLUGIN_VAR_RQCMDARG,
|
||||
"Log sql at logging result errors",
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
3,
|
||||
0
|
||||
);
|
||||
|
||||
uint spider_param_log_result_error_with_sql()
|
||||
{
|
||||
DBUG_ENTER("spider_param_log_result_error_with_sql");
|
||||
DBUG_RETURN(spider_log_result_error_with_sql);
|
||||
}
|
||||
|
||||
static char *spider_version = (char *) SPIDER_DETAIL_VERSION;
|
||||
static MYSQL_SYSVAR_STR(
|
||||
version,
|
||||
spider_version,
|
||||
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
|
||||
"The version of Spider",
|
||||
NULL,
|
||||
NULL,
|
||||
SPIDER_DETAIL_VERSION
|
||||
);
|
||||
|
||||
/*
|
||||
0: server_id + thread_id
|
||||
1: server_id + thread_id + query_id
|
||||
*/
|
||||
static MYSQL_THDVAR_UINT(
|
||||
internal_xa_id_type, /* name */
|
||||
PLUGIN_VAR_RQCMDARG, /* opt */
|
||||
"The type of internal_xa id", /* comment */
|
||||
NULL, /* check */
|
||||
NULL, /* update */
|
||||
0, /* def */
|
||||
0, /* min */
|
||||
1, /* max */
|
||||
0 /* blk */
|
||||
);
|
||||
|
||||
uint spider_param_internal_xa_id_type(
|
||||
THD *thd
|
||||
) {
|
||||
DBUG_ENTER("spider_param_internal_xa_id_type");
|
||||
DBUG_RETURN(THDVAR(thd, internal_xa_id_type));
|
||||
}
|
||||
|
||||
/*
|
||||
-1 :use table parameter
|
||||
0 :OFF
|
||||
1 :automatic channel
|
||||
2-63 :use custom channel
|
||||
*/
|
||||
static MYSQL_THDVAR_INT(
|
||||
casual_read, /* name */
|
||||
PLUGIN_VAR_RQCMDARG, /* opt */
|
||||
"Read casually if it is possible", /* comment */
|
||||
NULL, /* check */
|
||||
NULL, /* update */
|
||||
-1, /* def */
|
||||
-1, /* min */
|
||||
63, /* max */
|
||||
0 /* blk */
|
||||
);
|
||||
|
||||
int spider_param_casual_read(
|
||||
THD *thd,
|
||||
int casual_read
|
||||
) {
|
||||
DBUG_ENTER("spider_param_casual_read");
|
||||
DBUG_RETURN(THDVAR(thd, casual_read) == -1 ?
|
||||
casual_read : THDVAR(thd, casual_read));
|
||||
}
|
||||
|
||||
static my_bool spider_dry_access;
|
||||
static MYSQL_SYSVAR_BOOL(
|
||||
dry_access,
|
||||
spider_dry_access,
|
||||
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
|
||||
"dry access",
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE
|
||||
);
|
||||
|
||||
my_bool spider_param_dry_access()
|
||||
{
|
||||
DBUG_ENTER("spider_param_dry_access");
|
||||
DBUG_RETURN(spider_dry_access);
|
||||
}
|
||||
|
||||
/*
|
||||
-1 :use table parameter
|
||||
0 :fast
|
||||
1 :correct delete row number
|
||||
*/
|
||||
static MYSQL_THDVAR_INT(
|
||||
delete_all_rows_type, /* name */
|
||||
PLUGIN_VAR_RQCMDARG, /* opt */
|
||||
"The type of delete_all_rows", /* comment */
|
||||
NULL, /* check */
|
||||
NULL, /* update */
|
||||
-1, /* def */
|
||||
-1, /* min */
|
||||
1, /* max */
|
||||
0 /* blk */
|
||||
);
|
||||
|
||||
int spider_param_delete_all_rows_type(
|
||||
THD *thd,
|
||||
int delete_all_rows_type
|
||||
) {
|
||||
DBUG_ENTER("spider_param_delete_all_rows_type");
|
||||
DBUG_RETURN(THDVAR(thd, delete_all_rows_type) == -1 ?
|
||||
delete_all_rows_type : THDVAR(thd, delete_all_rows_type));
|
||||
}
|
||||
|
||||
static struct st_mysql_storage_engine spider_storage_engine =
|
||||
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
|
||||
|
||||
|
|
@ -2954,9 +3087,37 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
|
|||
#endif
|
||||
MYSQL_SYSVAR(general_log),
|
||||
MYSQL_SYSVAR(log_result_errors),
|
||||
MYSQL_SYSVAR(log_result_error_with_sql),
|
||||
MYSQL_SYSVAR(version),
|
||||
MYSQL_SYSVAR(internal_xa_id_type),
|
||||
MYSQL_SYSVAR(casual_read),
|
||||
MYSQL_SYSVAR(dry_access),
|
||||
MYSQL_SYSVAR(delete_all_rows_type),
|
||||
NULL
|
||||
};
|
||||
|
||||
mysql_declare_plugin(spider)
|
||||
{
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN,
|
||||
&spider_storage_engine,
|
||||
"SPIDER",
|
||||
"Kentoku Shiba",
|
||||
"Spider storage engine",
|
||||
PLUGIN_LICENSE_GPL,
|
||||
spider_db_init,
|
||||
spider_db_done,
|
||||
SPIDER_HEX_VERSION,
|
||||
spider_status_variables,
|
||||
spider_system_variables,
|
||||
NULL,
|
||||
#if MYSQL_VERSION_ID >= 50600
|
||||
0,
|
||||
#endif
|
||||
},
|
||||
spider_i_s_alloc_mem
|
||||
mysql_declare_plugin_end;
|
||||
|
||||
#ifdef MARIADB_BASE_VERSION
|
||||
maria_declare_plugin(spider)
|
||||
{
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN,
|
||||
|
|
@ -2967,11 +3128,12 @@ maria_declare_plugin(spider)
|
|||
PLUGIN_LICENSE_GPL,
|
||||
spider_db_init,
|
||||
spider_db_done,
|
||||
0x0300,
|
||||
SPIDER_HEX_VERSION,
|
||||
spider_status_variables,
|
||||
spider_system_variables,
|
||||
"3.0",
|
||||
MariaDB_PLUGIN_MATURITY_BETA
|
||||
SPIDER_DETAIL_VERSION,
|
||||
MariaDB_PLUGIN_MATURITY_GAMMA
|
||||
},
|
||||
spider_i_s_alloc_mem
|
||||
spider_i_s_alloc_mem_maria
|
||||
maria_declare_plugin_end;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -370,3 +370,16 @@ int spider_param_udf_ds_use_real_table(
|
|||
#endif
|
||||
my_bool spider_param_general_log();
|
||||
uint spider_param_log_result_errors();
|
||||
uint spider_param_log_result_error_with_sql();
|
||||
uint spider_param_internal_xa_id_type(
|
||||
THD *thd
|
||||
);
|
||||
int spider_param_casual_read(
|
||||
THD *thd,
|
||||
int casual_read
|
||||
);
|
||||
my_bool spider_param_dry_access();
|
||||
int spider_param_delete_all_rows_type(
|
||||
THD *thd,
|
||||
int delete_all_rows_type
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2009-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2009-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2009-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2009-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -90,7 +90,10 @@ TABLE *spider_open_sys_table(
|
|||
if (!(table = spider_sys_open_table(thd, &tables, open_tables_backup)))
|
||||
#endif
|
||||
{
|
||||
*error_num = my_errno;
|
||||
my_printf_error(ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM,
|
||||
ER_SPIDER_CANT_OPEN_SYS_TABLE_STR, MYF(0),
|
||||
"mysql", table_name);
|
||||
*error_num = ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM;
|
||||
DBUG_RETURN(NULL);
|
||||
}
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
|
|
@ -117,7 +120,10 @@ TABLE *spider_open_sys_table(
|
|||
table, FALSE)
|
||||
) {
|
||||
release_table_share(table_share, RELEASE_NORMAL);
|
||||
*error_num = my_errno;
|
||||
my_printf_error(ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM,
|
||||
ER_SPIDER_CANT_OPEN_SYS_TABLE_STR, MYF(0),
|
||||
"mysql", table_name);
|
||||
*error_num = ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
|
@ -1913,7 +1919,6 @@ int spider_sys_update_tables_link_status(
|
|||
SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock,
|
||||
&error_num))
|
||||
) {
|
||||
my_error(error_num, MYF(0));
|
||||
goto error;
|
||||
}
|
||||
if ((error_num = spider_update_tables_link_status(table_tables,
|
||||
|
|
@ -1952,7 +1957,6 @@ int spider_sys_log_tables_link_failed(
|
|||
SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup,
|
||||
need_lock, &error_num))
|
||||
) {
|
||||
my_error(error_num, MYF(0));
|
||||
goto error;
|
||||
}
|
||||
empty_record(table_tables);
|
||||
|
|
@ -1992,7 +1996,6 @@ int spider_sys_log_xa_failed(
|
|||
SPIDER_SYS_XA_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup,
|
||||
need_lock, &error_num))
|
||||
) {
|
||||
my_error(error_num, MYF(0));
|
||||
goto error;
|
||||
}
|
||||
empty_record(table_tables);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -43,6 +43,9 @@
|
|||
#include "spd_malloc.h"
|
||||
|
||||
ulong *spd_db_att_thread_id;
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
uint *spd_db_att_xid_cache_split_num;
|
||||
#endif
|
||||
pthread_mutex_t *spd_db_att_LOCK_xid_cache;
|
||||
HASH *spd_db_att_xid_cache;
|
||||
struct charset_info_st *spd_charset_utf8_bin;
|
||||
|
|
@ -1789,6 +1792,8 @@ int spider_parse_connect_info(
|
|||
#ifdef HA_CAN_FORCE_BULK_DELETE
|
||||
share->force_bulk_delete = -1;
|
||||
#endif
|
||||
share->casual_read = -1;
|
||||
share->delete_all_rows_type = -1;
|
||||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
for (roop_count = 4; roop_count > 0; roop_count--)
|
||||
|
|
@ -1918,6 +1923,7 @@ int spider_parse_connect_info(
|
|||
#endif
|
||||
SPIDER_PARAM_DOUBLE("civ", crd_interval, 0);
|
||||
SPIDER_PARAM_INT_WITH_MAX("cmd", crd_mode, 0, 3);
|
||||
SPIDER_PARAM_INT_WITH_MAX("csr", casual_read, 0, 63);
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
SPIDER_PARAM_INT_WITH_MAX("csy", crd_sync, 0, 2);
|
||||
#endif
|
||||
|
|
@ -1925,6 +1931,7 @@ int spider_parse_connect_info(
|
|||
2147483647);
|
||||
SPIDER_PARAM_INT_WITH_MAX("ctp", crd_type, 0, 2);
|
||||
SPIDER_PARAM_DOUBLE("cwg", crd_weight, 1);
|
||||
SPIDER_PARAM_INT_WITH_MAX("dat", delete_all_rows_type, 0, 1);
|
||||
SPIDER_PARAM_INT_WITH_MAX("ddi", direct_dup_insert, 0, 1);
|
||||
SPIDER_PARAM_STR_LIST("dff", tgt_default_files);
|
||||
SPIDER_PARAM_STR_LIST("dfg", tgt_default_groups);
|
||||
|
|
@ -2108,6 +2115,7 @@ int spider_parse_connect_info(
|
|||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
SPIDER_PARAM_LONG_LIST_WITH_MAX("use_hs_read", use_hs_reads, 0, 1);
|
||||
#endif
|
||||
SPIDER_PARAM_INT_WITH_MAX("casual_read", casual_read, 0, 63);
|
||||
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM;
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
|
||||
MYF(0), tmp_ptr);
|
||||
|
|
@ -2256,6 +2264,8 @@ int spider_parse_connect_info(
|
|||
case 20:
|
||||
SPIDER_PARAM_LONGLONG_LIST_WITH_MAX(
|
||||
"monitoring_server_id", monitoring_sid, 0, 4294967295LL);
|
||||
SPIDER_PARAM_INT_WITH_MAX(
|
||||
"delete_all_rows_type", delete_all_rows_type, 0, 1);
|
||||
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM;
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
|
||||
MYF(0), tmp_ptr);
|
||||
|
|
@ -3433,6 +3443,16 @@ int spider_set_connect_info_default(
|
|||
if (share->force_bulk_delete == -1)
|
||||
share->force_bulk_delete = 0;
|
||||
#endif
|
||||
if (share->casual_read == -1)
|
||||
share->casual_read = 0;
|
||||
if (share->delete_all_rows_type == -1)
|
||||
{
|
||||
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
|
||||
share->delete_all_rows_type = 1;
|
||||
#else
|
||||
share->delete_all_rows_type = 0;
|
||||
#endif
|
||||
}
|
||||
if (share->bka_mode == -1)
|
||||
share->bka_mode = 1;
|
||||
if (!share->bka_engine)
|
||||
|
|
@ -4320,12 +4340,15 @@ SPIDER_SHARE *spider_get_share(
|
|||
&result_list->tmp_table_created,
|
||||
sizeof(uchar) * share->link_bitmap_size,
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
&result_list->hs_r_bulk_open_index,
|
||||
sizeof(uchar) * share->link_bitmap_size,
|
||||
&result_list->hs_w_bulk_open_index,
|
||||
sizeof(uchar) * share->link_bitmap_size,
|
||||
#endif
|
||||
#endif
|
||||
&result_list->sql_kind_backup, sizeof(uint) * share->link_count,
|
||||
&result_list->casual_read, sizeof(int) * share->link_count,
|
||||
&spider->dbton_handler,
|
||||
sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE,
|
||||
NullS))
|
||||
|
|
@ -4759,12 +4782,15 @@ SPIDER_SHARE *spider_get_share(
|
|||
&result_list->tmp_table_created,
|
||||
sizeof(uchar) * share->link_bitmap_size,
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
|
||||
&result_list->hs_r_bulk_open_index,
|
||||
sizeof(uchar) * share->link_bitmap_size,
|
||||
&result_list->hs_w_bulk_open_index,
|
||||
sizeof(uchar) * share->link_bitmap_size,
|
||||
#endif
|
||||
#endif
|
||||
&result_list->sql_kind_backup, sizeof(uint) * share->link_count,
|
||||
&result_list->casual_read, sizeof(int) * share->link_count,
|
||||
&spider->dbton_handler,
|
||||
sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE,
|
||||
NullS))
|
||||
|
|
@ -5669,21 +5695,14 @@ int spider_close_connection(
|
|||
handlerton* hton,
|
||||
THD* thd
|
||||
) {
|
||||
int roop_count = 0, need_mon = 0;
|
||||
int roop_count = 0;
|
||||
SPIDER_CONN *conn;
|
||||
SPIDER_TRX *trx;
|
||||
ha_spider tmp_spider;
|
||||
char buf[MAX_FIELD_WIDTH];
|
||||
spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin);
|
||||
DBUG_ENTER("spider_close_connection");
|
||||
tmp_str.init_calc_mem(121);
|
||||
if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr)))
|
||||
DBUG_RETURN(0); /* transaction is not started */
|
||||
|
||||
tmp_spider.conns = &conn;
|
||||
tmp_spider.need_mons = &need_mon;
|
||||
tmp_spider.trx = trx;
|
||||
tmp_spider.result_list.sqls = &tmp_str;
|
||||
trx->tmp_spider->conns = &conn;
|
||||
while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash,
|
||||
roop_count)))
|
||||
{
|
||||
|
|
@ -5695,7 +5714,7 @@ int spider_close_connection(
|
|||
conn->disable_reconnect = FALSE;
|
||||
if (conn->table_lock != 2)
|
||||
{
|
||||
spider_db_unlock_tables(&tmp_spider, 0);
|
||||
spider_db_unlock_tables(trx->tmp_spider, 0);
|
||||
}
|
||||
conn->table_lock = 0;
|
||||
}
|
||||
|
|
@ -6000,6 +6019,16 @@ int spider_db_init(
|
|||
HMODULE current_module = GetModuleHandle(NULL);
|
||||
spd_db_att_thread_id = (ulong *)
|
||||
GetProcAddress(current_module, "?thread_id@@3KA");
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
spd_db_att_xid_cache_split_num = (uint *)
|
||||
GetProcAddress(current_module,
|
||||
"?opt_xid_cache_split_num@@3IA");
|
||||
spd_db_att_LOCK_xid_cache = *((pthread_mutex_t **)
|
||||
GetProcAddress(current_module,
|
||||
"?LOCK_xid_cache@@3PAUst_mysql_mutex@@A"));
|
||||
spd_db_att_xid_cache = *((HASH **)
|
||||
GetProcAddress(current_module, "?xid_cache@@3PAUst_hash@@A"));
|
||||
#else
|
||||
spd_db_att_LOCK_xid_cache = (pthread_mutex_t *)
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
GetProcAddress(current_module,
|
||||
|
|
@ -6010,6 +6039,7 @@ int spider_db_init(
|
|||
#endif
|
||||
spd_db_att_xid_cache = (HASH *)
|
||||
GetProcAddress(current_module, "?xid_cache@@3Ust_hash@@A");
|
||||
#endif
|
||||
spd_charset_utf8_bin = (struct charset_info_st *)
|
||||
GetProcAddress(current_module, "my_charset_utf8_bin");
|
||||
spd_defaults_extra_file = (const char **)
|
||||
|
|
@ -6018,8 +6048,14 @@ int spider_db_init(
|
|||
GetProcAddress(current_module, "my_defaults_file");
|
||||
#else
|
||||
spd_db_att_thread_id = &thread_id;
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
spd_db_att_xid_cache_split_num = &opt_xid_cache_split_num;
|
||||
spd_db_att_LOCK_xid_cache = LOCK_xid_cache;
|
||||
spd_db_att_xid_cache = xid_cache;
|
||||
#else
|
||||
spd_db_att_LOCK_xid_cache = &LOCK_xid_cache;
|
||||
spd_db_att_xid_cache = &xid_cache;
|
||||
#endif
|
||||
spd_charset_utf8_bin = &my_charset_utf8_bin;
|
||||
spd_defaults_extra_file = &my_defaults_extra_file;
|
||||
spd_defaults_file = &my_defaults_file;
|
||||
|
|
@ -7489,7 +7525,7 @@ longlong spider_split_read_param(
|
|||
/* This case must select by one shot */
|
||||
DBUG_PRINT("info",("spider cancel split read"));
|
||||
result_list->split_read_base = 9223372036854775807LL;
|
||||
result_list->semi_split_read = 9223372036854775807LL;
|
||||
result_list->semi_split_read = 0;
|
||||
result_list->semi_split_read_limit = 9223372036854775807LL;
|
||||
result_list->first_read = 9223372036854775807LL;
|
||||
result_list->second_read = 9223372036854775807LL;
|
||||
|
|
@ -7596,8 +7632,25 @@ bool spider_check_direct_order_limit(
|
|||
longlong select_limit;
|
||||
longlong offset_limit;
|
||||
DBUG_ENTER("spider_check_direct_order_limit");
|
||||
if (spider->sql_command != SQLCOM_HA_READ)
|
||||
{
|
||||
DBUG_PRINT("info",("spider SQLCOM_HA_READ=%s",
|
||||
(spider->sql_command == SQLCOM_HA_READ) ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider has_clone_for_merge=%s",
|
||||
spider->has_clone_for_merge ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider is_clone=%s",
|
||||
spider->is_clone ? "TRUE" : "FALSE"));
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
DBUG_PRINT("info",("spider is_bulk_access_clone=%s",
|
||||
spider->is_bulk_access_clone ? "TRUE" : "FALSE"));
|
||||
#endif
|
||||
if (
|
||||
spider->sql_command != SQLCOM_HA_READ &&
|
||||
!spider->has_clone_for_merge &&
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
(!spider->is_clone || spider->is_bulk_access_clone)
|
||||
#else
|
||||
!spider->is_clone
|
||||
#endif
|
||||
) {
|
||||
spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit);
|
||||
bool first_check = TRUE;
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
|
|
@ -7660,8 +7713,25 @@ bool spider_check_direct_order_limit(
|
|||
|
||||
longlong direct_order_limit = spider_param_direct_order_limit(thd,
|
||||
share->direct_order_limit);
|
||||
DBUG_PRINT("info",("spider direct_order_limit=%lld", direct_order_limit));
|
||||
if (direct_order_limit)
|
||||
{
|
||||
DBUG_PRINT("info",("spider first_check=%s",
|
||||
first_check ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider (select_lex->options & OPTION_FOUND_ROWS)=%s",
|
||||
(select_lex->options & OPTION_FOUND_ROWS) ? "TRUE" : "FALSE"));
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
DBUG_PRINT("info",("spider direct_aggregate=%s",
|
||||
spider->result_list.direct_aggregate ? "TRUE" : "FALSE"));
|
||||
#endif
|
||||
DBUG_PRINT("info",("spider select_lex->group_list.elements=%u",
|
||||
select_lex->group_list.elements));
|
||||
DBUG_PRINT("info",("spider select_lex->with_sum_func=%s",
|
||||
select_lex->with_sum_func ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider select_lex->having=%s",
|
||||
select_lex->having ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider select_lex->order_list.elements=%u",
|
||||
select_lex->order_list.elements));
|
||||
if (
|
||||
!first_check ||
|
||||
!select_lex->explicit_limit ||
|
||||
|
|
@ -7989,8 +8059,13 @@ int spider_discover_table_structure(
|
|||
{
|
||||
DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM);
|
||||
}
|
||||
#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE_COMMENT
|
||||
if (!(part_syntax = generate_partition_syntax(part_info, &part_syntax_len,
|
||||
FALSE, TRUE, info, NULL, NULL)))
|
||||
#else
|
||||
if (!(part_syntax = generate_partition_syntax(part_info, &part_syntax_len,
|
||||
FALSE, TRUE, info, NULL)))
|
||||
#endif
|
||||
{
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -38,11 +38,15 @@
|
|||
#include "spd_ping_table.h"
|
||||
#include "spd_malloc.h"
|
||||
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
extern uint *spd_db_att_xid_cache_split_num;
|
||||
#endif
|
||||
extern pthread_mutex_t *spd_db_att_LOCK_xid_cache;
|
||||
extern HASH *spd_db_att_xid_cache;
|
||||
extern struct charset_info_st *spd_charset_utf8_bin;
|
||||
|
||||
extern handlerton *spider_hton_ptr;
|
||||
extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE];
|
||||
pthread_mutex_t spider_thread_id_mutex;
|
||||
ulonglong spider_thread_id = 1;
|
||||
|
||||
|
|
@ -213,18 +217,15 @@ int spider_free_trx_another_conn(
|
|||
bool lock
|
||||
) {
|
||||
int error_num, tmp_error_num;
|
||||
int roop_count = 0, need_mon = 0;
|
||||
int roop_count = 0;
|
||||
SPIDER_CONN *conn;
|
||||
ha_spider tmp_spider;
|
||||
DBUG_ENTER("spider_free_trx_another_conn");
|
||||
tmp_spider.conns = &conn;
|
||||
tmp_spider.need_mons = &need_mon;
|
||||
trx->tmp_spider->conns = &conn;
|
||||
error_num = 0;
|
||||
while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_another_conn_hash,
|
||||
roop_count)))
|
||||
{
|
||||
tmp_spider.trx = trx;
|
||||
if (lock && (tmp_error_num = spider_db_unlock_tables(&tmp_spider, 0)))
|
||||
if (lock && (tmp_error_num = spider_db_unlock_tables(trx->tmp_spider, 0)))
|
||||
error_num = tmp_error_num;
|
||||
spider_free_conn_from_trx(trx, conn, TRUE, TRUE, &roop_count);
|
||||
}
|
||||
|
|
@ -352,20 +353,16 @@ int spider_trx_all_unlock_tables(
|
|||
SPIDER_TRX *trx
|
||||
) {
|
||||
int error_num;
|
||||
int roop_count = 0, need_mon = 0;
|
||||
int roop_count = 0;
|
||||
THD *thd = trx->thd;
|
||||
SPIDER_CONN *conn;
|
||||
ha_spider tmp_spider;
|
||||
DBUG_ENTER("spider_trx_all_unlock_tables");
|
||||
SPIDER_BACKUP_DASTATUS;
|
||||
memset((void*)&tmp_spider, 0, sizeof(ha_spider));
|
||||
tmp_spider.conns = &conn;
|
||||
tmp_spider.need_mons = &need_mon;
|
||||
trx->tmp_spider->conns = &conn;
|
||||
while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash,
|
||||
roop_count)))
|
||||
{
|
||||
tmp_spider.trx = trx;
|
||||
if ((error_num = spider_db_unlock_tables(&tmp_spider, 0)))
|
||||
if ((error_num = spider_db_unlock_tables(trx->tmp_spider, 0)))
|
||||
{
|
||||
SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM;
|
||||
if (error_num)
|
||||
|
|
@ -1049,6 +1046,36 @@ int spider_free_trx_alloc(
|
|||
) {
|
||||
int roop_count;
|
||||
DBUG_ENTER("spider_free_trx_alloc");
|
||||
if (trx->tmp_spider)
|
||||
{
|
||||
for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; ++roop_count)
|
||||
{
|
||||
if (trx->tmp_spider->dbton_handler[roop_count])
|
||||
{
|
||||
delete trx->tmp_spider->dbton_handler[roop_count];
|
||||
trx->tmp_spider->dbton_handler[roop_count] = NULL;
|
||||
}
|
||||
}
|
||||
if (trx->tmp_spider->result_list.sqls)
|
||||
{
|
||||
delete [] trx->tmp_spider->result_list.sqls;
|
||||
trx->tmp_spider->result_list.sqls = NULL;
|
||||
}
|
||||
delete trx->tmp_spider;
|
||||
trx->tmp_spider = NULL;
|
||||
}
|
||||
if (trx->tmp_share)
|
||||
{
|
||||
for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; ++roop_count)
|
||||
{
|
||||
if (trx->tmp_share->dbton_share[roop_count])
|
||||
{
|
||||
delete trx->tmp_share->dbton_share[roop_count];
|
||||
trx->tmp_share->dbton_share[roop_count] = NULL;
|
||||
}
|
||||
}
|
||||
spider_free_tmp_share_alloc(trx->tmp_share);
|
||||
}
|
||||
spider_db_udf_free_set_names(trx);
|
||||
for (roop_count = spider_param_udf_table_lock_mutex_count() - 1;
|
||||
roop_count >= 0; roop_count--)
|
||||
|
|
@ -1100,6 +1127,7 @@ int spider_free_trx_alloc(
|
|||
trx->trx_alter_table_hash.array.max_element *
|
||||
trx->trx_alter_table_hash.array.size_of_element);
|
||||
my_hash_free(&trx->trx_alter_table_hash);
|
||||
free_root(&trx->mem_root, MYF(0));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
|
@ -1108,8 +1136,9 @@ SPIDER_TRX *spider_get_trx(
|
|||
bool regist_allocated_thds,
|
||||
int *error_num
|
||||
) {
|
||||
int roop_count = 0;
|
||||
int roop_count = 0, roop_count2;
|
||||
SPIDER_TRX *trx;
|
||||
SPIDER_SHARE *tmp_share;
|
||||
pthread_mutex_t *udf_table_mutexes;
|
||||
DBUG_ENTER("spider_get_trx");
|
||||
|
||||
|
|
@ -1121,12 +1150,15 @@ SPIDER_TRX *spider_get_trx(
|
|||
if (!(trx = (SPIDER_TRX *)
|
||||
spider_bulk_malloc(NULL, 56, MYF(MY_WME | MY_ZEROFILL),
|
||||
&trx, sizeof(*trx),
|
||||
&tmp_share, sizeof(SPIDER_SHARE),
|
||||
&udf_table_mutexes, sizeof(pthread_mutex_t) *
|
||||
spider_param_udf_table_lock_mutex_count(),
|
||||
NullS))
|
||||
)
|
||||
goto error_alloc_trx;
|
||||
|
||||
SPD_INIT_ALLOC_ROOT(&trx->mem_root, 4096, 0, MYF(MY_WME));
|
||||
trx->tmp_share = tmp_share;
|
||||
trx->udf_table_mutexes = udf_table_mutexes;
|
||||
|
||||
for (roop_count = 0;
|
||||
|
|
@ -1263,6 +1295,79 @@ SPIDER_TRX *spider_get_trx(
|
|||
|
||||
if (thd)
|
||||
{
|
||||
spider_set_tmp_share_pointer(trx->tmp_share, trx->tmp_connect_info,
|
||||
trx->tmp_connect_info_length, trx->tmp_long, trx->tmp_longlong);
|
||||
if (
|
||||
spider_set_connect_info_default(
|
||||
trx->tmp_share,
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
NULL
|
||||
) ||
|
||||
spider_set_connect_info_default_db_table(
|
||||
trx->tmp_share,
|
||||
"", 0,
|
||||
"", 0
|
||||
) ||
|
||||
spider_create_conn_keys(trx->tmp_share)
|
||||
) {
|
||||
goto error_set_connect_info_default;
|
||||
}
|
||||
|
||||
if (!(trx->tmp_spider = new (&trx->mem_root) ha_spider()))
|
||||
{
|
||||
goto error_alloc_spider;
|
||||
}
|
||||
trx->tmp_spider->need_mons = &trx->tmp_need_mon;
|
||||
trx->tmp_spider->share = trx->tmp_share;
|
||||
trx->tmp_spider->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]))
|
||||
{
|
||||
goto error_init_result_list_sql;
|
||||
}
|
||||
for (roop_count2 = 0; roop_count2 < (int) trx->tmp_share->link_count;
|
||||
++roop_count2)
|
||||
{
|
||||
trx->tmp_spider->result_list.sqls[roop_count2].init_calc_mem(121);
|
||||
trx->tmp_spider->result_list.sqls[roop_count2].set_charset(
|
||||
trx->tmp_share->access_charset);
|
||||
}
|
||||
|
||||
for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; ++roop_count2)
|
||||
{
|
||||
if (!spider_dbton[roop_count2].init)
|
||||
continue;
|
||||
|
||||
if (!(trx->tmp_share->dbton_share[roop_count2] =
|
||||
spider_dbton[roop_count2].create_db_share(trx->tmp_share)))
|
||||
{
|
||||
goto error_create_db_share;
|
||||
}
|
||||
if (trx->tmp_share->dbton_share[roop_count2]->init())
|
||||
{
|
||||
delete trx->tmp_share->dbton_share[roop_count2];
|
||||
trx->tmp_share->dbton_share[roop_count2] = NULL;
|
||||
goto error_create_db_share;
|
||||
}
|
||||
|
||||
if (!(trx->tmp_spider->dbton_handler[roop_count2] =
|
||||
spider_dbton[roop_count2].create_db_handler(trx->tmp_spider,
|
||||
trx->tmp_share->dbton_share[roop_count2])))
|
||||
{
|
||||
goto error_create_db_share;
|
||||
}
|
||||
if (trx->tmp_spider->dbton_handler[roop_count2]->init())
|
||||
{
|
||||
delete trx->tmp_spider->dbton_handler[roop_count2];
|
||||
trx->tmp_spider->dbton_handler[roop_count2] = NULL;
|
||||
goto error_create_db_share;
|
||||
}
|
||||
}
|
||||
|
||||
if (regist_allocated_thds)
|
||||
{
|
||||
pthread_mutex_lock(&spider_allocated_thds_mutex);
|
||||
|
|
@ -1295,6 +1400,37 @@ SPIDER_TRX *spider_get_trx(
|
|||
DBUG_RETURN(trx);
|
||||
|
||||
error_allocated_thds_insert:
|
||||
error_alloc_spider:
|
||||
error_create_db_share:
|
||||
if (thd)
|
||||
{
|
||||
delete [] trx->tmp_spider->result_list.sqls;
|
||||
trx->tmp_spider->result_list.sqls = NULL;
|
||||
}
|
||||
error_init_result_list_sql:
|
||||
if (thd)
|
||||
{
|
||||
delete trx->tmp_spider;
|
||||
trx->tmp_spider = NULL;
|
||||
for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; ++roop_count2)
|
||||
{
|
||||
if (trx->tmp_spider->dbton_handler[roop_count2])
|
||||
{
|
||||
delete trx->tmp_spider->dbton_handler[roop_count2];
|
||||
trx->tmp_spider->dbton_handler[roop_count2] = NULL;
|
||||
}
|
||||
if (trx->tmp_share->dbton_share[roop_count2])
|
||||
{
|
||||
delete trx->tmp_share->dbton_share[roop_count2];
|
||||
trx->tmp_share->dbton_share[roop_count2] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
error_set_connect_info_default:
|
||||
if (thd)
|
||||
{
|
||||
spider_free_tmp_share_alloc(trx->tmp_share);
|
||||
}
|
||||
spider_free_mem_calc(trx,
|
||||
trx->trx_ha_hash_id,
|
||||
trx->trx_ha_hash.array.max_element *
|
||||
|
|
@ -1360,6 +1496,7 @@ error_init_hash:
|
|||
pthread_mutex_destroy(&trx->udf_table_mutexes[roop_count]);
|
||||
}
|
||||
error_init_udf_table_mutex:
|
||||
free_root(&trx->mem_root, MYF(0));
|
||||
spider_free(NULL, trx, MYF(0));
|
||||
error_alloc_trx:
|
||||
*error_num = HA_ERR_OUT_OF_MEM;
|
||||
|
|
@ -1500,16 +1637,31 @@ int spider_check_and_set_time_zone(
|
|||
int spider_xa_lock(
|
||||
XID_STATE *xid_state
|
||||
) {
|
||||
THD *thd = current_thd;
|
||||
int error_num;
|
||||
const char *old_proc_info;
|
||||
DBUG_ENTER("spider_xa_lock");
|
||||
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
|
||||
my_hash_value_type hash_value = my_calc_hash(spd_db_att_xid_cache,
|
||||
(uchar*) xid_state->xid.key(), xid_state->xid.key_length());
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
uint idx = hash_value % *spd_db_att_xid_cache_split_num;
|
||||
#endif
|
||||
#endif
|
||||
old_proc_info = thd_proc_info(thd, "Locking xid by Spider");
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
pthread_mutex_lock(&spd_db_att_LOCK_xid_cache[idx]);
|
||||
#else
|
||||
pthread_mutex_lock(spd_db_att_LOCK_xid_cache);
|
||||
#endif
|
||||
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
if (my_hash_search_using_hash_value(&spd_db_att_xid_cache[idx], hash_value,
|
||||
xid_state->xid.key(), xid_state->xid.key_length()))
|
||||
#else
|
||||
if (my_hash_search_using_hash_value(spd_db_att_xid_cache, hash_value,
|
||||
xid_state->xid.key(), xid_state->xid.key_length()))
|
||||
#endif
|
||||
#else
|
||||
if (my_hash_search(spd_db_att_xid_cache,
|
||||
xid_state->xid.key(), xid_state->xid.key_length()))
|
||||
|
|
@ -1519,8 +1671,13 @@ int spider_xa_lock(
|
|||
goto error;
|
||||
}
|
||||
#ifdef HASH_UPDATE_WITH_HASH_VALUE
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
if (my_hash_insert_with_hash_value(&spd_db_att_xid_cache[idx], hash_value,
|
||||
(uchar*)xid_state))
|
||||
#else
|
||||
if (my_hash_insert_with_hash_value(spd_db_att_xid_cache, hash_value,
|
||||
(uchar*)xid_state))
|
||||
#endif
|
||||
#else
|
||||
if (my_hash_insert(spd_db_att_xid_cache, (uchar*)xid_state))
|
||||
#endif
|
||||
|
|
@ -1528,29 +1685,60 @@ int spider_xa_lock(
|
|||
error_num = HA_ERR_OUT_OF_MEM;
|
||||
goto error;
|
||||
}
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
pthread_mutex_unlock(&spd_db_att_LOCK_xid_cache[idx]);
|
||||
#else
|
||||
pthread_mutex_unlock(spd_db_att_LOCK_xid_cache);
|
||||
#endif
|
||||
thd_proc_info(thd, old_proc_info);
|
||||
DBUG_RETURN(0);
|
||||
|
||||
error:
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
pthread_mutex_unlock(&spd_db_att_LOCK_xid_cache[idx]);
|
||||
#else
|
||||
pthread_mutex_unlock(spd_db_att_LOCK_xid_cache);
|
||||
#endif
|
||||
thd_proc_info(thd, old_proc_info);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
int spider_xa_unlock(
|
||||
XID_STATE *xid_state
|
||||
) {
|
||||
THD *thd = current_thd;
|
||||
const char *old_proc_info;
|
||||
DBUG_ENTER("spider_xa_unlock");
|
||||
#if defined(SPIDER_HAS_HASH_VALUE_TYPE) && defined(HASH_UPDATE_WITH_HASH_VALUE)
|
||||
my_hash_value_type hash_value = my_calc_hash(spd_db_att_xid_cache,
|
||||
(uchar*) xid_state->xid.key(), xid_state->xid.key_length());
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
uint idx = hash_value % *spd_db_att_xid_cache_split_num;
|
||||
#endif
|
||||
#endif
|
||||
old_proc_info = thd_proc_info(thd, "Unlocking xid by Spider");
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
pthread_mutex_lock(&spd_db_att_LOCK_xid_cache[idx]);
|
||||
#else
|
||||
pthread_mutex_lock(spd_db_att_LOCK_xid_cache);
|
||||
#endif
|
||||
#if defined(SPIDER_HAS_HASH_VALUE_TYPE) && defined(HASH_UPDATE_WITH_HASH_VALUE)
|
||||
my_hash_delete_with_hash_value(spd_db_att_xid_cache, hash_value, (uchar *)xid_state);
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
my_hash_delete_with_hash_value(&spd_db_att_xid_cache[idx],
|
||||
hash_value, (uchar *)xid_state);
|
||||
#else
|
||||
my_hash_delete_with_hash_value(spd_db_att_xid_cache,
|
||||
hash_value, (uchar *)xid_state);
|
||||
#endif
|
||||
#else
|
||||
my_hash_delete(spd_db_att_xid_cache, (uchar *)xid_state);
|
||||
#endif
|
||||
#ifdef XID_CACHE_IS_SPLITTED
|
||||
pthread_mutex_unlock(&spd_db_att_LOCK_xid_cache[idx]);
|
||||
#else
|
||||
pthread_mutex_unlock(spd_db_att_LOCK_xid_cache);
|
||||
#endif
|
||||
thd_proc_info(thd, old_proc_info);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
|
@ -1572,10 +1760,11 @@ int spider_internal_start_trx(
|
|||
) {
|
||||
int error_num;
|
||||
SPIDER_TRX *trx = spider->trx;
|
||||
bool sync_autocommit = spider_param_sync_autocommit(trx->thd);
|
||||
bool sync_time_zone = spider_param_sync_time_zone(trx->thd);
|
||||
THD *thd = trx->thd;
|
||||
bool sync_autocommit = spider_param_sync_autocommit(thd);
|
||||
bool sync_time_zone = spider_param_sync_time_zone(thd);
|
||||
double ping_interval_at_trx_start =
|
||||
spider_param_ping_interval_at_trx_start(trx->thd);
|
||||
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");
|
||||
|
|
@ -1592,19 +1781,19 @@ int spider_internal_start_trx(
|
|||
if (!trx->trx_consistent_snapshot)
|
||||
{
|
||||
trx->use_consistent_snapshot =
|
||||
spider_param_use_consistent_snapshot(trx->thd);
|
||||
trx->internal_xa = spider_param_internal_xa(trx->thd);
|
||||
trx->internal_xa_snapshot = spider_param_internal_xa_snapshot(trx->thd);
|
||||
spider_param_use_consistent_snapshot(thd);
|
||||
trx->internal_xa = spider_param_internal_xa(thd);
|
||||
trx->internal_xa_snapshot = spider_param_internal_xa_snapshot(thd);
|
||||
}
|
||||
}
|
||||
if (
|
||||
(error_num = spider_check_and_set_sql_log_off(trx->thd, conn,
|
||||
(error_num = spider_check_and_set_sql_log_off(thd, conn,
|
||||
&spider->need_mons[link_idx])) ||
|
||||
(sync_time_zone &&
|
||||
(error_num = spider_check_and_set_time_zone(trx->thd, conn,
|
||||
(error_num = spider_check_and_set_time_zone(thd, conn,
|
||||
&spider->need_mons[link_idx]))) ||
|
||||
(sync_autocommit &&
|
||||
(error_num = spider_check_and_set_autocommit(trx->thd, conn,
|
||||
(error_num = spider_check_and_set_autocommit(thd, conn,
|
||||
&spider->need_mons[link_idx])))
|
||||
)
|
||||
goto error;
|
||||
|
|
@ -1628,70 +1817,74 @@ int spider_internal_start_trx(
|
|||
if (!trx->trx_start)
|
||||
{
|
||||
if (
|
||||
trx->thd->transaction.xid_state.xa_state == XA_ACTIVE &&
|
||||
thd->transaction.xid_state.xa_state == XA_ACTIVE &&
|
||||
spider_param_support_xa()
|
||||
) {
|
||||
trx->trx_xa = TRUE;
|
||||
thd_get_xid(trx->thd, (MYSQL_XID*) &trx->xid);
|
||||
thd_get_xid(thd, (MYSQL_XID*) &trx->xid);
|
||||
}
|
||||
|
||||
if (!trx->trx_xa && trx->internal_xa)
|
||||
{
|
||||
if (!trx->trx_consistent_snapshot || trx->internal_xa_snapshot == 3)
|
||||
{
|
||||
if (
|
||||
!trx->trx_xa &&
|
||||
trx->internal_xa &&
|
||||
(!trx->trx_consistent_snapshot || trx->internal_xa_snapshot == 3) &&
|
||||
spider->sql_command != SQLCOM_LOCK_TABLES
|
||||
) {
|
||||
trx->trx_xa = TRUE;
|
||||
trx->xid.formatID = 1;
|
||||
if (spider_param_internal_xa_id_type(thd) == 0)
|
||||
{
|
||||
trx->xid.gtrid_length
|
||||
= my_sprintf(trx->xid.data,
|
||||
(trx->xid.data, "%lx", thd_get_thread_id(trx->thd)));
|
||||
(trx->xid.data, "%lx", thd_get_thread_id(thd)));
|
||||
} else {
|
||||
trx->xid.gtrid_length
|
||||
= my_sprintf(trx->xid.data,
|
||||
(trx->xid.data, "%lx%016llx", thd_get_thread_id(thd),
|
||||
thd->query_id));
|
||||
}
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002
|
||||
trx->xid.bqual_length
|
||||
= my_sprintf(trx->xid.data + trx->xid.gtrid_length,
|
||||
(trx->xid.data + trx->xid.gtrid_length, "%lx",
|
||||
trx->thd->variables.server_id));
|
||||
thd->variables.server_id));
|
||||
#else
|
||||
trx->xid.bqual_length
|
||||
= my_sprintf(trx->xid.data + trx->xid.gtrid_length,
|
||||
(trx->xid.data + trx->xid.gtrid_length, "%x",
|
||||
trx->thd->server_id));
|
||||
thd->server_id));
|
||||
#endif
|
||||
|
||||
trx->internal_xid_state.xa_state = XA_ACTIVE;
|
||||
trx->internal_xid_state.xid.set(&trx->xid);
|
||||
trx->internal_xid_state.in_thd = 1;
|
||||
while ((error_num = spider_xa_lock(&trx->internal_xid_state)))
|
||||
{
|
||||
if (error_num != ER_SPIDER_XA_LOCKED_NUM)
|
||||
goto error;
|
||||
else if (trx->xid.formatID == 0)
|
||||
if ((error_num = spider_xa_lock(&trx->internal_xid_state)))
|
||||
{
|
||||
if (error_num == ER_SPIDER_XA_LOCKED_NUM)
|
||||
my_message(error_num, ER_SPIDER_XA_LOCKED_STR, MYF(0));
|
||||
goto error;
|
||||
}
|
||||
/* retry */
|
||||
trx->xid.formatID++;
|
||||
trx->internal_xid_state.xid.set(&trx->xid);
|
||||
}
|
||||
xa_lock = TRUE;
|
||||
}
|
||||
}
|
||||
} else
|
||||
trx->internal_xa = FALSE;
|
||||
|
||||
DBUG_PRINT("info",("spider trx->trx_consistent_snapshot= %s",
|
||||
trx->trx_consistent_snapshot ? "TRUE" : "FALSE"));
|
||||
if (!trx->trx_consistent_snapshot)
|
||||
{
|
||||
trans_register_ha(trx->thd, FALSE, spider_hton_ptr);
|
||||
if (thd_test_options(trx->thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
|
||||
trans_register_ha(trx->thd, TRUE, spider_hton_ptr);
|
||||
trans_register_ha(thd, FALSE, spider_hton_ptr);
|
||||
if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
|
||||
trans_register_ha(thd, TRUE, spider_hton_ptr);
|
||||
}
|
||||
trx->trx_start = TRUE;
|
||||
trx->trx_xa_prepared = FALSE;
|
||||
}
|
||||
|
||||
DBUG_PRINT("info",("spider sync_autocommit = %d", sync_autocommit));
|
||||
DBUG_PRINT("info",("spider conn->semi_trx_chk = %d", conn->semi_trx_chk));
|
||||
DBUG_PRINT("info",("spider conn->table_lock = %d", conn->table_lock));
|
||||
DBUG_PRINT("info",("spider conn->autocommit = %d", conn->autocommit));
|
||||
DBUG_PRINT("info",("spider semi_trx = %d", spider_param_semi_trx(trx->thd)));
|
||||
DBUG_PRINT("info",("spider semi_trx = %d", spider_param_semi_trx(thd)));
|
||||
conn->semi_trx = FALSE;
|
||||
if (conn->table_lock == 3)
|
||||
{
|
||||
|
|
@ -1708,7 +1901,7 @@ int spider_internal_start_trx(
|
|||
(!conn->queued_autocommit && conn->autocommit == 1) ||
|
||||
(conn->queued_autocommit && conn->queued_autocommit_val == TRUE)
|
||||
) &&
|
||||
spider_param_semi_trx(trx->thd)
|
||||
spider_param_semi_trx(thd)
|
||||
) {
|
||||
DBUG_PRINT("info",("spider semi_trx is set"));
|
||||
conn->semi_trx = TRUE;
|
||||
|
|
@ -1717,7 +1910,7 @@ int spider_internal_start_trx(
|
|||
conn->disable_xa = FALSE;
|
||||
} else if (
|
||||
!trx->trx_consistent_snapshot &&
|
||||
!thd_test_options(trx->thd, OPTION_BEGIN) &&
|
||||
!thd_test_options(thd, OPTION_BEGIN) &&
|
||||
sync_autocommit &&
|
||||
conn->semi_trx_chk &&
|
||||
!conn->table_lock &&
|
||||
|
|
@ -1725,14 +1918,14 @@ int spider_internal_start_trx(
|
|||
(!conn->queued_autocommit && conn->autocommit == 1) ||
|
||||
(conn->queued_autocommit && conn->queued_autocommit_val == TRUE)
|
||||
) &&
|
||||
spider_param_semi_trx(trx->thd)
|
||||
spider_param_semi_trx(thd)
|
||||
) {
|
||||
DBUG_PRINT("info",("spider semi_trx is set"));
|
||||
spider_conn_queue_start_transaction(conn);
|
||||
conn->semi_trx = TRUE;
|
||||
} else if (
|
||||
!trx->trx_consistent_snapshot &&
|
||||
thd_test_options(trx->thd, OPTION_BEGIN)
|
||||
thd_test_options(thd, OPTION_BEGIN)
|
||||
) {
|
||||
DBUG_PRINT("info",("spider start transaction"));
|
||||
spider_conn_queue_start_transaction(conn);
|
||||
|
|
@ -1848,6 +2041,8 @@ int spider_internal_xa_commit(
|
|||
if ((conn = spider_tree_first(trx->join_trx_top)))
|
||||
{
|
||||
do {
|
||||
if (conn->bg_search)
|
||||
spider_bg_conn_break(conn, NULL);
|
||||
DBUG_PRINT("info",("spider conn=%p", conn));
|
||||
DBUG_PRINT("info",("spider conn->join_trx=%u", conn->join_trx));
|
||||
if (conn->join_trx)
|
||||
|
|
@ -1950,12 +2145,11 @@ int spider_internal_xa_rollback(
|
|||
Open_tables_backup open_tables_backup;
|
||||
#endif
|
||||
bool server_lost = FALSE;
|
||||
bool prepared = (thd->transaction.xid_state.xa_state == XA_PREPARED);
|
||||
bool table_xa_opened = FALSE;
|
||||
bool table_xa_member_opened = FALSE;
|
||||
DBUG_ENTER("spider_internal_xa_rollback");
|
||||
|
||||
if (prepared)
|
||||
if (trx->trx_xa_prepared)
|
||||
{
|
||||
/*
|
||||
select
|
||||
|
|
@ -2029,11 +2223,13 @@ int spider_internal_xa_rollback(
|
|||
if ((conn = spider_tree_first(trx->join_trx_top)))
|
||||
{
|
||||
do {
|
||||
if (conn->bg_search)
|
||||
spider_bg_conn_break(conn, NULL);
|
||||
if (conn->join_trx)
|
||||
{
|
||||
if (conn->disable_xa)
|
||||
{
|
||||
if (conn->table_lock != 3 && !prepared)
|
||||
if (conn->table_lock != 3 && !trx->trx_xa_prepared)
|
||||
{
|
||||
if (
|
||||
!conn->server_lost &&
|
||||
|
|
@ -2048,7 +2244,7 @@ int spider_internal_xa_rollback(
|
|||
if (!conn->server_lost)
|
||||
{
|
||||
if (
|
||||
!prepared &&
|
||||
!trx->trx_xa_prepared &&
|
||||
(tmp_error_num = spider_db_xa_end(conn, &trx->xid))
|
||||
) {
|
||||
if (
|
||||
|
|
@ -2102,7 +2298,7 @@ int spider_internal_xa_rollback(
|
|||
goto error_in_rollback;
|
||||
|
||||
if (
|
||||
prepared &&
|
||||
trx->trx_xa_prepared &&
|
||||
!server_lost
|
||||
) {
|
||||
/*
|
||||
|
|
@ -2213,6 +2409,8 @@ int spider_internal_xa_prepare(
|
|||
if ((conn = spider_tree_first(trx->join_trx_top)))
|
||||
{
|
||||
do {
|
||||
if (conn->bg_search)
|
||||
spider_bg_conn_break(conn, NULL);
|
||||
if (conn->disable_xa)
|
||||
{
|
||||
if (conn->table_lock != 3)
|
||||
|
|
@ -3088,9 +3286,10 @@ int spider_commit(
|
|||
if (trx->trx_start)
|
||||
{
|
||||
if (trx->trx_xa)
|
||||
{
|
||||
if (trx->internal_xa && !trx->trx_xa_prepared)
|
||||
{
|
||||
if (
|
||||
trx->internal_xa &&
|
||||
(error_num = spider_internal_xa_prepare(
|
||||
thd, trx, table_xa, table_xa_member, TRUE))
|
||||
) {
|
||||
|
|
@ -3105,6 +3304,8 @@ int spider_commit(
|
|||
*/
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
trx->trx_xa_prepared = TRUE;
|
||||
}
|
||||
int tmp_error_num;
|
||||
if (
|
||||
(tmp_error_num = spider_internal_xa_commit(
|
||||
|
|
@ -3114,6 +3315,7 @@ int spider_commit(
|
|||
error_num = tmp_error_num;
|
||||
}
|
||||
trx->trx_xa = FALSE;
|
||||
trx->join_trx_top = NULL;
|
||||
} else {
|
||||
if ((conn = spider_tree_first(trx->join_trx_top)))
|
||||
{
|
||||
|
|
@ -3183,6 +3385,7 @@ int spider_rollback(
|
|||
error_num = tmp_error_num;
|
||||
}
|
||||
trx->trx_xa = FALSE;
|
||||
trx->join_trx_top = NULL;
|
||||
} else {
|
||||
if ((conn = spider_tree_first(trx->join_trx_top)))
|
||||
{
|
||||
|
|
@ -3246,6 +3449,7 @@ int spider_xa_prepare(
|
|||
if ((error_num = spider_internal_xa_prepare(
|
||||
thd, trx, table_xa, table_xa_member, FALSE)))
|
||||
goto error;
|
||||
trx->trx_xa_prepared = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3315,22 +3519,40 @@ error_get_trx:
|
|||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
void spider_copy_table_free_trx_conn(
|
||||
SPIDER_TRX *trx
|
||||
) {
|
||||
SPIDER_CONN *conn;
|
||||
DBUG_ENTER("spider_copy_table_free_trx_conn");
|
||||
if ((conn = spider_tree_first(trx->join_trx_top)))
|
||||
{
|
||||
do {
|
||||
spider_end_trx(trx, conn);
|
||||
conn->join_trx = 0;
|
||||
} while ((conn = spider_tree_next(conn)));
|
||||
trx->join_trx_top = NULL;
|
||||
}
|
||||
spider_reuse_trx_ha(trx);
|
||||
spider_free_trx_conn(trx, FALSE);
|
||||
trx->trx_consistent_snapshot = FALSE;
|
||||
spider_merge_mem_calc(trx, FALSE);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
int spider_end_trx(
|
||||
SPIDER_TRX *trx,
|
||||
SPIDER_CONN *conn
|
||||
) {
|
||||
int error_num = 0, need_mon = 0;
|
||||
ha_spider tmp_spider;
|
||||
DBUG_ENTER("spider_end_trx");
|
||||
tmp_spider.conns = &conn;
|
||||
if (conn->table_lock == 3)
|
||||
{
|
||||
trx->tmp_spider->conns = &conn;
|
||||
conn->table_lock = 0;
|
||||
conn->disable_reconnect = FALSE;
|
||||
tmp_spider.trx = trx;
|
||||
if (
|
||||
!conn->server_lost &&
|
||||
(error_num = spider_db_unlock_tables(&tmp_spider, 0))
|
||||
(error_num = spider_db_unlock_tables(trx->tmp_spider, 0))
|
||||
) {
|
||||
if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM)
|
||||
error_num = 0;
|
||||
|
|
@ -3422,8 +3644,6 @@ int spider_check_trx_and_get_conn(
|
|||
DBUG_PRINT("info",("spider semi_table_lock = %d",
|
||||
spider_param_semi_table_lock(thd, share->semi_table_lock)));
|
||||
DBUG_PRINT("info",("spider first_byte = %d", first_byte));
|
||||
DBUG_PRINT("info",("spider link_status = %ld",
|
||||
share->link_statuses[spider->conn_link_idx[spider->search_link_idx]]));
|
||||
if (
|
||||
!trx_ha ||
|
||||
trx_ha->wait_for_reusing ||
|
||||
|
|
@ -3615,6 +3835,8 @@ int spider_check_trx_and_get_conn(
|
|||
#endif
|
||||
}
|
||||
} else {
|
||||
DBUG_PRINT("info",("spider link_status = %ld",
|
||||
share->link_statuses[spider->conn_link_idx[spider->search_link_idx]]));
|
||||
for (
|
||||
roop_count = spider_conn_link_idx_next(share->link_statuses,
|
||||
spider->conn_link_idx, -1, share->link_count,
|
||||
|
|
@ -3757,12 +3979,12 @@ void spider_free_tmp_thd(
|
|||
THD *thd
|
||||
) {
|
||||
DBUG_ENTER("spider_free_tmp_thd");
|
||||
thd->cleanup();
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
|
||||
thd->reset_globals();
|
||||
#else
|
||||
thd->restore_globals();
|
||||
#endif
|
||||
thd->cleanup();
|
||||
delete thd;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2008-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
@ -208,6 +208,10 @@ int spider_xa_rollback_by_xid(
|
|||
XID* xid
|
||||
);
|
||||
|
||||
void spider_copy_table_free_trx_conn(
|
||||
SPIDER_TRX *trx
|
||||
);
|
||||
|
||||
int spider_end_trx(
|
||||
SPIDER_TRX *trx,
|
||||
SPIDER_CONN *conn
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2009-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2009-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2009-2013 Kentoku Shiba
|
||||
/* Copyright (C) 2009-2014 Kentoku Shiba
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue