Commit 94861b83 authored by Kentoku SHIBA's avatar Kentoku SHIBA

prepare for adding new connectors for Spider

Conflicts:
	storage/spider/spd_conn.cc
parent 23c8adda
...@@ -10028,6 +10028,28 @@ int ha_spider::update_row( ...@@ -10028,6 +10028,28 @@ int ha_spider::update_row(
} }
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool ha_spider::check_direct_update_sql_part(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
) {
uint roop_count, dbton_id;
spider_db_handler *dbton_hdl;
DBUG_ENTER("ha_spider::check_direct_update_sql_part");
for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++)
{
dbton_id = share->use_sql_dbton_ids[roop_count];
dbton_hdl = dbton_handler[dbton_id];
if (
dbton_hdl->first_link_idx >= 0 &&
dbton_hdl->check_direct_update(select_lex, select_limit, offset_limit)
) {
DBUG_RETURN(TRUE);
}
}
DBUG_RETURN(FALSE);
}
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
#ifdef SPIDER_MDEV_16246 #ifdef SPIDER_MDEV_16246
int ha_spider::direct_update_rows_init( int ha_spider::direct_update_rows_init(
...@@ -10118,6 +10140,7 @@ int ha_spider::direct_update_rows_init( ...@@ -10118,6 +10140,7 @@ int ha_spider::direct_update_rows_init(
!select_lex || !select_lex ||
select_lex->table_list.elements != 1 || select_lex->table_list.elements != 1 ||
check_update_columns_sql_part() || check_update_columns_sql_part() ||
check_direct_update_sql_part(select_lex, select_limit, offset_limit) ||
spider_db_append_condition(this, NULL, 0, TRUE) spider_db_append_condition(this, NULL, 0, TRUE)
) { ) {
DBUG_PRINT("info",("spider FALSE by condition")); DBUG_PRINT("info",("spider FALSE by condition"));
...@@ -10292,6 +10315,7 @@ int ha_spider::direct_update_rows_init() ...@@ -10292,6 +10315,7 @@ int ha_spider::direct_update_rows_init()
!select_lex || !select_lex ||
select_lex->table_list.elements != 1 || select_lex->table_list.elements != 1 ||
check_update_columns_sql_part() || check_update_columns_sql_part() ||
check_direct_update_sql_part(select_lex, select_limit, offset_limit) ||
spider_db_append_condition(this, NULL, 0, TRUE) spider_db_append_condition(this, NULL, 0, TRUE)
) { ) {
DBUG_PRINT("info",("spider FALSE by condition")); DBUG_PRINT("info",("spider FALSE by condition"));
...@@ -10649,6 +10673,28 @@ int ha_spider::delete_row( ...@@ -10649,6 +10673,28 @@ int ha_spider::delete_row(
} }
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool ha_spider::check_direct_delete_sql_part(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
) {
uint roop_count, dbton_id;
spider_db_handler *dbton_hdl;
DBUG_ENTER("ha_spider::check_direct_delete_sql_part");
for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++)
{
dbton_id = share->use_sql_dbton_ids[roop_count];
dbton_hdl = dbton_handler[dbton_id];
if (
dbton_hdl->first_link_idx >= 0 &&
dbton_hdl->check_direct_delete(select_lex, select_limit, offset_limit)
) {
DBUG_RETURN(TRUE);
}
}
DBUG_RETURN(FALSE);
}
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
int ha_spider::direct_delete_rows_init( int ha_spider::direct_delete_rows_init(
uint mode, uint mode,
...@@ -10716,6 +10762,7 @@ int ha_spider::direct_delete_rows_init( ...@@ -10716,6 +10762,7 @@ int ha_spider::direct_delete_rows_init(
#endif #endif
!select_lex || !select_lex ||
select_lex->table_list.elements != 1 || select_lex->table_list.elements != 1 ||
check_direct_delete_sql_part(select_lex, select_limit, offset_limit) ||
spider_db_append_condition(this, NULL, 0, TRUE) spider_db_append_condition(this, NULL, 0, TRUE)
) { ) {
DBUG_PRINT("info",("spider FALSE by condition")); DBUG_PRINT("info",("spider FALSE by condition"));
...@@ -10821,6 +10868,7 @@ int ha_spider::direct_delete_rows_init() ...@@ -10821,6 +10868,7 @@ int ha_spider::direct_delete_rows_init()
#endif #endif
!select_lex || !select_lex ||
select_lex->table_list.elements != 1 || select_lex->table_list.elements != 1 ||
check_direct_delete_sql_part(select_lex, select_limit, offset_limit) ||
spider_db_append_condition(this, NULL, 0, TRUE) spider_db_append_condition(this, NULL, 0, TRUE)
) { ) {
DBUG_PRINT("info",("spider FALSE by condition")); DBUG_PRINT("info",("spider FALSE by condition"));
......
...@@ -585,6 +585,11 @@ class ha_spider: public handler ...@@ -585,6 +585,11 @@ class ha_spider: public handler
); );
#endif #endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool check_direct_update_sql_part(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
);
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
#ifdef SPIDER_MDEV_16246 #ifdef SPIDER_MDEV_16246
inline int direct_update_rows_init( inline int direct_update_rows_init(
...@@ -709,6 +714,11 @@ class ha_spider: public handler ...@@ -709,6 +714,11 @@ class ha_spider: public handler
const uchar *buf const uchar *buf
); );
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool check_direct_delete_sql_part(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
);
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
inline int direct_delete_rows_init() inline int direct_delete_rows_init()
{ {
......
/* Copyright (C) 2008-2019 Kentoku Shiba /* Copyright (C) 2008-2020 Kentoku Shiba
Copyright (C) 2019, 2020, MariaDB Corporation. Copyright (C) 2019, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
...@@ -563,7 +563,7 @@ SPIDER_CONN *spider_create_conn( ...@@ -563,7 +563,7 @@ SPIDER_CONN *spider_create_conn(
SPIDER_CONN *conn; SPIDER_CONN *conn;
SPIDER_IP_PORT_CONN *ip_port_conn; SPIDER_IP_PORT_CONN *ip_port_conn;
char *tmp_name, *tmp_host, *tmp_username, *tmp_password, *tmp_socket; char *tmp_name, *tmp_host, *tmp_username, *tmp_password, *tmp_socket;
char *tmp_wrapper, *tmp_ssl_ca, *tmp_ssl_capath, *tmp_ssl_cert; char *tmp_wrapper, *tmp_db, *tmp_ssl_ca, *tmp_ssl_capath, *tmp_ssl_cert;
char *tmp_ssl_cipher, *tmp_ssl_key, *tmp_default_file, *tmp_default_group; char *tmp_ssl_cipher, *tmp_ssl_key, *tmp_default_file, *tmp_default_group;
DBUG_ENTER("spider_create_conn"); DBUG_ENTER("spider_create_conn");
...@@ -578,6 +578,15 @@ SPIDER_CONN *spider_create_conn( ...@@ -578,6 +578,15 @@ SPIDER_CONN *spider_create_conn(
if (conn_kind == SPIDER_CONN_KIND_MYSQL) if (conn_kind == SPIDER_CONN_KIND_MYSQL)
{ {
#endif #endif
bool tables_on_different_db_are_joinable;
if (share->sql_dbton_ids[link_idx] != SPIDER_DBTON_SIZE)
{
tables_on_different_db_are_joinable =
spider_dbton[share->sql_dbton_ids[link_idx]].db_util->
tables_on_different_db_are_joinable();
} else {
tables_on_different_db_are_joinable = TRUE;
}
if (!(conn = (SPIDER_CONN *) if (!(conn = (SPIDER_CONN *)
spider_bulk_malloc(spider_current_trx, 18, MYF(MY_WME | MY_ZEROFILL), spider_bulk_malloc(spider_current_trx, 18, MYF(MY_WME | MY_ZEROFILL),
&conn, (uint) (sizeof(*conn)), &conn, (uint) (sizeof(*conn)),
...@@ -590,6 +599,8 @@ SPIDER_CONN *spider_create_conn( ...@@ -590,6 +599,8 @@ SPIDER_CONN *spider_create_conn(
&tmp_socket, (uint) (share->tgt_sockets_lengths[link_idx] + 1), &tmp_socket, (uint) (share->tgt_sockets_lengths[link_idx] + 1),
&tmp_wrapper, &tmp_wrapper,
(uint) (share->tgt_wrappers_lengths[link_idx] + 1), (uint) (share->tgt_wrappers_lengths[link_idx] + 1),
&tmp_db, (uint) (tables_on_different_db_are_joinable ?
0 : share->tgt_dbs_lengths[link_idx] + 1),
&tmp_ssl_ca, (uint) (share->tgt_ssl_cas_lengths[link_idx] + 1), &tmp_ssl_ca, (uint) (share->tgt_ssl_cas_lengths[link_idx] + 1),
&tmp_ssl_capath, &tmp_ssl_capath,
(uint) (share->tgt_ssl_capaths_lengths[link_idx] + 1), (uint) (share->tgt_ssl_capaths_lengths[link_idx] + 1),
...@@ -638,6 +649,13 @@ SPIDER_CONN *spider_create_conn( ...@@ -638,6 +649,13 @@ SPIDER_CONN *spider_create_conn(
conn->tgt_wrapper = tmp_wrapper; conn->tgt_wrapper = tmp_wrapper;
memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx], memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx],
share->tgt_wrappers_lengths[link_idx]); share->tgt_wrappers_lengths[link_idx]);
if (!tables_on_different_db_are_joinable)
{
conn->tgt_db_length = share->tgt_dbs_lengths[link_idx];
conn->tgt_db = tmp_db;
memcpy(conn->tgt_db, share->tgt_dbs[link_idx],
share->tgt_dbs_lengths[link_idx]);
}
conn->tgt_ssl_ca_length = share->tgt_ssl_cas_lengths[link_idx]; conn->tgt_ssl_ca_length = share->tgt_ssl_cas_lengths[link_idx];
if (conn->tgt_ssl_ca_length) if (conn->tgt_ssl_ca_length)
{ {
...@@ -1878,8 +1896,8 @@ int spider_conn_queue_loop_check( ...@@ -1878,8 +1896,8 @@ int spider_conn_queue_loop_check(
my_afree(loop_check_buf); my_afree(loop_check_buf);
to_str.length = build_table_filename(path, FN_REFLEN, to_str.length = build_table_filename(path, FN_REFLEN,
share->tgt_dbs[conn_link_idx], share->tgt_table_names[conn_link_idx], share->tgt_dbs[conn_link_idx] ? share->tgt_dbs[conn_link_idx] : "",
"", 0); share->tgt_table_names[conn_link_idx], "", 0);
to_str.str = path; to_str.str = path;
DBUG_PRINT("info", ("spider to=%s", to_str.str)); DBUG_PRINT("info", ("spider to=%s", to_str.str));
buf_sz = from_str.length + top_share->path.length + to_str.length + 3; buf_sz = from_str.length + top_share->path.length + to_str.length + 3;
...@@ -2831,6 +2849,21 @@ int spider_bg_conn_search( ...@@ -2831,6 +2849,21 @@ int spider_bg_conn_search(
} }
} }
result_list->bgs_phase = 2; result_list->bgs_phase = 2;
if (conn->db_conn->limit_mode() == 1)
{
conn->db_conn->set_limit(result_list->limit_num);
if (!discard_result)
{
if ((error_num = spider_db_store_result_for_reuse_cursor(
spider, link_idx, result_list->table)))
{
pthread_mutex_unlock(&conn->bg_conn_mutex);
DBUG_RETURN(error_num);
}
}
pthread_mutex_unlock(&conn->bg_conn_mutex);
DBUG_RETURN(0);
}
} }
result_list->bgs_working = TRUE; result_list->bgs_working = TRUE;
conn->bg_search = TRUE; conn->bg_search = TRUE;
...@@ -2965,6 +2998,21 @@ int spider_bg_conn_search( ...@@ -2965,6 +2998,21 @@ int spider_bg_conn_search(
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
} }
if (conn->db_conn->limit_mode() == 1)
{
conn->db_conn->set_limit(result_list->limit_num);
if (!discard_result)
{
if ((error_num = spider_db_store_result_for_reuse_cursor(
spider, link_idx, result_list->table)))
{
pthread_mutex_unlock(&conn->bg_conn_mutex);
DBUG_RETURN(error_num);
}
}
pthread_mutex_unlock(&conn->bg_conn_mutex);
DBUG_RETURN(0);
}
} }
conn->bg_target = spider; conn->bg_target = spider;
conn->link_idx = link_idx; conn->link_idx = link_idx;
......
/* Copyright (C) 2008-2019 Kentoku Shiba /* Copyright (C) 2008-2020 Kentoku Shiba
Copyright (C) 2019 MariaDB corp Copyright (C) 2019-2020 MariaDB corp
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-2019 Kentoku Shiba /* Copyright (C) 2008-2020 Kentoku Shiba
Copyright (C) 2019 MariaDB corp Copyright (C) 2019-2020 MariaDB corp
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 @@
#define SPIDER_SQL_OPEN_PAREN_LEN (sizeof(SPIDER_SQL_OPEN_PAREN_STR) - 1) #define SPIDER_SQL_OPEN_PAREN_LEN (sizeof(SPIDER_SQL_OPEN_PAREN_STR) - 1)
#define SPIDER_SQL_CLOSE_PAREN_STR ")" #define SPIDER_SQL_CLOSE_PAREN_STR ")"
#define SPIDER_SQL_CLOSE_PAREN_LEN (sizeof(SPIDER_SQL_CLOSE_PAREN_STR) - 1) #define SPIDER_SQL_CLOSE_PAREN_LEN (sizeof(SPIDER_SQL_CLOSE_PAREN_STR) - 1)
#define SPIDER_SQL_OPEN_BRACE_STR "{"
#define SPIDER_SQL_OPEN_BRACE_LEN (sizeof(SPIDER_SQL_OPEN_BRACE_STR) - 1)
#define SPIDER_SQL_CLOSE_BRACE_STR "}"
#define SPIDER_SQL_CLOSE_BRACE_LEN (sizeof(SPIDER_SQL_CLOSE_BRACE_STR) - 1)
#define SPIDER_SQL_COMMA_STR "," #define SPIDER_SQL_COMMA_STR ","
#define SPIDER_SQL_COMMA_LEN (sizeof(SPIDER_SQL_COMMA_STR) - 1) #define SPIDER_SQL_COMMA_LEN (sizeof(SPIDER_SQL_COMMA_STR) - 1)
#define SPIDER_SQL_UNION_ALL_STR ")union all(" #define SPIDER_SQL_UNION_ALL_STR ")union all("
...@@ -608,6 +612,12 @@ int spider_db_store_result( ...@@ -608,6 +612,12 @@ int spider_db_store_result(
TABLE *table TABLE *table
); );
int spider_db_store_result_for_reuse_cursor(
ha_spider *spider,
int link_idx,
TABLE *table
);
void spider_db_discard_result( void spider_db_discard_result(
ha_spider *spider, ha_spider *spider,
int link_idx, int link_idx,
...@@ -1052,6 +1062,13 @@ int spider_db_append_update_columns( ...@@ -1052,6 +1062,13 @@ int spider_db_append_update_columns(
); );
#endif #endif
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
bool spider_db_check_select_colum_in_group(
st_select_lex *select_lex,
Field *field
);
#endif
uint spider_db_check_ft_idx( uint spider_db_check_ft_idx(
Item_func *item_func, Item_func *item_func,
ha_spider *spider ha_spider *spider
......
/* Copyright (C) 2018-2019 Kentoku Shiba /* Copyright (C) 2018-2020 Kentoku Shiba
Copyright (C) 2018-2020 MariaDB corp
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
...@@ -33,6 +34,8 @@ ...@@ -33,6 +34,8 @@
#include "spd_include.h" #include "spd_include.h"
#include "spd_conn.h" #include "spd_conn.h"
extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE];
spider_db_result::spider_db_result( spider_db_result::spider_db_result(
SPIDER_DB_CONN *in_db_conn SPIDER_DB_CONN *in_db_conn
) : db_conn(in_db_conn), dbton_id(in_db_conn->dbton_id) ) : db_conn(in_db_conn), dbton_id(in_db_conn->dbton_id)
...@@ -52,6 +55,13 @@ int spider_db_result::fetch_table_checksum( ...@@ -52,6 +55,13 @@ int spider_db_result::fetch_table_checksum(
} }
#endif #endif
uint spider_db_result::limit_mode()
{
DBUG_ENTER("spider_db_result::limit_mode");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(spider_dbton[dbton_id].db_util->limit_mode());
}
spider_db_conn::spider_db_conn( spider_db_conn::spider_db_conn(
SPIDER_CONN *in_conn SPIDER_CONN *in_conn
) : conn(in_conn), dbton_id(in_conn->dbton_id) ) : conn(in_conn), dbton_id(in_conn->dbton_id)
...@@ -110,6 +120,13 @@ int spider_db_conn::fin_loop_check() ...@@ -110,6 +120,13 @@ int spider_db_conn::fin_loop_check()
DBUG_RETURN(0); DBUG_RETURN(0);
} }
uint spider_db_conn::limit_mode()
{
DBUG_ENTER("spider_db_conn::limit_mode");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(spider_dbton[dbton_id].db_util->limit_mode());
}
int spider_db_util::append_loop_check( int spider_db_util::append_loop_check(
spider_string *str, spider_string *str,
SPIDER_CONN *conn SPIDER_CONN *conn
...@@ -120,6 +137,41 @@ int spider_db_util::append_loop_check( ...@@ -120,6 +137,41 @@ int spider_db_util::append_loop_check(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
bool spider_db_util::tables_on_different_db_are_joinable()
{
DBUG_ENTER("spider_db_util::tables_on_different_db_are_joinable");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(TRUE);
}
bool spider_db_util::socket_has_default_value()
{
DBUG_ENTER("spider_db_util::socket_has_default_value");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(TRUE);
}
bool spider_db_util::database_has_default_value()
{
DBUG_ENTER("spider_db_util::database_has_default_value");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(TRUE);
}
bool spider_db_util::append_charset_name_before_string()
{
DBUG_ENTER("spider_db_util::append_charset_name_before_string");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(FALSE);
}
uint spider_db_util::limit_mode()
{
DBUG_ENTER("spider_db_util::limit_mode");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(0);
}
#ifdef HA_HAS_CHECKSUM_EXTENDED #ifdef HA_HAS_CHECKSUM_EXTENDED
bool spider_db_share::checksum_support() bool spider_db_share::checksum_support()
{ {
...@@ -136,3 +188,39 @@ int spider_db_handler::checksum_table( ...@@ -136,3 +188,39 @@ int spider_db_handler::checksum_table(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
#endif #endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool spider_db_handler::check_direct_update(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
) {
DBUG_ENTER("spider_db_handler::check_direct_update");
DBUG_PRINT("info",("spider this=%p", this));
if (
select_limit != 9223372036854775807LL ||
offset_limit != 0 ||
select_lex->order_list.elements
) {
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
}
bool spider_db_handler::check_direct_delete(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
) {
DBUG_ENTER("spider_db_handler::check_direct_delete");
DBUG_PRINT("info",("spider this=%p", this));
if (
select_limit != 9223372036854775807LL ||
offset_limit != 0 ||
select_lex->order_list.elements
) {
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
}
#endif
/* Copyright (C) 2008-2018 Kentoku Shiba /* Copyright (C) 2008-2020 Kentoku Shiba
Copyright (C) 2019-2020 MariaDB corp
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
...@@ -93,6 +94,8 @@ typedef st_spider_result SPIDER_RESULT; ...@@ -93,6 +94,8 @@ typedef st_spider_result SPIDER_RESULT;
#define SPIDER_SQL_SEMICOLON_STR ";" #define SPIDER_SQL_SEMICOLON_STR ";"
#define SPIDER_SQL_SEMICOLON_LEN sizeof(SPIDER_SQL_SEMICOLON_STR) - 1 #define SPIDER_SQL_SEMICOLON_LEN sizeof(SPIDER_SQL_SEMICOLON_STR) - 1
#define SPIDER_SQL_COLON_STR ":"
#define SPIDER_SQL_COLON_LEN sizeof(SPIDER_SQL_COLON_STR) - 1
#define SPIDER_SQL_VALUE_QUOTE_STR "'" #define SPIDER_SQL_VALUE_QUOTE_STR "'"
#define SPIDER_SQL_VALUE_QUOTE_LEN (sizeof(SPIDER_SQL_VALUE_QUOTE_STR) - 1) #define SPIDER_SQL_VALUE_QUOTE_LEN (sizeof(SPIDER_SQL_VALUE_QUOTE_STR) - 1)
...@@ -953,6 +956,11 @@ class spider_db_util ...@@ -953,6 +956,11 @@ class spider_db_util
spider_string *str spider_string *str
) = 0; ) = 0;
#endif #endif
virtual bool tables_on_different_db_are_joinable();
virtual bool socket_has_default_value();
virtual bool database_has_default_value();
virtual bool append_charset_name_before_string();
virtual uint limit_mode();
}; };
class spider_db_row class spider_db_row
...@@ -1003,12 +1011,12 @@ class spider_db_result_buffer ...@@ -1003,12 +1011,12 @@ class spider_db_result_buffer
class spider_db_result class spider_db_result
{ {
protected:
SPIDER_DB_CONN *db_conn;
public: public:
uint dbton_id; SPIDER_DB_CONN *db_conn;
uint dbton_id;
spider_db_result(SPIDER_DB_CONN *in_db_conn); spider_db_result(SPIDER_DB_CONN *in_db_conn);
virtual ~spider_db_result() {} virtual ~spider_db_result() {}
virtual void set_limit(longlong value) {}
virtual bool has_result() = 0; virtual bool has_result() = 0;
virtual void free_result() = 0; virtual void free_result() = 0;
virtual SPIDER_DB_ROW *current_row() = 0; virtual SPIDER_DB_ROW *current_row() = 0;
...@@ -1063,19 +1071,20 @@ class spider_db_result ...@@ -1063,19 +1071,20 @@ class spider_db_result
CHARSET_INFO *access_charset CHARSET_INFO *access_charset
) = 0; ) = 0;
#endif #endif
virtual uint limit_mode();
}; };
class spider_db_conn class spider_db_conn
{ {
protected:
SPIDER_CONN *conn;
public: public:
uint dbton_id; SPIDER_CONN *conn;
uint dbton_id;
spider_db_conn( spider_db_conn(
SPIDER_CONN *in_conn SPIDER_CONN *in_conn
); );
virtual ~spider_db_conn() {} virtual ~spider_db_conn() {}
virtual int init() = 0; virtual int init() = 0;
virtual void set_limit(longlong value) {}
virtual bool is_connected() = 0; virtual bool is_connected() = 0;
virtual void bg_connect() = 0; virtual void bg_connect() = 0;
virtual int connect( virtual int connect(
...@@ -1282,6 +1291,7 @@ class spider_db_conn ...@@ -1282,6 +1291,7 @@ class spider_db_conn
virtual bool cmp_request_key_to_snd( virtual bool cmp_request_key_to_snd(
st_spider_db_request_key *request_key st_spider_db_request_key *request_key
) = 0; ) = 0;
virtual uint limit_mode();
}; };
class spider_db_share class spider_db_share
...@@ -1822,6 +1832,18 @@ class spider_db_handler ...@@ -1822,6 +1832,18 @@ class spider_db_handler
ulong sql_type ulong sql_type
) = 0; ) = 0;
#endif #endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
virtual bool check_direct_update(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
);
virtual bool check_direct_delete(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
);
#endif
}; };
class spider_db_copy_table class spider_db_copy_table
......
...@@ -7272,6 +7272,13 @@ int spider_db_mbase_util::append_having( ...@@ -7272,6 +7272,13 @@ int spider_db_mbase_util::append_having(
} }
#endif #endif
bool spider_db_mbase_util::append_charset_name_before_string()
{
DBUG_ENTER("spider_db_mbase_util::append_charset_name_before_string");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(TRUE);
}
spider_mbase_share::spider_mbase_share( spider_mbase_share::spider_mbase_share(
st_spider_share *share, st_spider_share *share,
uint dbton_id, uint dbton_id,
...@@ -15693,6 +15700,28 @@ int spider_mbase_handler::append_order_by( ...@@ -15693,6 +15700,28 @@ int spider_mbase_handler::append_order_by(
} }
#endif #endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool spider_mbase_handler::check_direct_update(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
) {
DBUG_ENTER("spider_mbase_handler::check_direct_update");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(FALSE);
}
bool spider_mbase_handler::check_direct_delete(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
) {
DBUG_ENTER("spider_mbase_handler::check_direct_delete");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(FALSE);
}
#endif
spider_mbase_copy_table::spider_mbase_copy_table( spider_mbase_copy_table::spider_mbase_copy_table(
spider_mbase_share *db_share spider_mbase_share *db_share
) : spider_db_copy_table( ) : spider_db_copy_table(
......
...@@ -199,6 +199,7 @@ class spider_db_mbase_util: public spider_db_util ...@@ -199,6 +199,7 @@ class spider_db_mbase_util: public spider_db_util
spider_string *str spider_string *str
); );
#endif #endif
bool append_charset_name_before_string();
}; };
class spider_db_mysql_util: public spider_db_mbase_util class spider_db_mysql_util: public spider_db_mbase_util
...@@ -1672,6 +1673,18 @@ class spider_mbase_handler: public spider_db_handler ...@@ -1672,6 +1673,18 @@ class spider_mbase_handler: public spider_db_handler
spider_fields *fields spider_fields *fields
); );
#endif #endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool check_direct_update(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
);
bool check_direct_delete(
st_select_lex *select_lex,
longlong select_limit,
longlong offset_limit
);
#endif
}; };
class spider_mysql_handler: public spider_mbase_handler class spider_mysql_handler: public spider_mbase_handler
......
This diff is collapsed.
/* Copyright (C) 2008-2017 Kentoku Shiba /* Copyright (C) 2008-2020 Kentoku Shiba
Copyright (C) 2019-2020 MariaDB corp
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
...@@ -120,6 +121,8 @@ ...@@ -120,6 +121,8 @@
#define ER_SPIDER_ORACLE_STR "Error from Oracle %d %d %s" #define ER_SPIDER_ORACLE_STR "Error from Oracle %d %d %s"
#define ER_SPIDER_ORACLE_NUM 12712 #define ER_SPIDER_ORACLE_NUM 12712
#define ER_SPIDER_ORACLE_ERR "Oracle error" #define ER_SPIDER_ORACLE_ERR "Oracle error"
#define ER_SPIDER_DATASOURCE_STR "Error from %s %d %s %s"
#define ER_SPIDER_DATASOURCE_NUM 12712
#define ER_SPIDER_CON_COUNT_ERROR 12713 #define ER_SPIDER_CON_COUNT_ERROR 12713
#define ER_SPIDER_CON_COUNT_ERROR_STR "Too many connections between spider and remote" #define ER_SPIDER_CON_COUNT_ERROR_STR "Too many connections between spider and remote"
#define ER_SPIDER_TABLE_OPEN_TIMEOUT_NUM 12714 #define ER_SPIDER_TABLE_OPEN_TIMEOUT_NUM 12714
......
/* Copyright (C) 2008-2019 Kentoku Shiba /* Copyright (C) 2008-2020 Kentoku Shiba
Copyright (C) 2019 MariaDB corp Copyright (C) 2019-2020 MariaDB corp
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
...@@ -261,7 +261,7 @@ const char SPIDER_empty_string = ""; ...@@ -261,7 +261,7 @@ const char SPIDER_empty_string = "";
#define SPIDER_TMP_SHARE_LONG_COUNT 19 #define SPIDER_TMP_SHARE_LONG_COUNT 19
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3 #define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
#define SPIDER_MEM_CALC_LIST_NUM 273 #define SPIDER_MEM_CALC_LIST_NUM 314
#define SPIDER_CONN_META_BUF_LEN 64 #define SPIDER_CONN_META_BUF_LEN 64
#define SPIDER_BACKUP_DASTATUS \ #define SPIDER_BACKUP_DASTATUS \
...@@ -482,6 +482,7 @@ typedef struct st_spider_conn ...@@ -482,6 +482,7 @@ typedef struct st_spider_conn
char *tgt_password; char *tgt_password;
char *tgt_socket; char *tgt_socket;
char *tgt_wrapper; char *tgt_wrapper;
char *tgt_db; /* for not joinable tables on different db */
char *tgt_ssl_ca; char *tgt_ssl_ca;
char *tgt_ssl_capath; char *tgt_ssl_capath;
char *tgt_ssl_cert; char *tgt_ssl_cert;
...@@ -501,6 +502,7 @@ typedef struct st_spider_conn ...@@ -501,6 +502,7 @@ typedef struct st_spider_conn
uint tgt_password_length; uint tgt_password_length;
uint tgt_socket_length; uint tgt_socket_length;
uint tgt_wrapper_length; uint tgt_wrapper_length;
uint tgt_db_length;
uint tgt_ssl_ca_length; uint tgt_ssl_ca_length;
uint tgt_ssl_capath_length; uint tgt_ssl_capath_length;
uint tgt_ssl_cert_length; uint tgt_ssl_cert_length;
...@@ -1046,6 +1048,7 @@ typedef struct st_spider_share ...@@ -1046,6 +1048,7 @@ typedef struct st_spider_share
int bulk_size; int bulk_size;
int bulk_update_mode; int bulk_update_mode;
int bulk_update_size; int bulk_update_size;
int buffer_size;
int internal_optimize; int internal_optimize;
int internal_optimize_local; int internal_optimize_local;
double scan_rate; double scan_rate;
......
...@@ -1051,6 +1051,31 @@ int spider_param_bulk_update_size( ...@@ -1051,6 +1051,31 @@ int spider_param_bulk_update_size(
bulk_update_size : THDVAR(thd, bulk_update_size)); bulk_update_size : THDVAR(thd, bulk_update_size));
} }
/*
-1 :use table parameter
0-:buffer size
*/
static MYSQL_THDVAR_INT(
buffer_size, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Buffer size", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
2147483647, /* max */
0 /* blk */
);
int spider_param_buffer_size(
THD *thd,
int buffer_size
) {
DBUG_ENTER("spider_param_buffer_size");
DBUG_RETURN(THDVAR(thd, buffer_size) == -1 ?
buffer_size : THDVAR(thd, buffer_size));
}
/* /*
-1 :use table parameter -1 :use table parameter
0 :off 0 :off
...@@ -3463,6 +3488,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = { ...@@ -3463,6 +3488,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(bulk_size), MYSQL_SYSVAR(bulk_size),
MYSQL_SYSVAR(bulk_update_mode), MYSQL_SYSVAR(bulk_update_mode),
MYSQL_SYSVAR(bulk_update_size), MYSQL_SYSVAR(bulk_update_size),
MYSQL_SYSVAR(buffer_size),
MYSQL_SYSVAR(internal_optimize), MYSQL_SYSVAR(internal_optimize),
MYSQL_SYSVAR(internal_optimize_local), MYSQL_SYSVAR(internal_optimize_local),
MYSQL_SYSVAR(use_flash_logs), MYSQL_SYSVAR(use_flash_logs),
......
...@@ -126,6 +126,10 @@ int spider_param_bulk_update_size( ...@@ -126,6 +126,10 @@ int spider_param_bulk_update_size(
THD *thd, THD *thd,
int bulk_update_size int bulk_update_size
); );
int spider_param_buffer_size(
THD *thd,
int buffer_size
);
int spider_param_internal_optimize( int spider_param_internal_optimize(
THD *thd, THD *thd,
int internal_optimize int internal_optimize
......
This diff is collapsed.
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