Commit 15b443b0 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-6088 - Merge spider 3.2

parents 244d4b53 e105d8bc
This diff is collapsed.
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -125,6 +125,7 @@ public: ...@@ -125,6 +125,7 @@ public:
bool clone_bitmap_init; bool clone_bitmap_init;
ha_spider *pt_clone_source_handler; ha_spider *pt_clone_source_handler;
ha_spider *pt_clone_last_searcher; ha_spider *pt_clone_last_searcher;
bool has_clone_for_merge;
bool init_index_handler; bool init_index_handler;
bool init_rnd_handler; bool init_rnd_handler;
...@@ -165,6 +166,7 @@ public: ...@@ -165,6 +166,7 @@ public:
bool high_priority; bool high_priority;
bool insert_delayed; bool insert_delayed;
bool use_pre_call; bool use_pre_call;
bool use_pre_records;
enum thr_lock_type lock_type; enum thr_lock_type lock_type;
int lock_mode; int lock_mode;
uint sql_command; uint sql_command;
...@@ -172,6 +174,9 @@ public: ...@@ -172,6 +174,9 @@ public:
bool bulk_insert; bool bulk_insert;
#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC #ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
bool info_auto_called; bool info_auto_called;
#endif
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
bool auto_inc_temporary;
#endif #endif
int bulk_size; int bulk_size;
int direct_dup_insert; int direct_dup_insert;
...@@ -232,6 +237,7 @@ public: ...@@ -232,6 +237,7 @@ public:
SPIDER_ITEM_HLD *direct_aggregate_item_first; SPIDER_ITEM_HLD *direct_aggregate_item_first;
SPIDER_ITEM_HLD *direct_aggregate_item_current; SPIDER_ITEM_HLD *direct_aggregate_item_current;
#endif #endif
ha_rows table_rows;
/* for fulltext search */ /* for fulltext search */
bool ft_init_and_first; bool ft_init_and_first;
...@@ -463,6 +469,9 @@ public: ...@@ -463,6 +469,9 @@ public:
bool use_parallel bool use_parallel
); );
#ifdef HA_MRR_USE_DEFAULT_IMPL #ifdef HA_MRR_USE_DEFAULT_IMPL
int pre_multi_range_read_next(
bool use_parallel
);
#else #else
int pre_read_multi_range_first( int pre_read_multi_range_first(
KEY_MULTI_RANGE **found_range_p, KEY_MULTI_RANGE **found_range_p,
...@@ -491,6 +500,7 @@ public: ...@@ -491,6 +500,7 @@ public:
key_range *end_key key_range *end_key
); );
int check_crd(); int check_crd();
int pre_records();
ha_rows records(); ha_rows records();
const char *table_type() const; const char *table_type() const;
ulonglong table_flags() const; ulonglong table_flags() const;
...@@ -510,6 +520,9 @@ public: ...@@ -510,6 +520,9 @@ public:
uint8 table_cache_type(); uint8 table_cache_type();
#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC #ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
bool 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 #endif
int update_auto_increment(); int update_auto_increment();
void get_auto_increment( void get_auto_increment(
...@@ -541,6 +554,12 @@ public: ...@@ -541,6 +554,12 @@ public:
int pre_write_row( int pre_write_row(
uchar *buf uchar *buf
); );
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
void direct_update_init(
THD *thd,
bool hs_request
);
#endif #endif
bool start_bulk_update(); bool start_bulk_update();
int exec_bulk_update( int exec_bulk_update(
...@@ -721,6 +740,7 @@ public: ...@@ -721,6 +740,7 @@ public:
); );
uint check_partitioned(); uint check_partitioned();
void check_direct_order_limit(); void check_direct_order_limit();
int check_ha_range_eof();
int drop_tmp_tables(); int drop_tmp_tables();
bool handler_opened( bool handler_opened(
int link_idx, int link_idx,
...@@ -845,7 +865,7 @@ public: ...@@ -845,7 +865,7 @@ public:
int append_direct_update_set_hs_part(); int append_direct_update_set_hs_part();
#endif #endif
#endif #endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
int append_dup_update_pushdown_sql_part( int append_dup_update_pushdown_sql_part(
const char *alias, const char *alias,
uint alias_length uint alias_length
...@@ -944,6 +964,13 @@ public: ...@@ -944,6 +964,13 @@ public:
void set_order_to_pos_sql( void set_order_to_pos_sql(
ulong sql_type 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( int append_key_order_for_merge_with_alias_sql_part(
const char *alias, const char *alias,
uint alias_length, uint alias_length,
......
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -233,6 +233,7 @@ void spider_free_conn_from_trx( ...@@ -233,6 +233,7 @@ void spider_free_conn_from_trx(
) { ) {
/* conn_recycle_mode == 1 */ /* conn_recycle_mode == 1 */
*conn->conn_key = '0'; *conn->conn_key = '0';
conn->casual_read_base_conn = NULL;
if ( if (
conn->quick_target && conn->quick_target &&
spider_db_free_result((ha_spider *) conn->quick_target, FALSE) spider_db_free_result((ha_spider *) conn->quick_target, FALSE)
...@@ -1100,6 +1101,91 @@ int spider_free_conn( ...@@ -1100,6 +1101,91 @@ int spider_free_conn(
DBUG_RETURN(0); 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( void spider_conn_queue_connect(
SPIDER_SHARE *share, SPIDER_SHARE *share,
SPIDER_CONN *conn, SPIDER_CONN *conn,
...@@ -2096,18 +2182,38 @@ int spider_bg_conn_search( ...@@ -2096,18 +2182,38 @@ int spider_bg_conn_search(
void spider_bg_conn_simple_action( void spider_bg_conn_simple_action(
SPIDER_CONN *conn, 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"); DBUG_ENTER("spider_bg_conn_simple_action");
pthread_mutex_lock(&conn->bg_conn_mutex); 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_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_mutex_lock(&conn->bg_conn_sync_mutex);
}
pthread_cond_signal(&conn->bg_conn_cond); pthread_cond_signal(&conn->bg_conn_cond);
pthread_mutex_unlock(&conn->bg_conn_mutex); pthread_mutex_unlock(&conn->bg_conn_mutex);
if (caller_wait)
{
pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex);
pthread_mutex_unlock(&conn->bg_conn_sync_mutex); pthread_mutex_unlock(&conn->bg_conn_sync_mutex);
conn->bg_caller_wait = FALSE; 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; DBUG_VOID_RETURN;
} }
...@@ -2450,6 +2556,13 @@ void *spider_bg_conn_action( ...@@ -2450,6 +2556,13 @@ void *spider_bg_conn_action(
case SPIDER_BG_SIMPLE_DISCONNECT: case SPIDER_BG_SIMPLE_DISCONNECT:
conn->db_conn->bg_disconnect(); conn->db_conn->bg_disconnect();
break; 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: default:
break; break;
} }
...@@ -2761,10 +2874,15 @@ void *spider_bg_sts_action( ...@@ -2761,10 +2874,15 @@ void *spider_bg_sts_action(
if (spider.search_link_idx == -1) if (spider.search_link_idx == -1)
{ {
spider_trx_set_link_idx_for_all(&spider); spider_trx_set_link_idx_for_all(&spider);
/*
spider.search_link_idx = spider_conn_next_link_idx( spider.search_link_idx = spider_conn_next_link_idx(
thd, share->link_statuses, share->access_balances, thd, share->link_statuses, share->access_balances,
spider.conn_link_idx, spider.search_link_idx, share->link_count, spider.conn_link_idx, spider.search_link_idx, share->link_count,
SPIDER_LINK_STATUS_OK); 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) if (spider.search_link_idx >= 0)
{ {
...@@ -2780,6 +2898,7 @@ void *spider_bg_sts_action( ...@@ -2780,6 +2898,7 @@ void *spider_bg_sts_action(
&error_num); &error_num);
conns[spider.search_link_idx]->error_mode = 0; conns[spider.search_link_idx]->error_mode = 0;
pthread_mutex_unlock(&spider_global_trx_mutex); pthread_mutex_unlock(&spider_global_trx_mutex);
/*
if ( if (
error_num && error_num &&
share->monitoring_kind[spider.search_link_idx] && share->monitoring_kind[spider.search_link_idx] &&
...@@ -2802,8 +2921,10 @@ void *spider_bg_sts_action( ...@@ -2802,8 +2921,10 @@ void *spider_bg_sts_action(
); );
lex_end(thd->lex); 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 #ifdef WITH_PARTITION_STORAGE_ENGINE
if (spider_get_sts(share, spider.search_link_idx, if (spider_get_sts(share, spider.search_link_idx,
...@@ -2818,6 +2939,7 @@ void *spider_bg_sts_action( ...@@ -2818,6 +2939,7 @@ void *spider_bg_sts_action(
2, HA_STATUS_CONST | HA_STATUS_VARIABLE)) 2, HA_STATUS_CONST | HA_STATUS_VARIABLE))
#endif #endif
{ {
/*
if ( if (
share->monitoring_kind[spider.search_link_idx] && share->monitoring_kind[spider.search_link_idx] &&
need_mons[spider.search_link_idx] need_mons[spider.search_link_idx]
...@@ -2839,6 +2961,7 @@ void *spider_bg_sts_action( ...@@ -2839,6 +2961,7 @@ void *spider_bg_sts_action(
); );
lex_end(thd->lex); lex_end(thd->lex);
} }
*/
spider.search_link_idx = -1; spider.search_link_idx = -1;
} }
} }
...@@ -3143,10 +3266,15 @@ void *spider_bg_crd_action( ...@@ -3143,10 +3266,15 @@ void *spider_bg_crd_action(
if (spider.search_link_idx == -1) if (spider.search_link_idx == -1)
{ {
spider_trx_set_link_idx_for_all(&spider); spider_trx_set_link_idx_for_all(&spider);
/*
spider.search_link_idx = spider_conn_next_link_idx( spider.search_link_idx = spider_conn_next_link_idx(
thd, share->link_statuses, share->access_balances, thd, share->link_statuses, share->access_balances,
spider.conn_link_idx, spider.search_link_idx, share->link_count, spider.conn_link_idx, spider.search_link_idx, share->link_count,
SPIDER_LINK_STATUS_OK); 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) if (spider.search_link_idx >= 0)
{ {
...@@ -3162,6 +3290,7 @@ void *spider_bg_crd_action( ...@@ -3162,6 +3290,7 @@ void *spider_bg_crd_action(
&error_num); &error_num);
conns[spider.search_link_idx]->error_mode = 0; conns[spider.search_link_idx]->error_mode = 0;
pthread_mutex_unlock(&spider_global_trx_mutex); pthread_mutex_unlock(&spider_global_trx_mutex);
/*
if ( if (
error_num && error_num &&
share->monitoring_kind[spider.search_link_idx] && share->monitoring_kind[spider.search_link_idx] &&
...@@ -3184,8 +3313,10 @@ void *spider_bg_crd_action( ...@@ -3184,8 +3313,10 @@ void *spider_bg_crd_action(
); );
lex_end(thd->lex); 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 #ifdef WITH_PARTITION_STORAGE_ENGINE
if (spider_get_crd(share, spider.search_link_idx, if (spider_get_crd(share, spider.search_link_idx,
...@@ -3200,6 +3331,7 @@ void *spider_bg_crd_action( ...@@ -3200,6 +3331,7 @@ void *spider_bg_crd_action(
2)) 2))
#endif #endif
{ {
/*
if ( if (
share->monitoring_kind[spider.search_link_idx] && share->monitoring_kind[spider.search_link_idx] &&
need_mons[spider.search_link_idx] need_mons[spider.search_link_idx]
...@@ -3221,6 +3353,7 @@ void *spider_bg_crd_action( ...@@ -3221,6 +3353,7 @@ void *spider_bg_crd_action(
); );
lex_end(thd->lex); lex_end(thd->lex);
} }
*/
spider.search_link_idx = -1; spider.search_link_idx = -1;
} }
} }
...@@ -3718,28 +3851,35 @@ bool spider_conn_use_handler( ...@@ -3718,28 +3851,35 @@ bool spider_conn_use_handler(
#endif #endif
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
if (spider->do_direct_update) if (spider->do_direct_update)
{ {
spider->sql_kinds |= SPIDER_SQL_KIND_SQL; spider->sql_kinds |= SPIDER_SQL_KIND_SQL;
spider->sql_kind[link_idx] = 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)) if (spider_bit_is_set(spider->do_hs_direct_update, link_idx))
{ {
spider->direct_update_kinds |= SPIDER_SQL_KIND_HS; spider->direct_update_kinds |= SPIDER_SQL_KIND_HS;
DBUG_PRINT("info",("spider TRUE by using HS direct_update")); DBUG_PRINT("info",("spider TRUE by using HS direct_update"));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} else } else {
#endif
spider->direct_update_kinds |= SPIDER_SQL_KIND_SQL; 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) if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL)
{ {
#endif
DBUG_PRINT("info",("spider FALSE by using direct_update")); DBUG_PRINT("info",("spider FALSE by using direct_update"));
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else { } else {
DBUG_PRINT("info",("spider TRUE by using BOTH")); DBUG_PRINT("info",("spider TRUE by using BOTH"));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
}
#endif #endif
}
#endif #endif
if (spider->use_spatial_index) if (spider->use_spatial_index)
{ {
......
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#define SPIDER_BG_SIMPLE_NO_ACTION 0 #define SPIDER_BG_SIMPLE_NO_ACTION 0
#define SPIDER_BG_SIMPLE_CONNECT 1 #define SPIDER_BG_SIMPLE_CONNECT 1
#define SPIDER_BG_SIMPLE_DISCONNECT 2 #define SPIDER_BG_SIMPLE_DISCONNECT 2
#define SPIDER_BG_SIMPLE_RECORDS 3
uchar *spider_conn_get_key( uchar *spider_conn_get_key(
SPIDER_CONN *conn, SPIDER_CONN *conn,
...@@ -69,6 +70,18 @@ int spider_free_conn( ...@@ -69,6 +70,18 @@ int spider_free_conn(
SPIDER_CONN *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( void spider_conn_queue_connect(
SPIDER_SHARE *share, SPIDER_SHARE *share,
SPIDER_CONN *conn, SPIDER_CONN *conn,
...@@ -220,7 +233,11 @@ int spider_bg_conn_search( ...@@ -220,7 +233,11 @@ int spider_bg_conn_search(
void spider_bg_conn_simple_action( void spider_bg_conn_simple_action(
SPIDER_CONN *conn, 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( void *spider_bg_conn_action(
......
/* Copyright (C) 2009-2013 Kentoku Shiba /* Copyright (C) 2009-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 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( ...@@ -719,7 +719,7 @@ int spider_udf_copy_tables_create_table_list(
&copy_tables->link_idxs[1], &copy_tables->link_idxs[1],
sizeof(int) * copy_tables->link_idx_count[1], sizeof(int) * copy_tables->link_idx_count[1],
&tmp_name_ptr, sizeof(char) * ( &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)) NullS))
) { ) {
...@@ -849,6 +849,7 @@ long long spider_copy_tables_body( ...@@ -849,6 +849,7 @@ long long spider_copy_tables_body(
MEM_ROOT mem_root; MEM_ROOT mem_root;
longlong bulk_insert_rows; longlong bulk_insert_rows;
Reprepare_observer *reprepare_observer_backup; Reprepare_observer *reprepare_observer_backup;
uint tmp_conn_link_idx = 0;
DBUG_ENTER("spider_copy_tables_body"); DBUG_ENTER("spider_copy_tables_body");
if ( if (
thd->open_tables != 0 || thd->open_tables != 0 ||
...@@ -989,6 +990,7 @@ long long spider_copy_tables_body( ...@@ -989,6 +990,7 @@ long long spider_copy_tables_body(
table_list->table_name_length)); table_list->table_name_length));
reprepare_observer_backup = thd->m_reprepare_observer; reprepare_observer_backup = thd->m_reprepare_observer;
thd->m_reprepare_observer = NULL; thd->m_reprepare_observer = NULL;
copy_tables->trx->trx_start = TRUE;
#if MYSQL_VERSION_ID < 50500 #if MYSQL_VERSION_ID < 50500
if (open_and_lock_tables(thd, table_list)) if (open_and_lock_tables(thd, table_list))
#else #else
...@@ -1003,12 +1005,14 @@ long long spider_copy_tables_body( ...@@ -1003,12 +1005,14 @@ long long spider_copy_tables_body(
#endif #endif
{ {
thd->m_reprepare_observer = reprepare_observer_backup; thd->m_reprepare_observer = reprepare_observer_backup;
copy_tables->trx->trx_start = FALSE;
my_printf_error(ER_SPIDER_UDF_CANT_OPEN_TABLE_NUM, my_printf_error(ER_SPIDER_UDF_CANT_OPEN_TABLE_NUM,
ER_SPIDER_UDF_CANT_OPEN_TABLE_STR, MYF(0), table_list->db, ER_SPIDER_UDF_CANT_OPEN_TABLE_STR, MYF(0), table_list->db,
table_list->table_name); table_list->table_name);
goto error; goto error;
} }
thd->m_reprepare_observer = reprepare_observer_backup; thd->m_reprepare_observer = reprepare_observer_backup;
copy_tables->trx->trx_start = FALSE;
table = table_list->table; table = table_list->table;
table_share = table->s; table_share = table->s;
...@@ -1093,6 +1097,7 @@ long long spider_copy_tables_body( ...@@ -1093,6 +1097,7 @@ long long spider_copy_tables_body(
for (roop_count = 0; roop_count < all_link_cnt; roop_count++) for (roop_count = 0; roop_count < all_link_cnt; roop_count++)
{ {
spider[roop_count].conns = NULL; 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]; for (roop_count = 0, table_conn = copy_tables->table_conn[0];
table_conn; roop_count++, table_conn = table_conn->next) table_conn; roop_count++, table_conn = table_conn->next)
...@@ -1123,6 +1128,7 @@ long long spider_copy_tables_body( ...@@ -1123,6 +1128,7 @@ long long spider_copy_tables_body(
tmp_spider->result_list.sqls = &tmp_sql[roop_count]; tmp_spider->result_list.sqls = &tmp_sql[roop_count];
tmp_spider->need_mons = &table_conn->need_mon; tmp_spider->need_mons = &table_conn->need_mon;
tmp_spider->lock_type = TL_READ; 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]; uint dbton_id = tmp_spider->share->use_dbton_ids[0];
if (!(tmp_spider->dbton_handler[dbton_id] = if (!(tmp_spider->dbton_handler[dbton_id] =
spider_dbton[dbton_id].create_db_handler(tmp_spider, spider_dbton[dbton_id].create_db_handler(tmp_spider,
...@@ -1166,6 +1172,7 @@ long long spider_copy_tables_body( ...@@ -1166,6 +1172,7 @@ long long spider_copy_tables_body(
tmp_spider->result_list.sqls = &tmp_sql[roop_count]; tmp_spider->result_list.sqls = &tmp_sql[roop_count];
tmp_spider->need_mons = &table_conn->need_mon; tmp_spider->need_mons = &table_conn->need_mon;
tmp_spider->lock_type = TL_WRITE; 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]; uint dbton_id = tmp_spider->share->use_dbton_ids[0];
if (!(tmp_spider->dbton_handler[dbton_id] = if (!(tmp_spider->dbton_handler[dbton_id] =
spider_dbton[dbton_id].create_db_handler(tmp_spider, spider_dbton[dbton_id].create_db_handler(tmp_spider,
...@@ -1293,7 +1300,9 @@ error: ...@@ -1293,7 +1300,9 @@ error:
delete [] tmp_sql; delete [] tmp_sql;
} }
if (copy_tables) if (copy_tables)
{
spider_udf_free_copy_tables_alloc(copy_tables); spider_udf_free_copy_tables_alloc(copy_tables);
}
*error = 1; *error = 1;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1338,6 +1347,6 @@ void spider_copy_tables_deinit_body( ...@@ -1338,6 +1347,6 @@ void spider_copy_tables_deinit_body(
!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) && !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) &&
(trx = spider_get_trx(thd, TRUE, &error_num)) (trx = spider_get_trx(thd, TRUE, &error_num))
) )
spider_free_trx_conn(trx, FALSE); spider_copy_table_free_trx_conn(trx);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* Copyright (C) 2010-2013 Kentoku Shiba /* Copyright (C) 2010-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
This diff is collapsed.
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -639,7 +639,8 @@ int spider_db_show_table_status( ...@@ -639,7 +639,8 @@ int spider_db_show_table_status(
int spider_db_show_records( int spider_db_show_records(
ha_spider *spider, ha_spider *spider,
int link_idx int link_idx,
bool pre_call
); );
void spider_db_set_cardinarity( void spider_db_set_cardinarity(
......
/* Copyright (C) 2012-2013 Kentoku Shiba /* Copyright (C) 2012-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 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( ...@@ -3262,10 +3262,15 @@ int spider_db_handlersocket_util::open_item_func(
func_name_length = strlen(func_name); func_name_length = strlen(func_name);
DBUG_PRINT("info",("spider func_name = %s", func_name)); DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (str->reserve(SPIDER_SQL_MBR_LEN + func_name_length + if (str->reserve(
SPIDER_SQL_OPEN_PAREN_LEN)) #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); 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); str->q_append(SPIDER_SQL_MBR_STR, SPIDER_SQL_MBR_LEN);
#endif
str->q_append(func_name, func_name_length); str->q_append(func_name, func_name_length);
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
} }
...@@ -3540,7 +3545,10 @@ int spider_handlersocket_share::init() ...@@ -3540,7 +3545,10 @@ int spider_handlersocket_share::init()
if ( if (
(error_num = create_table_names_str()) || (error_num = create_table_names_str()) ||
(
spider_share->table_share &&
(error_num = create_column_name_str()) (error_num = create_column_name_str())
)
) { ) {
DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(HA_ERR_OUT_OF_MEM);
} }
...@@ -3859,6 +3867,7 @@ spider_handlersocket_handler::~spider_handlersocket_handler() ...@@ -3859,6 +3867,7 @@ spider_handlersocket_handler::~spider_handlersocket_handler()
int spider_handlersocket_handler::init() int spider_handlersocket_handler::init()
{ {
st_spider_share *share = spider->share; st_spider_share *share = spider->share;
TABLE *table = spider->get_table();
DBUG_ENTER("spider_handlersocket_handler::init"); DBUG_ENTER("spider_handlersocket_handler::init");
DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider this=%p", this));
if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *) if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *)
...@@ -3866,6 +3875,8 @@ int spider_handlersocket_handler::init() ...@@ -3866,6 +3875,8 @@ int spider_handlersocket_handler::init()
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
&link_for_hash, &link_for_hash,
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count, sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
&minimum_select_bitmap,
table ? sizeof(uchar) * no_bytes_in_map(table->read_set) : 0,
NullS)) NullS))
) { ) {
DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(HA_ERR_OUT_OF_MEM);
...@@ -4072,10 +4083,12 @@ int spider_handlersocket_handler::append_minimum_select_without_quote( ...@@ -4072,10 +4083,12 @@ int spider_handlersocket_handler::append_minimum_select_without_quote(
int field_length; int field_length;
bool appended = FALSE; bool appended = FALSE;
DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_without_quote"); DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_without_quote");
minimum_select_bitmap_create();
for (field = table->field; *field; field++) for (field = table->field; *field; field++)
{ {
if (minimum_select_bit_is_set((*field)->field_index)) if (minimum_select_bit_is_set((*field)->field_index))
{ {
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
field_length = field_length =
handlersocket_share->column_name_str[(*field)->field_index].length(); handlersocket_share->column_name_str[(*field)->field_index].length();
if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN)) if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN))
...@@ -4331,7 +4344,8 @@ int spider_handlersocket_handler::append_is_null_part( ...@@ -4331,7 +4344,8 @@ int spider_handlersocket_handler::append_is_null_part(
KEY_PART_INFO *key_part, KEY_PART_INFO *key_part,
const key_range *key, const key_range *key,
const uchar **ptr, const uchar **ptr,
bool key_eq bool key_eq,
bool tgt_final
) { ) {
int error_num; int error_num;
spider_string *str; spider_string *str;
...@@ -4349,7 +4363,7 @@ int spider_handlersocket_handler::append_is_null_part( ...@@ -4349,7 +4363,7 @@ int spider_handlersocket_handler::append_is_null_part(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
error_num = append_is_null(sql_type, str, NULL, NULL, key_part, key, ptr, error_num = append_is_null(sql_type, str, NULL, NULL, key_part, key, ptr,
key_eq); key_eq, tgt_final);
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
...@@ -4361,7 +4375,8 @@ int spider_handlersocket_handler::append_is_null( ...@@ -4361,7 +4375,8 @@ int spider_handlersocket_handler::append_is_null(
KEY_PART_INFO *key_part, KEY_PART_INFO *key_part,
const key_range *key, const key_range *key,
const uchar **ptr, const uchar **ptr,
bool key_eq bool key_eq,
bool tgt_final
) { ) {
DBUG_ENTER("spider_handlersocket_handler::append_is_null"); DBUG_ENTER("spider_handlersocket_handler::append_is_null");
DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider this=%p", this));
...@@ -4448,6 +4463,19 @@ void spider_handlersocket_handler::set_order_to_pos( ...@@ -4448,6 +4463,19 @@ void spider_handlersocket_handler::set_order_to_pos(
DBUG_VOID_RETURN; 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( int spider_handlersocket_handler::append_key_order_for_merge_with_alias_part(
const char *alias, const char *alias,
uint alias_length, uint alias_length,
...@@ -5485,16 +5513,68 @@ bool spider_handlersocket_handler::support_use_handler( ...@@ -5485,16 +5513,68 @@ bool spider_handlersocket_handler::support_use_handler(
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
bool spider_handlersocket_handler::minimum_select_bit_is_set( void spider_handlersocket_handler::minimum_select_bitmap_create()
uint field_index {
) {
TABLE *table = spider->get_table(); TABLE *table = spider->get_table();
DBUG_ENTER("spider_handlersocket_handler::minimum_select_bit_is_set"); Field **field_p;
DBUG_RETURN( 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) | spider_bit_is_set(spider->searched_bitmap, field_index) |
bitmap_is_set(table->read_set, field_index) | bitmap_is_set(table->read_set, field_index) |
bitmap_is_set(table->write_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( void spider_handlersocket_handler::copy_minimum_select_bitmap(
...@@ -5508,18 +5588,10 @@ void spider_handlersocket_handler::copy_minimum_select_bitmap( ...@@ -5508,18 +5588,10 @@ void spider_handlersocket_handler::copy_minimum_select_bitmap(
roop_count++) roop_count++)
{ {
bitmap[roop_count] = bitmap[roop_count] =
spider->searched_bitmap[roop_count] | minimum_select_bitmap[roop_count];
((uchar *) table->read_set->bitmap)[roop_count] |
((uchar *) table->write_set->bitmap)[roop_count];
DBUG_PRINT("info",("spider roop_count=%d", roop_count)); DBUG_PRINT("info",("spider roop_count=%d", roop_count));
DBUG_PRINT("info",("spider bitmap=%d", DBUG_PRINT("info",("spider bitmap=%d",
bitmap[roop_count])); 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; DBUG_VOID_RETURN;
} }
......
/* Copyright (C) 2012-2013 Kentoku Shiba /* Copyright (C) 2012-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -493,6 +493,7 @@ public: ...@@ -493,6 +493,7 @@ public:
int hs_skip; int hs_skip;
spider_handlersocket_share *handlersocket_share; spider_handlersocket_share *handlersocket_share;
SPIDER_LINK_FOR_HASH *link_for_hash; SPIDER_LINK_FOR_HASH *link_for_hash;
uchar *minimum_select_bitmap;
spider_handlersocket_handler( spider_handlersocket_handler(
ha_spider *spider, ha_spider *spider,
spider_handlersocket_share *db_share spider_handlersocket_share *db_share
...@@ -627,7 +628,8 @@ public: ...@@ -627,7 +628,8 @@ public:
KEY_PART_INFO *key_part, KEY_PART_INFO *key_part,
const key_range *key, const key_range *key,
const uchar **ptr, const uchar **ptr,
bool key_eq bool key_eq,
bool tgt_final
); );
int append_is_null( int append_is_null(
ulong sql_type, ulong sql_type,
...@@ -637,7 +639,8 @@ public: ...@@ -637,7 +639,8 @@ public:
KEY_PART_INFO *key_part, KEY_PART_INFO *key_part,
const key_range *key, const key_range *key,
const uchar **ptr, const uchar **ptr,
bool key_eq bool key_eq,
bool tgt_final
); );
int append_where_terminator_part( int append_where_terminator_part(
ulong sql_type, ulong sql_type,
...@@ -671,6 +674,13 @@ public: ...@@ -671,6 +674,13 @@ public:
void set_order_to_pos( void set_order_to_pos(
ulong sql_type 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( int append_key_order_for_merge_with_alias_part(
const char *alias, const char *alias,
uint alias_length, uint alias_length,
...@@ -928,6 +938,7 @@ public: ...@@ -928,6 +938,7 @@ public:
bool support_use_handler( bool support_use_handler(
int use_handler int use_handler
); );
void minimum_select_bitmap_create();
bool minimum_select_bit_is_set( bool minimum_select_bit_is_set(
uint field_index uint field_index
); );
......
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -26,11 +26,20 @@ ...@@ -26,11 +26,20 @@
#define SPIDER_HAS_SHOW_SIMPLE_FUNC #define SPIDER_HAS_SHOW_SIMPLE_FUNC
#endif #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 #if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100004
#define SPIDER_HAS_TIME_STATUS #define SPIDER_HAS_TIME_STATUS
#define SPIDER_HAS_DECIMAL_OPERATION_RESULTS_VALUE_TYPE #define SPIDER_HAS_DECIMAL_OPERATION_RESULTS_VALUE_TYPE
#endif #endif
#if defined(MARIADB_BASE_VERSION)
#define SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
#endif
class spider_db_conn; class spider_db_conn;
typedef spider_db_conn SPIDER_DB_CONN; typedef spider_db_conn SPIDER_DB_CONN;
class spider_db_result; class spider_db_result;
...@@ -1120,7 +1129,8 @@ public: ...@@ -1120,7 +1129,8 @@ public:
KEY_PART_INFO *key_part, KEY_PART_INFO *key_part,
const key_range *key, const key_range *key,
const uchar **ptr, const uchar **ptr,
bool key_eq bool key_eq,
bool tgt_final
) = 0; ) = 0;
virtual int append_where_terminator_part( virtual int append_where_terminator_part(
ulong sql_type, ulong sql_type,
...@@ -1154,6 +1164,13 @@ public: ...@@ -1154,6 +1164,13 @@ public:
virtual void set_order_to_pos( virtual void set_order_to_pos(
ulong sql_type ulong sql_type
) = 0; ) = 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( virtual int append_key_order_for_merge_with_alias_part(
const char *alias, const char *alias,
uint alias_length, uint alias_length,
...@@ -1578,6 +1595,8 @@ typedef struct st_spider_result_list ...@@ -1578,6 +1595,8 @@ typedef struct st_spider_result_list
uint *sql_kind_backup; uint *sql_kind_backup;
uint sql_kinds_backup; uint sql_kinds_backup;
bool use_union; bool use_union;
bool use_both_key;
const key_range *end_key;
spider_string *insert_sqls; spider_string *insert_sqls;
spider_string *update_sqls; spider_string *update_sqls;
TABLE **upd_tmp_tbls; TABLE **upd_tmp_tbls;
...@@ -1624,6 +1643,7 @@ typedef struct st_spider_result_list ...@@ -1624,6 +1643,7 @@ typedef struct st_spider_result_list
longlong first_read; longlong first_read;
longlong second_read; longlong second_read;
int set_split_read_count; int set_split_read_count;
int *casual_read;
#ifndef WITHOUT_SPIDER_BG_SEARCH #ifndef WITHOUT_SPIDER_BG_SEARCH
/* 0:nomal 1:store 2:store end */ /* 0:nomal 1:store 2:store end */
volatile volatile
......
This diff is collapsed.
/* Copyright (C) 2012-2013 Kentoku Shiba /* Copyright (C) 2012-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -271,6 +271,9 @@ public: ...@@ -271,6 +271,9 @@ public:
bool is_xa_nota_error( bool is_xa_nota_error(
int error_num int error_num
); );
void print_warnings(
struct tm *l_time
);
spider_db_result *store_result( spider_db_result *store_result(
spider_db_result_buffer **spider_res_buf, spider_db_result_buffer **spider_res_buf,
st_spider_db_request_key *request_key, st_spider_db_request_key *request_key,
...@@ -539,6 +542,7 @@ class spider_mysql_handler: public spider_db_handler ...@@ -539,6 +542,7 @@ class spider_mysql_handler: public spider_db_handler
public: public:
spider_mysql_share *mysql_share; spider_mysql_share *mysql_share;
SPIDER_LINK_FOR_HASH *link_for_hash; SPIDER_LINK_FOR_HASH *link_for_hash;
uchar *minimum_select_bitmap;
spider_mysql_handler( spider_mysql_handler(
ha_spider *spider, ha_spider *spider,
spider_mysql_share *share spider_mysql_share *share
...@@ -787,7 +791,8 @@ public: ...@@ -787,7 +791,8 @@ public:
KEY_PART_INFO *key_part, KEY_PART_INFO *key_part,
const key_range *key, const key_range *key,
const uchar **ptr, const uchar **ptr,
bool key_eq bool key_eq,
bool tgt_final
); );
int append_is_null( int append_is_null(
ulong sql_type, ulong sql_type,
...@@ -797,7 +802,8 @@ public: ...@@ -797,7 +802,8 @@ public:
KEY_PART_INFO *key_part, KEY_PART_INFO *key_part,
const key_range *key, const key_range *key,
const uchar **ptr, const uchar **ptr,
bool key_eq bool key_eq,
bool tgt_final
); );
int append_where_terminator_part( int append_where_terminator_part(
ulong sql_type, ulong sql_type,
...@@ -877,6 +883,11 @@ public: ...@@ -877,6 +883,11 @@ public:
ulong sql_type ulong sql_type
); );
#ifdef HANDLER_HAS_DIRECT_AGGREGATE #ifdef HANDLER_HAS_DIRECT_AGGREGATE
int append_group_by_part(
const char *alias,
uint alias_length,
ulong sql_type
);
int append_group_by( int append_group_by(
spider_string *str, spider_string *str,
const char *alias, const char *alias,
...@@ -1277,6 +1288,7 @@ public: ...@@ -1277,6 +1288,7 @@ public:
bool support_use_handler( bool support_use_handler(
int use_handler int use_handler
); );
void minimum_select_bitmap_create();
bool minimum_select_bit_is_set( bool minimum_select_bit_is_set(
uint field_index uint field_index
); );
......
This diff is collapsed.
/* Copyright (C) 2012-2013 Kentoku Shiba /* Copyright (C) 2012-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 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 ...@@ -622,6 +622,7 @@ class spider_oracle_handler: public spider_db_handler
public: public:
spider_oracle_share *oracle_share; spider_oracle_share *oracle_share;
SPIDER_LINK_FOR_HASH *link_for_hash; SPIDER_LINK_FOR_HASH *link_for_hash;
uchar *minimum_select_bitmap;
spider_oracle_handler( spider_oracle_handler(
ha_spider *spider, ha_spider *spider,
spider_oracle_share *share spider_oracle_share *share
...@@ -870,7 +871,8 @@ public: ...@@ -870,7 +871,8 @@ public:
KEY_PART_INFO *key_part, KEY_PART_INFO *key_part,
const key_range *key, const key_range *key,
const uchar **ptr, const uchar **ptr,
bool key_eq bool key_eq,
bool tgt_final
); );
int append_is_null( int append_is_null(
ulong sql_type, ulong sql_type,
...@@ -880,7 +882,8 @@ public: ...@@ -880,7 +882,8 @@ public:
KEY_PART_INFO *key_part, KEY_PART_INFO *key_part,
const key_range *key, const key_range *key,
const uchar **ptr, const uchar **ptr,
bool key_eq bool key_eq,
bool tgt_final
); );
int append_where_terminator_part( int append_where_terminator_part(
ulong sql_type, ulong sql_type,
...@@ -960,6 +963,11 @@ public: ...@@ -960,6 +963,11 @@ public:
ulong sql_type ulong sql_type
); );
#ifdef HANDLER_HAS_DIRECT_AGGREGATE #ifdef HANDLER_HAS_DIRECT_AGGREGATE
int append_group_by_part(
const char *alias,
uint alias_length,
ulong sql_type
);
int append_group_by( int append_group_by(
spider_string *str, spider_string *str,
const char *alias, const char *alias,
...@@ -1363,6 +1371,7 @@ public: ...@@ -1363,6 +1371,7 @@ public:
bool support_use_handler( bool support_use_handler(
int use_handler int use_handler
); );
void minimum_select_bitmap_create();
bool minimum_select_bit_is_set( bool minimum_select_bit_is_set(
uint field_index uint field_index
); );
......
/* Copyright (C) 2009-2013 Kentoku Shiba /* Copyright (C) 2009-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -40,6 +40,10 @@ ...@@ -40,6 +40,10 @@
#include "spd_udf.h" #include "spd_udf.h"
#include "spd_malloc.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_extra_file;
extern const char **spd_defaults_file; extern const char **spd_defaults_file;
...@@ -1604,8 +1608,16 @@ long long spider_direct_sql_body( ...@@ -1604,8 +1608,16 @@ long long spider_direct_sql_body(
#endif #endif
for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) 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.db = direct_sql->db_names[roop_count];
table_list.table_name = direct_sql->table_names[roop_count]; table_list.table_name = direct_sql->table_names[roop_count];
#endif
if (!(direct_sql->tables[roop_count] = if (!(direct_sql->tables[roop_count] =
find_temporary_table(thd, &table_list))) find_temporary_table(thd, &table_list)))
{ {
......
/* Copyright (C) 2009-2013 Kentoku Shiba /* Copyright (C) 2009-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
#define ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR "Can't use wrapper '%s' for NOSQL connection" #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_NUM 12523
#define ER_SPIDER_REQUEST_KEY_STR "Request key not found" #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_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" #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"
......
/* Copyright (C) 2012-2013 Kentoku Shiba /* Copyright (C) 2012-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 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( ...@@ -128,7 +128,7 @@ static int spider_i_s_alloc_mem_deinit(
DBUG_RETURN(0); 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, MYSQL_INFORMATION_SCHEMA_PLUGIN,
&spider_i_s_info, &spider_i_s_info,
...@@ -141,6 +141,27 @@ struct st_maria_plugin spider_i_s_alloc_mem = ...@@ -141,6 +141,27 @@ struct st_maria_plugin spider_i_s_alloc_mem =
0x0001, 0x0001,
NULL, NULL,
NULL, NULL,
"0.1", NULL,
MariaDB_PLUGIN_MATURITY_BETA #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
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 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 #if MYSQL_VERSION_ID < 50500
#else #else
#define my_free(A,B) my_free(A) #define my_free(A,B) my_free(A)
...@@ -77,8 +80,13 @@ ...@@ -77,8 +80,13 @@
#define spider_stmt_da_message(A) (A)->main_da.message() #define spider_stmt_da_message(A) (A)->main_da.message()
#define spider_stmt_da_sql_errno(A) (A)->main_da.sql_errno() #define spider_stmt_da_sql_errno(A) (A)->main_da.sql_errno()
#else #else
#if MYSQL_VERSION_ID < 50600
#define spider_stmt_da_message(A) (A)->stmt_da->message() #define spider_stmt_da_message(A) (A)->stmt_da->message()
#define spider_stmt_da_sql_errno(A) (A)->stmt_da->sql_errno() #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 #endif
#define spider_user_defined_key_parts(A) (A)->key_parts #define spider_user_defined_key_parts(A) (A)->key_parts
#define SPIDER_ALTER_ADD_PARTITION ALTER_ADD_PARTITION #define SPIDER_ALTER_ADD_PARTITION ALTER_ADD_PARTITION
...@@ -91,6 +99,12 @@ ...@@ -91,6 +99,12 @@
#define SPIDER_WARN_LEVEL_NOTE MYSQL_ERROR::WARN_LEVEL_NOTE #define SPIDER_WARN_LEVEL_NOTE MYSQL_ERROR::WARN_LEVEL_NOTE
#endif #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 #if MYSQL_VERSION_ID >= 50500
#define SPIDER_HAS_HASH_VALUE_TYPE #define SPIDER_HAS_HASH_VALUE_TYPE
#endif #endif
...@@ -118,7 +132,7 @@ ...@@ -118,7 +132,7 @@
#define SPIDER_TMP_SHARE_LONG_COUNT 15 #define SPIDER_TMP_SHARE_LONG_COUNT 15
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3 #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 \ #define SPIDER_BACKUP_DASTATUS \
bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE; bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE;
...@@ -134,7 +148,7 @@ ...@@ -134,7 +148,7 @@
#define SPIDER_SET_FILE_POS(A) \ #define SPIDER_SET_FILE_POS(A) \
{(A)->thd = current_thd; (A)->func_name = __func__; (A)->file_name = __FILE__; (A)->line_no = __LINE__;} {(A)->thd = current_thd; (A)->func_name = __func__; (A)->file_name = __FILE__; (A)->line_no = __LINE__;}
#define SPIDER_CLEAR_FILE_POS(A) \ #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; class ha_spider;
typedef struct st_spider_share SPIDER_SHARE; typedef struct st_spider_share SPIDER_SHARE;
...@@ -261,6 +275,9 @@ typedef struct st_spider_conn ...@@ -261,6 +275,9 @@ typedef struct st_spider_conn
uint opened_handlers; uint opened_handlers;
ulonglong conn_id; ulonglong conn_id;
ulonglong connection_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; pthread_mutex_t mta_conn_mutex;
volatile bool mta_conn_mutex_lock_already; volatile bool mta_conn_mutex_lock_already;
volatile bool mta_conn_mutex_unlock_later; volatile bool mta_conn_mutex_unlock_later;
...@@ -473,6 +490,7 @@ typedef struct st_spider_transaction ...@@ -473,6 +490,7 @@ typedef struct st_spider_transaction
bool trx_start; bool trx_start;
bool trx_xa; bool trx_xa;
bool trx_consistent_snapshot; bool trx_consistent_snapshot;
bool trx_xa_prepared;
bool use_consistent_snapshot; bool use_consistent_snapshot;
bool internal_xa; bool internal_xa;
...@@ -571,6 +589,18 @@ typedef struct st_spider_transaction ...@@ -571,6 +589,18 @@ typedef struct st_spider_transaction
longlong current_alloc_mem_buffer[SPIDER_MEM_CALC_LIST_NUM]; longlong current_alloc_mem_buffer[SPIDER_MEM_CALC_LIST_NUM];
ulonglong alloc_mem_count_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]; 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; } SPIDER_TRX;
typedef struct st_spider_share typedef struct st_spider_share
...@@ -734,6 +764,8 @@ typedef struct st_spider_share ...@@ -734,6 +764,8 @@ typedef struct st_spider_share
#ifdef HA_CAN_FORCE_BULK_DELETE #ifdef HA_CAN_FORCE_BULK_DELETE
int force_bulk_delete; int force_bulk_delete;
#endif #endif
int casual_read;
int delete_all_rows_type;
int bka_mode; int bka_mode;
char *bka_engine; char *bka_engine;
......
/* Copyright (C) 2012-2013 Kentoku Shiba /* Copyright (C) 2012-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
/* Copyright (C) 2012-2013 Kentoku Shiba /* Copyright (C) 2012-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -32,7 +32,10 @@ ...@@ -32,7 +32,10 @@
#include "spd_table.h" #include "spd_table.h"
#include "spd_trx.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;
extern volatile ulonglong spider_mon_table_cache_version_req; extern volatile ulonglong spider_mon_table_cache_version_req;
...@@ -2827,6 +2830,136 @@ uint spider_param_log_result_errors() ...@@ -2827,6 +2830,136 @@ uint spider_param_log_result_errors()
DBUG_RETURN(spider_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 = static struct st_mysql_storage_engine spider_storage_engine =
{ MYSQL_HANDLERTON_INTERFACE_VERSION }; { MYSQL_HANDLERTON_INTERFACE_VERSION };
...@@ -2954,10 +3087,16 @@ static struct st_mysql_sys_var* spider_system_variables[] = { ...@@ -2954,10 +3087,16 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
#endif #endif
MYSQL_SYSVAR(general_log), MYSQL_SYSVAR(general_log),
MYSQL_SYSVAR(log_result_errors), 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 NULL
}; };
maria_declare_plugin(spider) mysql_declare_plugin(spider)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&spider_storage_engine, &spider_storage_engine,
...@@ -2967,11 +3106,34 @@ maria_declare_plugin(spider) ...@@ -2967,11 +3106,34 @@ maria_declare_plugin(spider)
PLUGIN_LICENSE_GPL, PLUGIN_LICENSE_GPL,
spider_db_init, spider_db_init,
spider_db_done, spider_db_done,
0x0300, SPIDER_HEX_VERSION,
spider_status_variables, spider_status_variables,
spider_system_variables, spider_system_variables,
"3.0", NULL,
MariaDB_PLUGIN_MATURITY_BETA #if MYSQL_VERSION_ID >= 50600
0,
#endif
}, },
spider_i_s_alloc_mem spider_i_s_alloc_mem
mysql_declare_plugin_end;
#ifdef MARIADB_BASE_VERSION
maria_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,
SPIDER_DETAIL_VERSION,
MariaDB_PLUGIN_MATURITY_GAMMA
},
spider_i_s_alloc_mem_maria
maria_declare_plugin_end; maria_declare_plugin_end;
#endif
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software); you can redistribute it and/or modify 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 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( ...@@ -370,3 +370,16 @@ int spider_param_udf_ds_use_real_table(
#endif #endif
my_bool spider_param_general_log(); my_bool spider_param_general_log();
uint spider_param_log_result_errors(); 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
);
/* Copyright (C) 2009-2013 Kentoku Shiba /* Copyright (C) 2009-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
/* Copyright (C) 2009-2013 Kentoku Shiba /* Copyright (C) 2009-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -90,7 +90,10 @@ TABLE *spider_open_sys_table( ...@@ -90,7 +90,10 @@ TABLE *spider_open_sys_table(
if (!(table = spider_sys_open_table(thd, &tables, open_tables_backup))) if (!(table = spider_sys_open_table(thd, &tables, open_tables_backup)))
#endif #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); DBUG_RETURN(NULL);
} }
#if MYSQL_VERSION_ID < 50500 #if MYSQL_VERSION_ID < 50500
...@@ -117,7 +120,10 @@ TABLE *spider_open_sys_table( ...@@ -117,7 +120,10 @@ TABLE *spider_open_sys_table(
table, FALSE) table, FALSE)
) { ) {
release_table_share(table_share, RELEASE_NORMAL); 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; goto error;
} }
} }
...@@ -1913,7 +1919,6 @@ int spider_sys_update_tables_link_status( ...@@ -1913,7 +1919,6 @@ int spider_sys_update_tables_link_status(
SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock, SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock,
&error_num)) &error_num))
) { ) {
my_error(error_num, MYF(0));
goto error; goto error;
} }
if ((error_num = spider_update_tables_link_status(table_tables, if ((error_num = spider_update_tables_link_status(table_tables,
...@@ -1952,7 +1957,6 @@ int spider_sys_log_tables_link_failed( ...@@ -1952,7 +1957,6 @@ int spider_sys_log_tables_link_failed(
SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup, SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup,
need_lock, &error_num)) need_lock, &error_num))
) { ) {
my_error(error_num, MYF(0));
goto error; goto error;
} }
empty_record(table_tables); empty_record(table_tables);
...@@ -1992,7 +1996,6 @@ int spider_sys_log_xa_failed( ...@@ -1992,7 +1996,6 @@ int spider_sys_log_xa_failed(
SPIDER_SYS_XA_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup, SPIDER_SYS_XA_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup,
need_lock, &error_num)) need_lock, &error_num))
) { ) {
my_error(error_num, MYF(0));
goto error; goto error;
} }
empty_record(table_tables); empty_record(table_tables);
......
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
This diff is collapsed.
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
This diff is collapsed.
/* Copyright (C) 2008-2013 Kentoku Shiba /* Copyright (C) 2008-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -208,6 +208,10 @@ int spider_xa_rollback_by_xid( ...@@ -208,6 +208,10 @@ int spider_xa_rollback_by_xid(
XID* xid XID* xid
); );
void spider_copy_table_free_trx_conn(
SPIDER_TRX *trx
);
int spider_end_trx( int spider_end_trx(
SPIDER_TRX *trx, SPIDER_TRX *trx,
SPIDER_CONN *conn SPIDER_CONN *conn
......
/* Copyright (C) 2009-2013 Kentoku Shiba /* Copyright (C) 2009-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
/* Copyright (C) 2009-2013 Kentoku Shiba /* Copyright (C) 2009-2014 Kentoku Shiba
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment