Merge branch '10.5' into 10.6

This commit is contained in:
Yuchen Pei 2024-05-31 09:10:17 +10:00
commit f2302a62e3
No known key found for this signature in database
GPG key ID: 3DD1B35105743563
46 changed files with 160 additions and 15891 deletions

View file

@ -17,10 +17,7 @@ SET(SPIDER_SOURCES
spd_param.cc spd_sys_table.cc spd_trx.cc spd_db_conn.cc spd_conn.cc
spd_table.cc spd_direct_sql.cc spd_udf.cc spd_ping_table.cc
spd_copy_tables.cc spd_i_s.cc spd_malloc.cc ha_spider.cc spd_udf.def
spd_db_mysql.cc spd_db_handlersocket.cc spd_db_oracle.cc
spd_group_by_handler.cc spd_db_include.cc
hs_client/config.cpp hs_client/escape.cpp hs_client/fatal.cpp
hs_client/hstcpcli.cpp hs_client/socket.cpp hs_client/string_util.cpp
spd_db_mysql.cc spd_db_oracle.cc spd_group_by_handler.cc spd_db_include.cc
)
IF(DEFINED ENV{ORACLE_HOME})

File diff suppressed because it is too large Load diff

View file

@ -55,10 +55,6 @@ public:
SPIDER_SHARE *share;
ulonglong spider_thread_id;
ulonglong trx_conn_adjustment;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
ulonglong trx_hs_r_conn_adjustment;
ulonglong trx_hs_w_conn_adjustment;
#endif
uint mem_calc_id;
const char *mem_calc_func_name;
const char *mem_calc_file_name;
@ -71,14 +67,6 @@ public:
char *conn_keys_first_ptr;
char **conn_keys;
SPIDER_CONN **conns;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
char **hs_r_conn_keys;
SPIDER_CONN **hs_r_conns;
ulonglong *hs_r_conn_ages;
char **hs_w_conn_keys;
SPIDER_CONN **hs_w_conns;
ulonglong *hs_w_conn_ages;
#endif
/* for active-standby mode */
uint *conn_link_idx;
uchar *conn_can_fo;
@ -179,27 +167,8 @@ public:
uchar *m_handler_opened;
uint *m_handler_id;
char **m_handler_cid;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uchar *r_handler_opened;
uint *r_handler_id;
uint *r_handler_index;
uchar *w_handler_opened;
uint *w_handler_id;
uint *w_handler_index;
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
uchar *do_hs_direct_update;
uint32 **hs_r_ret_fields;
uint32 **hs_w_ret_fields;
size_t *hs_r_ret_fields_num;
size_t *hs_w_ret_fields_num;
uchar *tmp_column_bitmap;
#endif
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool do_direct_update;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
bool maybe_do_hs_direct_update;
#endif
uint direct_update_kinds;
#endif
spider_index_rnd_init prev_index_rnd_init;
@ -938,26 +907,6 @@ public:
int reset_sql_sql(
ulong sql_type
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int reset_hs_sql(
ulong sql_type
);
int reset_hs_keys(
ulong sql_type
);
int reset_hs_upds(
ulong sql_type
);
int reset_hs_strs(
ulong sql_type
);
int reset_hs_strs_pos(
ulong sql_type
);
int push_back_hs_upds(
SPIDER_HS_STRING_REF &info
);
#endif
int append_tmp_table_and_sql_for_bka(
const key_range *start_key
);
@ -968,17 +917,9 @@ public:
int reuse_union_table_and_sql_for_bka();
int append_insert_sql_part();
int append_update_sql_part();
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
int append_increment_update_set_sql_part();
#endif
#endif
int append_update_set_sql_part();
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
int append_direct_update_set_sql_part();
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int append_direct_update_set_hs_part();
#endif
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
int append_dup_update_pushdown_sql_part(
@ -1045,13 +986,6 @@ public:
const key_range *end_key,
ulong sql_type
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int append_key_where_hs_part(
const key_range *start_key,
const key_range *end_key,
ulong sql_type
);
#endif
int append_match_where_sql_part(
ulong sql_type
);
@ -1106,13 +1040,6 @@ public:
longlong limit,
ulong sql_type
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int append_limit_hs_part(
longlong offset,
longlong limit,
ulong sql_type
);
#endif
int reappend_limit_sql_part(
longlong offset,
longlong limit,
@ -1124,11 +1051,6 @@ public:
int append_insert_values_sql_part(
ulong sql_type
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int append_insert_values_hs_part(
ulong sql_type
);
#endif
int append_into_sql_part(
ulong sql_type
);
@ -1197,9 +1119,6 @@ public:
bool support_use_handler_sql(
int use_handler
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
bool support_bulk_access_hs() const;
#endif
int init_union_table_name_pos_sql();
int set_union_table_name_pos_sql();
int append_lock_tables_list();

View file

@ -1,43 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_ALLOCATOR_HPP
#define DENA_ALLOCATOR_HPP
#if 0
extern "C" {
#include <tlsf.h>
};
#define DENA_MALLOC(x) tlsf_malloc(x)
#define DENA_REALLOC(x, y) tlsf_realloc(x, y)
#define DENA_FREE(x) tlsf_free(x)
#define DENA_NEWCHAR(x) static_cast<char *>(tlsf_malloc(x))
#define DENA_DELETE(x) tlsf_free(x)
#endif
#if 1
#define DENA_MALLOC(x) malloc(x)
#define DENA_REALLOC(x, y) realloc(x, y)
#define DENA_FREE(x) free(x)
#define DENA_NEWCHAR(x) (new char[x])
#define DENA_DELETE(x) (delete [] x)
#endif
#if 1
#define DENA_ALLOCA_ALLOCATE(typ, len) \
(typ *) (alloca((len) * sizeof(typ)))
#define DENA_ALLOCA_FREE(x)
#else
#define DENA_ALLOCA_ALLOCATE(typ, len) \
(typ *) (malloc((len) * sizeof(typ)))
#define DENA_ALLOCA_FREE(x) free(x)
#endif
#endif

View file

@ -1,49 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_AUTO_ADDRINFO_HPP
#define DENA_AUTO_ADDRINFO_HPP
#ifndef _WIN32
#include <netdb.h>
#endif
#include "util.hpp"
namespace dena {
struct auto_addrinfo : private noncopyable {
auto_addrinfo() : addr(0) { }
~auto_addrinfo() {
reset();
}
void reset(addrinfo *a = 0) {
if (addr != 0) {
freeaddrinfo(addr);
}
addr = a;
}
const addrinfo *get() const { return addr; }
int resolve(const char *node, const char *service, int flags = 0,
int family = AF_UNSPEC, int socktype = SOCK_STREAM, int protocol = 0) {
reset();
addrinfo hints;
hints.ai_flags = flags;
hints.ai_family = family;
hints.ai_socktype = socktype;
hints.ai_protocol = protocol;
return getaddrinfo(node, service, &hints, &addr);
}
private:
addrinfo *addr;
};
};
#endif

View file

@ -1,67 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_AUTO_FILE_HPP
#define DENA_AUTO_FILE_HPP
/*
#ifndef _WIN32
#include <dirent.h>
#endif
*/
#include "util.hpp"
namespace dena {
struct auto_file : private noncopyable {
auto_file() : fd(-1) { }
~auto_file() {
reset();
}
int get() const { return fd; }
int close() {
if (fd < 0) {
return 0;
}
const int r = ::close(fd);
fd = -1;
return r;
}
void reset(int x = -1) {
if (fd >= 0) {
this->close();
}
fd = x;
}
private:
int fd;
};
/*
struct auto_dir : private noncopyable {
auto_dir() : dp(0) { }
~auto_dir() {
reset();
}
DIR *get() const { return dp; }
void reset(DIR *d = 0) {
if (dp != 0) {
closedir(dp);
}
dp = d;
}
private:
DIR *dp;
};
*/
};
#endif

View file

@ -1,70 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_AUTO_PTRCONTAINER_HPP
#define DENA_AUTO_PTRCONTAINER_HPP
namespace dena {
/*
template <typename Tcnt>
struct auto_ptrcontainer {
typedef Tcnt container_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::pointer pointer;
typedef typename container_type::reference reference;
typedef typename container_type::const_reference const_reference;
typedef typename container_type::size_type size_type;
typedef typename container_type::difference_type difference_type;
typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
typedef typename container_type::reverse_iterator reverse_iterator;
typedef typename container_type::const_reverse_iterator
const_reverse_iterator;
iterator begin() { return cnt.begin(); }
const_iterator begin() const { return cnt.begin(); }
iterator end() { return cnt.end(); }
const_iterator end() const { return cnt.end(); }
reverse_iterator rbegin() { return cnt.rbegin(); }
reverse_iterator rend() { return cnt.rend(); }
const_reverse_iterator rbegin() const { return cnt.rbegin(); }
const_reverse_iterator rend() const { return cnt.rend(); }
size_type size() const { return cnt.size(); }
size_type max_size() const { return cnt.max_size(); }
bool empty() const { return cnt.empty(); }
reference front() { return cnt.front(); }
const_reference front() const { cnt.front(); }
reference back() { return cnt.back(); }
const_reference back() const { cnt.back(); }
void swap(auto_ptrcontainer& x) { cnt.swap(x.cnt); }
~auto_ptrcontainer() {
for (iterator i = begin(); i != end(); ++i) {
delete *i;
}
}
template <typename Tap> void push_back_ptr(Tap& ap) {
cnt.push_back(ap.get());
ap.release();
}
void erase_ptr(iterator i) {
delete *i;
cnt.erase(i);
}
reference operator [](size_type n) { return cnt[n]; }
const_reference operator [](size_type n) const { return cnt[n]; }
void clear() { cnt.clear(); }
private:
Tcnt cnt;
};
*/
};
#endif

View file

@ -1,286 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include <my_global.h>
#include "mysql_version.h"
#include "sql_priv.h"
#include "probes_mysql.h"
#include "config.hpp"
namespace dena {
unsigned int verbose_level = 0;
uchar *
conf_get_key(
conf_param *param,
size_t *length,
my_bool not_used __attribute__ ((unused))
) {
*length = param->key.length();
return (uchar*) param->key.ptr();
}
config::config()
{
if (my_hash_init(PSI_INSTRUMENT_ME, &conf_hash, &my_charset_bin, 32, 0, 0,
(my_hash_get_key) conf_get_key, 0, 0))
init = FALSE;
else
init = TRUE;
return;
}
config::~config()
{
if (init)
{
conf_param *param;
while ((param = (conf_param *) my_hash_element(&conf_hash, 0)))
{
my_hash_delete(&conf_hash, (uchar*) param);
delete param;
}
my_hash_free(&conf_hash);
}
}
conf_param *
config::find(const String& key) const
{
if (init)
return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key.ptr(),
key.length());
else
return NULL;
}
conf_param *
config::find(const char *key) const
{
if (init)
return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key,
strlen(key));
else
return NULL;
}
String
config::get_str(const String& key, const String& def) const
{
DENA_VERBOSE(30, list_all_params());
conf_param *param = find(key);
if (!param) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key.ptr(),
def.ptr()));
return def;
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", key.ptr(),
param->val.ptr()));
return param->val;
}
String
config::get_str(const char *key, const char *def) const
{
DENA_VERBOSE(30, list_all_params());
conf_param *param = find(key);
if (!param) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key, def));
return String(def, strlen(def), &my_charset_bin);
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n",
key, param->val.ptr()));
return param->val;
}
long long
config::get_int(const String& key, long long def) const
{
int err;
DENA_VERBOSE(30, list_all_params());
conf_param *param = find(key);
if (!param) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key.ptr(),
def));
return def;
}
const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err);
if (err) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key.ptr(),
def));
return def;
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key.ptr(), r));
return r;
}
long long
config::get_int(const char *key, long long def) const
{
int err;
DENA_VERBOSE(30, list_all_params());
conf_param *param = find(key);
if (!param) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key, def));
return def;
}
const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err);
if (err) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key, def));
return def;
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key, r));
return r;
}
bool
config::replace(const char *key, const char *val)
{
uint32 val_len = strlen(val);
conf_param *param = find(key);
if (!param) {
/* create */
if (!(param = new conf_param()))
return TRUE;
uint32 key_len = strlen(key);
if (
param->key.reserve(key_len + 1) ||
param->val.reserve(val_len + 1)
) {
delete param;
return TRUE;
}
param->key.q_append(key, key_len);
param->val.q_append(val, val_len);
param->key.c_ptr_safe();
param->val.c_ptr_safe();
if (my_hash_insert(&conf_hash, (uchar*) param))
{
delete param;
return TRUE;
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(create)\n",
param->key.ptr(), param->val.ptr()));
return FALSE;
}
/* replace */
param->val.length(0);
if (param->val.reserve(val_len + 1))
return TRUE;
param->val.q_append(val, val_len);
param->val.c_ptr_safe();
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(replace)\n",
param->key.ptr(), param->val.ptr()));
return FALSE;
}
bool
config::replace(const char *key, long long val)
{
char val_str[22];
sprintf(val_str, "%lld", val);
return replace(key, val_str);
}
bool
config::compare(const char *key, const char *val)
{
conf_param *param = find(key);
if (!param)
return FALSE;
return !strcmp(param->val.ptr(), val);
}
void
config::list_all_params() const
{
conf_param *param;
DENA_VERBOSE(10, fprintf(stderr, "list_all_params start\n"));
for(ulong i = 0; i < conf_hash.records; i++)
{
if ((param = (conf_param *) my_hash_element((HASH *) &conf_hash, i)))
{
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n",
param->key.ptr(), param->val.ptr()));
}
}
DENA_VERBOSE(10, fprintf(stderr, "list_all_params end\n"));
}
config&
config::operator =(const config& x)
{
DENA_VERBOSE(10, fprintf(stderr, "config operator = start"));
if (this != &x && init && x.init) {
conf_param *param, *new_param;
for(ulong i = 0; i < x.conf_hash.records; i++)
{
if ((param = (conf_param *) my_hash_element((HASH *) &x.conf_hash, i)))
if ((new_param = new conf_param()))
{
if (
!new_param->key.copy(param->key) &&
!new_param->val.copy(param->val)
) {
new_param->key.c_ptr_safe();
new_param->val.c_ptr_safe();
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n",
new_param->key.ptr(), new_param->val.ptr()));
if (my_hash_insert(&conf_hash, (uchar*) new_param))
delete new_param;
} else
delete new_param;
}
}
}
DENA_VERBOSE(10, fprintf(stderr, "config operator = end %p", this));
return *this;
}
void
parse_args(int argc, char **argv, config& conf)
{
conf_param *param;
for (int i = 1; i < argc; ++i) {
const char *const arg = argv[i];
const char *const eq = strchr(arg, '=');
if (eq == 0) {
continue;
}
if (!(param = new conf_param()))
continue;
uint32 key_len = (uint32)(eq - arg);
uint32 val_len = strlen(eq + 1);
if (
param->key.reserve(key_len + 1) ||
param->val.reserve(val_len + 1)
) {
delete param;
continue;
}
param->key.q_append(arg, key_len);
param->val.q_append(eq + 1, val_len);
param->key.c_ptr_safe();
param->val.c_ptr_safe();
if (my_hash_insert(&conf.conf_hash, (uchar*) param))
{
delete param;
continue;
}
}
param = conf.find("verbose");
if (param) {
verbose_level = atoi(param->val.c_ptr());
}
}
};

View file

@ -1,76 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_CONFIG_HPP
#define DENA_CONFIG_HPP
#include "mysql_version.h"
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h"
#define DENA_VERBOSE(lv, x) if (dena::verbose_level >= (lv)) { (x); }
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
#define INFO_KIND_HS_RET_FIELDS 1
#define INFO_KIND_HS_APPEND_STRING_REF 3
#define INFO_KIND_HS_CLEAR_STRING_REF 4
#define INFO_KIND_HS_INCREMENT_BEGIN 5
#define INFO_KIND_HS_INCREMENT_END 6
#define INFO_KIND_HS_DECREMENT_BEGIN 7
#define INFO_KIND_HS_DECREMENT_END 8
#endif
namespace dena {
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
struct uint32_info {
size_t info_size;
uint32 *info;
};
#endif
struct conf_param {
String key;
String val;
};
uchar *conf_get_key(
conf_param *share,
size_t *length,
my_bool not_used __attribute__ ((unused))
);
struct config {
bool init;
HASH conf_hash;
config();
~config();
conf_param *find(const String& key) const;
conf_param *find(const char *key) const;
String get_str(const String& key, const String& def =
String("", 0, &my_charset_bin)) const;
String get_str(const char *key, const char *def = "") const;
long long get_int(const String& key, long long def = 0) const;
long long get_int(const char *key, long long def = 0) const;
bool replace(const char *key, const char *val);
bool replace(const char *key, long long val);
bool compare(const char *key, const char *val);
void list_all_params() const;
config& operator =(const config& x);
};
void parse_args(int argc, char **argv, config& conf);
extern unsigned int verbose_level;
};
#endif

View file

@ -1,129 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include <my_global.h>
#include "mysql_version.h"
#include "hs_compat.h"
#include "escape.hpp"
#include "string_buffer.hpp"
#include "fatal.hpp"
#include "string_util.hpp"
#define DBG_OP(x)
#define DBG_BUF(x)
namespace dena {
enum special_char_t {
special_char_escape_prefix = 0x01, /* SOH */
special_char_noescape_min = 0x10, /* DLE */
special_char_escape_shift = 0x40, /* '@' */
};
void
escape_string(char *& wp, const char *start, const char *finish)
{
while (start != finish) {
const unsigned char c = *start;
if (c >= special_char_noescape_min) {
wp[0] = c; /* no need to escape */
} else {
wp[0] = special_char_escape_prefix;
++wp;
wp[0] = c + special_char_escape_shift;
}
++start;
++wp;
}
}
void
escape_string(string_buffer& ar, const char *start, const char *finish)
{
const size_t buflen = (finish - start) * 2;
char *const wp_begin = ar.make_space(buflen);
char *wp = wp_begin;
escape_string(wp, start, finish);
ar.space_wrote(wp - wp_begin);
}
bool
unescape_string(char *& wp, const char *start, const char *finish)
{
/* works even if wp == start */
while (start != finish) {
const unsigned char c = *start;
if (c != special_char_escape_prefix) {
wp[0] = c;
} else if (start + 1 != finish) {
++start;
const unsigned char cn = *start;
if (cn < special_char_escape_shift) {
return false;
}
wp[0] = cn - special_char_escape_shift;
} else {
return false;
}
++start;
++wp;
}
return true;
}
bool
unescape_string(string_buffer& ar, const char *start, const char *finish)
{
const size_t buflen = finish - start;
char *const wp_begin = ar.make_space(buflen);
char *wp = wp_begin;
const bool r = unescape_string(wp, start, finish);
ar.space_wrote(wp - wp_begin);
return r;
}
uint32
read_ui32(char *& start, char *finish)
{
char *const n_begin = start;
read_token(start, finish);
char *const n_end = start;
uint32 v = 0;
for (char *p = n_begin; p != n_end; ++p) {
const char ch = p[0];
if (ch >= '0' && ch <= '9') {
v *= 10;
v += (ch - '0');
}
}
return v;
}
void
write_ui32(string_buffer& buf, uint32 v)
{
char *wp = buf.make_space(12);
int len = snprintf(wp, 12, "%u", v);
if (len > 0) {
buf.space_wrote(len);
}
}
void
write_ui64(string_buffer& buf, uint64 v)
{
char *wp = buf.make_space(22);
int len = snprintf(wp, 22, "%llu", static_cast<unsigned long long>(v));
if (len > 0) {
buf.space_wrote(len);
}
}
};

View file

@ -1,64 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#include "string_buffer.hpp"
#include "string_ref.hpp"
#include "string_util.hpp"
#ifndef DENA_ESCAPE_HPP
#define DENA_ESCAPE_HPP
namespace dena {
void escape_string(char *& wp, const char *start, const char *finish);
void escape_string(string_buffer& ar, const char *start, const char *finish);
bool unescape_string(char *& wp, const char *start, const char *finish);
/* unescaped_string() works even if wp == start */
bool unescape_string(string_buffer& ar, const char *start, const char *finish);
uint32 read_ui32(char *& start, char *finish);
void write_ui32(string_buffer& buf, uint32 v);
void write_ui64(string_buffer& buf, uint64 v);
inline bool
is_null_expression(const char *start, const char *finish)
{
return (finish == start + 1 && start[0] == 0);
}
inline void
read_token(char *& start, char *finish)
{
char *const p = memchr_char(start, '\t', finish - start);
if (p == 0) {
start = finish;
} else {
start = p;
}
}
inline void
skip_token_delim_fold(char *& start, char *finish)
{
while (start != finish && start[0] == '\t') {
++start;
}
}
inline void
skip_one(char *& start, char *finish)
{
if (start != finish) {
++start;
}
}
};
#endif

View file

@ -1,44 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include <my_global.h>
#include "mysql_version.h"
#include "sql_priv.h"
#include "probes_mysql.h"
#include "fatal.hpp"
namespace dena {
/*
const int opt_syslog = LOG_ERR | LOG_PID | LOG_CONS;
*/
void
fatal_abort(const String& message)
{
fprintf(stderr, "FATAL_COREDUMP: %s\n", message.ptr());
/*
syslog(opt_syslog, "FATAL_COREDUMP: %s", message.ptr());
*/
abort();
}
void
fatal_abort(const char *message)
{
fprintf(stderr, "FATAL_COREDUMP: %s\n", message);
/*
syslog(opt_syslog, "FATAL_COREDUMP: %s", message);
*/
abort();
}
};

View file

@ -1,26 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_FATAL_HPP
#define DENA_FATAL_HPP
#include "mysql_version.h"
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h"
namespace dena {
void fatal_abort(const String& message);
void fatal_abort(const char *message);
};
#endif

View file

@ -1,662 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include <my_global.h>
#include "mysql_version.h"
#include "hs_compat.h"
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h"
#include "hstcpcli.hpp"
#include "auto_file.hpp"
#include "string_util.hpp"
#include "auto_addrinfo.hpp"
#include "escape.hpp"
#include "util.hpp"
/* TODO */
#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif
#define DBG(x)
namespace dena {
hstresult::hstresult()
{
SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16,
MYF(MY_WME));
}
hstresult::~hstresult()
{
delete_dynamic(&flds);
}
struct hstcpcli : public hstcpcli_i, private noncopyable {
hstcpcli(const socket_args& args);
virtual ~hstcpcli();
virtual void close();
virtual int reconnect();
virtual bool stable_point();
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds, const char *filflds);
virtual void request_buf_auth(const char *secret, const char *typ);
virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip,
const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
const hstcpcli_filter *fils, size_t filslen, int invalues_keypart,
const string_ref *invalues, size_t invalueslen);
virtual size_t request_buf_append(const char *start, const char *finish);
virtual void request_reset();
virtual int request_send();
virtual int response_recv(size_t& num_flds_r);
virtual int get_result(hstresult& result);
virtual const string_ref *get_next_row();
virtual const string_ref *get_next_row_from_result(hstresult& result);
virtual size_t get_row_size();
virtual size_t get_row_size_from_result(hstresult& result);
virtual void response_buf_remove();
virtual int get_error_code();
virtual String& get_error();
virtual void clear_error();
virtual int set_timeout(int send_timeout, int recv_timeout);
virtual size_t get_num_req_bufd() { return num_req_bufd; }
virtual size_t get_num_req_sent() { return num_req_sent; }
virtual size_t get_num_req_rcvd() { return num_req_rcvd; }
virtual size_t get_response_end_offset() { return response_end_offset; }
virtual const char *get_readbuf_begin() { return readbuf.begin(); }
virtual const char *get_readbuf_end() { return readbuf.end(); }
virtual const char *get_writebuf_begin() { return writebuf.begin(); }
virtual size_t get_writebuf_size() { return writebuf.size(); }
virtual void write_error_to_log(const char *func_name, const char *file_name,
ulong line_no);
private:
int read_more();
int set_error(int code, const String& str);
int set_error(int code, const char *str);
private:
auto_file fd;
socket_args sargs;
string_buffer readbuf;
string_buffer writebuf;
size_t response_end_offset; /* incl newline */
size_t cur_row_offset;
size_t cur_row_size;
size_t num_flds;
size_t num_req_bufd; /* buffered but not yet sent */
size_t num_req_sent; /* sent but not yet received */
size_t num_req_rcvd; /* received but not yet removed */
int error_code;
String error_str;
DYNAMIC_ARRAY flds;
int errno_buf;
};
hstcpcli::hstcpcli(const socket_args& args)
: sargs(args), response_end_offset(0), cur_row_offset(0), cur_row_size(0),
num_flds(0), num_req_bufd(0), num_req_sent(0), num_req_rcvd(0),
error_code(0), errno_buf(0)
{
String err;
SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16, MYF(MY_WME));
if (socket_connect(fd, sargs, err) != 0) {
set_error(-1, err);
}
}
hstcpcli::~hstcpcli()
{
delete_dynamic(&flds);
}
void
hstcpcli::close()
{
fd.close();
readbuf.clear();
writebuf.clear();
response_end_offset = 0;
cur_row_offset = 0;
num_flds = 0;
num_req_bufd = 0;
num_req_sent = 0;
num_req_rcvd = 0;
}
int
hstcpcli::reconnect()
{
clear_error();
close();
String err;
if (socket_connect(fd, sargs, err) != 0) {
set_error(-1, err);
}
return error_code;
}
int
hstcpcli::set_timeout(int send_timeout, int recv_timeout)
{
String err;
sargs.send_timeout = send_timeout;
sargs.recv_timeout = recv_timeout;
if (socket_set_timeout(fd, sargs, err) != 0) {
set_error(-1, err);
}
return error_code;
}
bool
hstcpcli::stable_point()
{
/* returns true if cli can send a new request */
return fd.get() >= 0 && num_req_bufd == 0 && num_req_sent == 0 &&
num_req_rcvd == 0 && response_end_offset == 0;
}
int
hstcpcli::get_error_code()
{
return error_code;
}
String&
hstcpcli::get_error()
{
return error_str;
}
int
hstcpcli::read_more()
{
const size_t block_size = 4096; // FIXME
char *const wp = readbuf.make_space(block_size);
int rlen;
errno = 0;
while ((rlen = read(fd.get(), wp, block_size)) <= 0) {
errno_buf = errno;
if (rlen < 0) {
if (errno == EINTR || errno == EAGAIN)
{
errno = 0;
continue;
}
error_str = String(STRING_WITH_LEN("read: failed"), &my_charset_bin);
} else {
error_str = String(STRING_WITH_LEN("read: eof"), &my_charset_bin);
}
return rlen;
}
readbuf.space_wrote(rlen);
return rlen;
}
void
hstcpcli::clear_error()
{
DBG(fprintf(stderr, "CLEAR_ERROR: %d\n", error_code));
error_code = 0;
error_str.length(0);
}
int
hstcpcli::set_error(int code, const String& str)
{
DBG(fprintf(stderr, "SET_ERROR: %d\n", code));
error_code = code;
error_str = str;
return error_code;
}
int
hstcpcli::set_error(int code, const char *str)
{
uint32 str_len = strlen(str);
DBG(fprintf(stderr, "SET_ERROR: %d\n", code));
error_code = code;
error_str.length(0);
if (error_str.reserve(str_len + 1))
return 0;
error_str.q_append(str, str_len);
error_str.c_ptr_safe();
return error_code;
}
void
hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds, const char *filflds)
{
/*
if (num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_rcvd > 0) {
close();
set_error(-1, "request_buf_open_index: protocol out of sync");
return;
}
const string_ref dbn_ref(dbn, strlen(dbn));
const string_ref tbl_ref(tbl, strlen(tbl));
const string_ref idx_ref(idx, strlen(idx));
const string_ref rfs_ref(retflds, strlen(retflds));
writebuf.append_literal("P\t");
append_uint32(writebuf, pst_id); // FIXME size_t ?
writebuf.append_literal("\t");
writebuf.append(dbn_ref.begin(), dbn_ref.end());
writebuf.append_literal("\t");
writebuf.append(tbl_ref.begin(), tbl_ref.end());
writebuf.append_literal("\t");
writebuf.append(idx_ref.begin(), idx_ref.end());
writebuf.append_literal("\t");
writebuf.append(rfs_ref.begin(), rfs_ref.end());
if (filflds != 0) {
const string_ref fls_ref(filflds, strlen(filflds));
writebuf.append_literal("\t");
writebuf.append(fls_ref.begin(), fls_ref.end());
}
writebuf.append_literal("\n");
++num_req_bufd;
}
void
hstcpcli::request_buf_auth(const char *secret, const char *typ)
{
/*
if (num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_rcvd > 0) {
close();
set_error(-1, "request_buf_auth: protocol out of sync");
return;
}
if (typ == 0) {
typ = "1";
}
const string_ref typ_ref(typ, strlen(typ));
const string_ref secret_ref(secret, strlen(secret));
writebuf.append_literal("A\t");
writebuf.append(typ_ref.begin(), typ_ref.end());
writebuf.append_literal("\t");
writebuf.append(secret_ref.begin(), secret_ref.end());
writebuf.append_literal("\n");
++num_req_bufd;
}
namespace {
void
append_delim_value(string_buffer& buf, const char *start, const char *finish)
{
if (start == 0) {
/* null */
const char t[] = "\t\0";
buf.append(t, t + 2);
} else {
/* non-null */
buf.append_literal("\t");
escape_string(buf, start, finish);
}
}
};
void
hstcpcli::request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip,
const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
const hstcpcli_filter *fils, size_t filslen, int invalues_keypart,
const string_ref *invalues, size_t invalueslen)
{
/*
if (num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_rcvd > 0) {
close();
set_error(-1, "request_buf_exec_generic: protocol out of sync");
return;
}
append_uint32(writebuf, pst_id); // FIXME size_t ?
writebuf.append_literal("\t");
writebuf.append(op.begin(), op.end());
writebuf.append_literal("\t");
append_uint32(writebuf, kvslen); // FIXME size_t ?
for (size_t i = 0; i < kvslen; ++i) {
const string_ref& kv = kvs[i];
append_delim_value(writebuf, kv.begin(), kv.end());
}
if (limit != 0 || skip != 0 || invalues_keypart >= 0 ||
mod_op.size() != 0 || filslen != 0) {
/* has more option */
writebuf.append_literal("\t");
append_uint32(writebuf, limit); // FIXME size_t ?
if (skip != 0 || invalues_keypart >= 0 ||
mod_op.size() != 0 || filslen != 0) {
writebuf.append_literal("\t");
append_uint32(writebuf, skip); // FIXME size_t ?
}
if (invalues_keypart >= 0) {
writebuf.append_literal("\t@\t");
append_uint32(writebuf, invalues_keypart);
writebuf.append_literal("\t");
append_uint32(writebuf, invalueslen);
for (size_t i = 0; i < invalueslen; ++i) {
const string_ref& s = invalues[i];
append_delim_value(writebuf, s.begin(), s.end());
}
}
for (size_t i = 0; i < filslen; ++i) {
const hstcpcli_filter& f = fils[i];
writebuf.append_literal("\t");
writebuf.append(f.filter_type.begin(), f.filter_type.end());
writebuf.append_literal("\t");
writebuf.append(f.op.begin(), f.op.end());
writebuf.append_literal("\t");
append_uint32(writebuf, f.ff_offset);
append_delim_value(writebuf, f.val.begin(), f.val.end());
}
if (mod_op.size() != 0) {
writebuf.append_literal("\t");
writebuf.append(mod_op.begin(), mod_op.end());
for (size_t i = 0; i < mvslen; ++i) {
const string_ref& mv = mvs[i];
append_delim_value(writebuf, mv.begin(), mv.end());
}
}
}
writebuf.append_literal("\n");
++num_req_bufd;
}
size_t
hstcpcli::request_buf_append(const char *start, const char *finish)
{
/*
if (num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_rcvd > 0) {
close();
set_error(-1, "request_buf_append: protocol out of sync");
return 0;
}
const char *nl = start;
size_t num_req = 0;
while ((nl = memchr_char(nl, '\n', finish - nl))) {
if (nl == finish)
break;
num_req++;
nl++;
}
num_req++;
writebuf.append(start, finish);
if (*(finish - 1) != '\n')
writebuf.append_literal("\n");
num_req_bufd += num_req;
return num_req;
}
void
hstcpcli::request_reset()
{
if (num_req_bufd) {
writebuf.erase_front(writebuf.size());
num_req_bufd = 0;
}
}
int
hstcpcli::request_send()
{
if (error_code < 0) {
return error_code;
}
clear_error();
if (fd.get() < 0) {
close();
return set_error(-1, "write: closed");
}
/*
if (num_req_bufd == 0 || num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_bufd == 0 || num_req_rcvd > 0) {
close();
return set_error(-1, "request_send: protocol out of sync");
}
const size_t wrlen = writebuf.size();
const ssize_t r = send(fd.get(), writebuf.begin(), wrlen, MSG_NOSIGNAL);
if (r <= 0) {
close();
return set_error(-1, r < 0 ? "write: failed" : "write: eof");
}
writebuf.erase_front(r);
if (static_cast<size_t>(r) != wrlen) {
close();
return set_error(-1, "write: incomplete");
}
num_req_sent += num_req_bufd;
num_req_bufd = 0;
DBG(fprintf(stderr, "REQSEND 0\n"));
return 0;
}
int
hstcpcli::response_recv(size_t& num_flds_r)
{
if (error_code < 0) {
return error_code;
}
clear_error();
if (num_req_bufd > 0 || num_req_sent == 0 || num_req_rcvd > 0 ||
response_end_offset != 0) {
close();
return set_error(-1, "response_recv: protocol out of sync");
}
cur_row_offset = 0;
num_flds_r = num_flds = 0;
if (fd.get() < 0) {
return set_error(-1, "read: closed");
}
size_t offset = 0;
while (true) {
const char *const lbegin = readbuf.begin() + offset;
const char *const lend = readbuf.end();
if (lbegin < lend)
{
const char *const nl = memchr_char(lbegin, '\n', lend - lbegin);
if (nl != 0) {
offset += (nl + 1) - lbegin;
break;
}
offset += lend - lbegin;
}
if (read_more() <= 0) {
close();
error_code = -1;
return error_code;
}
}
response_end_offset = offset;
--num_req_sent;
++num_req_rcvd;
char *start = readbuf.begin();
char *const finish = start + response_end_offset - 1;
const size_t resp_code = read_ui32(start, finish);
skip_one(start, finish);
num_flds_r = num_flds = read_ui32(start, finish);
if (resp_code != 0) {
skip_one(start, finish);
char *const err_begin = start;
read_token(start, finish);
char *const err_end = start;
String e = String(err_begin, (uint32)(err_end - err_begin), &my_charset_bin);
if (!e.length()) {
e = String(STRING_WITH_LEN("unknown_error"), &my_charset_bin);
}
return set_error(resp_code, e);
}
cur_row_size = 0;
cur_row_offset = start - readbuf.begin();
DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n",
String(readbuf.begin(), readbuf.begin() + response_end_offset)
.c_str(),
cur_row_offset, response_end_offset));
DBG(fprintf(stderr, "RES 0\n"));
if (flds.max_element < num_flds)
{
if (allocate_dynamic(&flds, num_flds))
return set_error(-1, "out of memory");
}
flds.elements = num_flds;
return 0;
}
int
hstcpcli::get_result(hstresult& result)
{
/*
readbuf.swap(result.readbuf);
*/
char *const wp = result.readbuf.make_space(response_end_offset);
memcpy(wp, readbuf.begin(), response_end_offset);
result.readbuf.space_wrote(response_end_offset);
result.response_end_offset = response_end_offset;
result.num_flds = num_flds;
result.cur_row_size = cur_row_size;
result.cur_row_offset = cur_row_offset;
if (result.flds.max_element < num_flds)
{
if (allocate_dynamic(&result.flds, num_flds))
return set_error(-1, "out of memory");
}
result.flds.elements = num_flds;
return 0;
}
const string_ref *
hstcpcli::get_next_row()
{
if (num_flds == 0 || flds.elements < num_flds) {
DBG(fprintf(stderr, "GNR NF 0\n"));
return 0;
}
char *start = readbuf.begin() + cur_row_offset;
char *const finish = readbuf.begin() + response_end_offset - 1;
if (start >= finish) { /* start[0] == nl */
DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish));
return 0;
}
for (size_t i = 0; i < num_flds; ++i) {
skip_one(start, finish);
char *const fld_begin = start;
read_token(start, finish);
char *const fld_end = start;
char *wp = fld_begin;
if (is_null_expression(fld_begin, fld_end)) {
/* null */
((string_ref *) flds.buffer)[i] = string_ref();
} else {
unescape_string(wp, fld_begin, fld_end); /* in-place */
((string_ref *) flds.buffer)[i] = string_ref(fld_begin, wp);
}
}
cur_row_size = start - (readbuf.begin() + cur_row_offset);
cur_row_offset = start - readbuf.begin();
return (string_ref *) flds.buffer;
}
const string_ref *
hstcpcli::get_next_row_from_result(hstresult& result)
{
if (result.num_flds == 0 || result.flds.elements < result.num_flds) {
DBG(fprintf(stderr, "GNR NF 0\n"));
return 0;
}
char *start = result.readbuf.begin() + result.cur_row_offset;
char *const finish = result.readbuf.begin() + result.response_end_offset - 1;
if (start >= finish) { /* start[0] == nl */
DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish));
return 0;
}
for (size_t i = 0; i < result.num_flds; ++i) {
skip_one(start, finish);
char *const fld_begin = start;
read_token(start, finish);
char *const fld_end = start;
char *wp = fld_begin;
if (is_null_expression(fld_begin, fld_end)) {
/* null */
((string_ref *) result.flds.buffer)[i] = string_ref();
} else {
unescape_string(wp, fld_begin, fld_end); /* in-place */
((string_ref *) result.flds.buffer)[i] = string_ref(fld_begin, wp);
}
}
result.cur_row_size =
start - (result.readbuf.begin() + result.cur_row_offset);
result.cur_row_offset = start - result.readbuf.begin();
return (string_ref *) result.flds.buffer;
}
size_t
hstcpcli::get_row_size()
{
return cur_row_size;
}
size_t
hstcpcli::get_row_size_from_result(hstresult& result)
{
return result.cur_row_size;
}
void
hstcpcli::response_buf_remove()
{
if (response_end_offset == 0) {
close();
set_error(-1, "response_buf_remove: protocol out of sync");
return;
}
readbuf.erase_front(response_end_offset);
response_end_offset = 0;
--num_req_rcvd;
cur_row_offset = 0;
num_flds = 0;
}
void
hstcpcli::write_error_to_log(
const char *func_name,
const char *file_name,
ulong line_no
) {
if (errno_buf) {
time_t cur_time = (time_t) time((time_t*) 0);
struct tm lt;
struct tm *l_time = localtime_r(&cur_time, &lt);
fprintf(stderr,
"%04d%02d%02d %02d:%02d:%02d [ERROR] hstcpcli: [%d][%s]"
" [%s][%s][%lu] errno=%d\n",
l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday,
l_time->tm_hour, l_time->tm_min, l_time->tm_sec,
error_code, error_str.c_ptr_safe(),
func_name, file_name, line_no, errno_buf);
}
}
hstcpcli_ptr
hstcpcli_i::create(const socket_args& args)
{
return hstcpcli_ptr(new hstcpcli(args));
}
};

View file

@ -1,93 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_HSTCPCLI_HPP
#define DENA_HSTCPCLI_HPP
#define HANDLERSOCKET_MYSQL_UTIL 1
#include "mysql_version.h"
#include "sql_priv.h"
#include "probes_mysql.h"
#include "config.hpp"
#include "socket.hpp"
#include "string_ref.hpp"
#include "string_buffer.hpp"
namespace dena {
struct hstcpcli_filter {
string_ref filter_type;
string_ref op;
size_t ff_offset;
string_ref val;
hstcpcli_filter() : ff_offset(0) { }
};
struct hstcpcli_i;
typedef hstcpcli_i *hstcpcli_ptr;
struct hstresult {
hstresult();
virtual ~hstresult();
string_buffer readbuf;
size_t response_end_offset;
size_t num_flds;
size_t cur_row_offset;
size_t cur_row_size;
DYNAMIC_ARRAY flds;
};
struct hstcpcli_i {
virtual ~hstcpcli_i() = default;
virtual void close() = 0;
virtual int reconnect() = 0;
virtual bool stable_point() = 0;
virtual void request_buf_auth(const char *secret, const char *typ) = 0;
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds,
const char *filflds = 0) = 0;
virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip,
const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
const hstcpcli_filter *fils = 0, size_t filslen = 0,
int invalues_keypart = -1, const string_ref *invalues = 0,
size_t invalueslen = 0) = 0; // FIXME: too long
virtual size_t request_buf_append(const char *start, const char *finish) = 0;
virtual void request_reset() = 0;
virtual int request_send() = 0;
virtual int response_recv(size_t& num_flds_r) = 0;
virtual int get_result(hstresult& result) = 0;
virtual const string_ref *get_next_row() = 0;
virtual const string_ref *get_next_row_from_result(hstresult& result) = 0;
virtual size_t get_row_size() = 0;
virtual size_t get_row_size_from_result(hstresult& result) = 0;
virtual void response_buf_remove() = 0;
virtual int get_error_code() = 0;
virtual String& get_error() = 0;
virtual void clear_error() = 0;
virtual int set_timeout(int send_timeout, int recv_timeout) = 0;
virtual size_t get_num_req_bufd() = 0;
virtual size_t get_num_req_sent() = 0;
virtual size_t get_num_req_rcvd() = 0;
virtual size_t get_response_end_offset() = 0;
virtual const char *get_readbuf_begin() = 0;
virtual const char *get_readbuf_end() = 0;
virtual const char *get_writebuf_begin() = 0;
virtual size_t get_writebuf_size() = 0;
virtual void write_error_to_log(const char *func_name, const char *file_name,
ulong line_no) = 0;
static hstcpcli_ptr create(const socket_args& args);
};
};
#endif

View file

@ -1,48 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_MUTEX_HPP
#define DENA_MUTEX_HPP
#include "fatal.hpp"
#include "util.hpp"
namespace dena {
struct condition;
struct mutex : private noncopyable {
friend struct condition;
mutex() {
if (pthread_mutex_init(&mtx, 0) != 0) {
fatal_abort("pthread_mutex_init");
}
}
~mutex() {
if (pthread_mutex_destroy(&mtx) != 0) {
fatal_abort("pthread_mutex_destroy");
}
}
void lock() const {
if (pthread_mutex_lock(&mtx) != 0) {
fatal_abort("pthread_mutex_lock");
}
}
void unlock() const {
if (pthread_mutex_unlock(&mtx) != 0) {
fatal_abort("pthread_mutex_unlock");
}
}
private:
mutable pthread_mutex_t mtx;
};
};
#endif

View file

@ -1,307 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include <my_global.h>
#include <my_config.h>
#ifndef _WIN32
#include <sys/types.h>
#include <sys/un.h>
#endif
#include "mysql_version.h"
#include "hs_compat.h"
#include <my_global.h>
#include "sql_priv.h"
#include "probes_mysql.h"
#include "socket.hpp"
#include "string_util.hpp"
#include "fatal.hpp"
/*
struct sockaddr_un {
short sun_family;
char sun_path[108];
};
*/
namespace dena {
void
ignore_sigpipe()
{
#if defined(SIGPIPE) && !defined(_WIN32)
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
fatal_abort("SIGPIPE SIG_IGN");
}
#endif
}
void
socket_args::set(const config& conf)
{
timeout = (int) conf.get_int("timeout", 600);
listen_backlog = (int) conf.get_int("listen_backlog", 256);
String node = conf.get_str("host", "");
String port = conf.get_str("port", "");
if (node.length() || port.length()) {
if (family == AF_UNIX || !strcmp(node.c_ptr(), "/")) {
set_unix_domain(port.c_ptr());
} else {
const char *nd = !node.length() ? 0 : node.c_ptr();
if (resolve(nd, port.c_ptr()) != 0) {
String message(STRING_WITH_LEN("getaddrinfo failed: "),
&my_charset_bin);
message.reserve(node.length() + sizeof(":") - 1 + port.length());
message.append(node);
message.q_append(":", sizeof(":") - 1);
message.append(port);
fatal_abort(message);
}
}
}
sndbuf = (int) conf.get_int("sndbuf", 0);
rcvbuf = (int) conf.get_int("rcvbuf", 0);
}
void
socket_args::set_unix_domain(const char *path)
{
#ifndef _WIN32
family = AF_UNIX;
addr = sockaddr_storage();
addrlen = sizeof(sockaddr_un);
sockaddr_un *const ap = reinterpret_cast<sockaddr_un *>(&addr);
ap->sun_family = AF_UNIX;
strncpy(ap->sun_path, path, sizeof(ap->sun_path) - 1);
#endif
}
int
socket_args::resolve(const char *node, const char *service)
{
const int flags = (node == 0) ? AI_PASSIVE : 0;
auto_addrinfo ai;
addr = sockaddr_storage();
addrlen = 0;
const int r = ai.resolve(node, service, flags, family, socktype, protocol);
if (r != 0) {
return r;
}
memcpy(&addr, ai.get()->ai_addr, ai.get()->ai_addrlen);
addrlen = ai.get()->ai_addrlen;
return 0;
}
int
socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r)
{
if (!args.nonblocking) {
#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO)
if (args.recv_timeout != 0) {
#ifndef _WIN32
struct timeval tv;
tv.tv_sec = args.recv_timeout;
tv.tv_usec = 0;
#else
int tv = args.recv_timeout * 1000;
#endif
if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO,
#ifndef _WIN32
(const void *) &tv,
#else
(const char *) &tv,
#endif
sizeof(tv)) != 0) {
return errno_string("setsockopt SO_RCVTIMEO", errno, err_r);
}
}
if (args.send_timeout != 0) {
#ifndef _WIN32
struct timeval tv;
tv.tv_sec = args.send_timeout;
tv.tv_usec = 0;
#else
int tv = args.send_timeout * 1000;
#endif
if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO,
#ifndef _WIN32
(const void *) &tv,
#else
(const char *) &tv,
#endif
sizeof(tv)) != 0) {
return errno_string("setsockopt SO_SNDTIMEO", errno, err_r);
}
}
#endif
}
return 0;
}
int
socket_set_options(auto_file& fd, const socket_args& args, String& err_r)
{
if (args.timeout != 0 && !args.nonblocking) {
#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO)
#ifndef _WIN32
struct timeval tv;
tv.tv_sec = args.timeout;
tv.tv_usec = 0;
#else
int tv = args.timeout * 1000;
#endif
if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO,
#ifndef _WIN32
(const void *) &tv,
#else
(const char *) &tv,
#endif
sizeof(tv)) != 0) {
return errno_string("setsockopt SO_RCVTIMEO", errno, err_r);
}
#ifndef _WIN32
tv.tv_sec = args.timeout;
tv.tv_usec = 0;
#else
tv = args.timeout * 1000;
#endif
if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO,
#ifndef _WIN32
(const void *) &tv,
#else
(const char *) &tv,
#endif
sizeof(tv)) != 0) {
return errno_string("setsockopt SO_RCVTIMEO", errno, err_r);
}
#endif
}
#ifndef _WIN32
if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) {
return errno_string("fcntl O_NONBLOCK", errno, err_r);
}
#endif
if (args.sndbuf != 0) {
const int v = args.sndbuf;
if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDBUF,
#ifndef _WIN32
(const void *) &v,
#else
(const char *) &v,
#endif
sizeof(v)) != 0) {
return errno_string("setsockopt SO_SNDBUF", errno, err_r);
}
}
if (args.rcvbuf != 0) {
const int v = args.rcvbuf;
if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVBUF,
#ifndef _WIN32
(const void *) &v,
#else
(const char *) &v,
#endif
sizeof(v)) != 0) {
return errno_string("setsockopt SO_RCVBUF", errno, err_r);
}
}
return 0;
}
int
socket_open(auto_file& fd, const socket_args& args, String& err_r)
{
fd.reset((int) socket(args.family, args.socktype, args.protocol));
if (fd.get() < 0) {
return errno_string("socket", errno, err_r);
}
return socket_set_options(fd, args, err_r);
}
int
socket_connect(auto_file& fd, const socket_args& args, String& err_r)
{
int r = 0;
if ((r = socket_open(fd, args, err_r)) != 0) {
return r;
}
if (connect(fd.get(), reinterpret_cast<const sockaddr *>(&args.addr),
args.addrlen) != 0) {
if (!args.nonblocking
#ifndef _WIN32
|| errno != EINPROGRESS
#endif
) {
return errno_string("connect", errno, err_r);
}
}
return 0;
}
int
socket_bind(auto_file& fd, const socket_args& args, String& err_r)
{
fd.reset((int) socket(args.family, args.socktype, args.protocol));
if (fd.get() < 0) {
return errno_string("socket", errno, err_r);
}
if (args.reuseaddr) {
#ifndef _WIN32
if (args.family == AF_UNIX) {
const sockaddr_un *const ap =
reinterpret_cast<const sockaddr_un *>(&args.addr);
if (unlink(ap->sun_path) != 0 && errno != ENOENT) {
return errno_string("unlink uds", errno, err_r);
}
} else {
#endif
int v = 1;
if (setsockopt(fd.get(), SOL_SOCKET, SO_REUSEADDR,
#ifndef _WIN32
(const void *) &v,
#else
(const char *) &v,
#endif
sizeof(v)) != 0) {
return errno_string("setsockopt SO_REUSEADDR", errno, err_r);
}
#ifndef _WIN32
}
#endif
}
if (bind(fd.get(), reinterpret_cast<const sockaddr *>(&args.addr),
args.addrlen) != 0) {
return errno_string("bind", errno, err_r);
}
if (listen(fd.get(), args.listen_backlog) != 0) {
return errno_string("listen", errno, err_r);
}
#ifndef _WIN32
if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) {
return errno_string("fcntl O_NONBLOCK", errno, err_r);
}
#endif
return 0;
}
int
socket_accept(int listen_fd, auto_file& fd, const socket_args& args,
sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r)
{
fd.reset((int) accept(listen_fd, reinterpret_cast<sockaddr *>(&addr_r),
&addrlen_r));
if (fd.get() < 0) {
return errno_string("accept", errno, err_r);
}
return socket_set_options(fd, args, err_r);
}
};

View file

@ -1,57 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_SOCKET_HPP
#define DENA_SOCKET_HPP
#include "mysql_version.h"
#include "sql_priv.h"
#include "probes_mysql.h"
#include "auto_addrinfo.hpp"
#include "auto_file.hpp"
#include "config.hpp"
namespace dena {
struct socket_args {
sockaddr_storage addr;
socklen_t addrlen;
int family;
int socktype;
int protocol;
int timeout;
int send_timeout;
int recv_timeout;
int listen_backlog;
bool reuseaddr;
bool nonblocking;
bool use_epoll;
int sndbuf;
int rcvbuf;
socket_args() : addr(), addrlen(0), family(AF_INET), socktype(SOCK_STREAM),
protocol(0), timeout(600), send_timeout(600), recv_timeout(600),
listen_backlog(256), reuseaddr(true), nonblocking(false), use_epoll(false),
sndbuf(0), rcvbuf(0) { }
void set(const config& conf);
void set_unix_domain(const char *path);
int resolve(const char *node, const char *service);
};
void ignore_sigpipe();
int socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r);
int socket_bind(auto_file& fd, const socket_args& args, String& err_r);
int socket_connect(auto_file& fd, const socket_args& args, String& err_r);
int socket_accept(int listen_fd, auto_file& fd, const socket_args& args,
sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r);
};
#endif

View file

@ -1,146 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_STRING_BUFFER_HPP
#define DENA_STRING_BUFFER_HPP
/*
#include <stdlib.h>
#include <string.h>
*/
#include "util.hpp"
#include "allocator.hpp"
#include "fatal.hpp"
namespace dena {
struct string_buffer : private noncopyable {
string_buffer() : buffer(0), begin_offset(0), end_offset(0), alloc_size(0) { }
~string_buffer() {
real_free();
}
void real_free() {
if (alloc_size) {
DENA_FREE(buffer);
buffer = 0;
begin_offset = 0;
end_offset = 0;
alloc_size = 0;
}
}
size_t real_size() {
return alloc_size;
}
const char *begin() const {
return buffer + begin_offset;
}
const char *end() const {
return buffer + end_offset;
}
char *begin() {
return buffer + begin_offset;
}
char *end() {
return buffer + end_offset;
}
size_t size() const {
return end_offset - begin_offset;
}
void clear() {
begin_offset = end_offset = 0;
}
void resize(size_t len) {
if (size() < len) {
reserve(len);
memset(buffer + end_offset, 0, len - size());
}
end_offset = begin_offset + len;
}
void reserve(size_t len) {
if (alloc_size >= begin_offset + len) {
return;
}
size_t asz = alloc_size;
while (asz < begin_offset + len) {
if (asz == 0) {
asz = 16;
}
const size_t asz_n = asz << 1;
if (asz_n < asz) {
fatal_abort("string_buffer::resize() overflow");
}
asz = asz_n;
}
void *const p = DENA_REALLOC(buffer, asz);
if (p == 0) {
fatal_abort("string_buffer::resize() realloc");
}
buffer = static_cast<char *>(p);
alloc_size = asz;
}
void erase_front(size_t len) {
if (len >= size()) {
clear();
} else {
begin_offset += len;
}
}
char *make_space(size_t len) {
reserve(size() + len);
return buffer + end_offset;
}
void space_wrote(size_t len) {
len = len < alloc_size - end_offset ? len : alloc_size - end_offset;
end_offset += len;
}
template <size_t N>
void append_literal(const char (& str)[N]) {
append(str, str + N - 1);
}
void append(const char *start, const char *finish) {
const size_t len = finish - start;
reserve(size() + len);
memcpy(buffer + end_offset, start, len);
end_offset += len;
}
void append_2(const char *s1, const char *f1, const char *s2,
const char *f2) {
const size_t l1 = f1 - s1;
const size_t l2 = f2 - s2;
reserve(end_offset + l1 + l2);
memcpy(buffer + end_offset, s1, l1);
memcpy(buffer + end_offset + l1, s2, l2);
end_offset += l1 + l2;
}
void swap(string_buffer& sb) {
char *tmp_buffer = buffer;
size_t tmp_begin_offset = begin_offset;
size_t tmp_end_offset = end_offset;
size_t tmp_alloc_size = alloc_size;
buffer = sb.buffer;
begin_offset = sb.begin_offset;
end_offset = sb.end_offset;
alloc_size = sb.alloc_size;
sb.buffer = tmp_buffer;
sb.begin_offset = tmp_begin_offset;
sb.end_offset = tmp_end_offset;
sb.alloc_size = tmp_alloc_size;
}
private:
char *buffer;
size_t begin_offset;
size_t end_offset;
size_t alloc_size;
};
};
#endif

View file

@ -1,106 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_STRING_REF_HPP
#define DENA_STRING_REF_HPP
namespace dena {
struct string_wref {
typedef char value_type;
char *begin() const { return start; }
char *end() const { return start + length; }
size_t size() const { return length; }
private:
char *start;
size_t length;
public:
string_wref(char *s = 0, size_t len = 0) : start(s), length(len) { }
};
struct string_ref {
typedef const char value_type;
const char *begin() const { return start; }
const char *end() const { return start + length; }
size_t size() const { return length; }
void set(const char *s, size_t len) { start = s; length = len; }
void set(const char *s, const char *f) { start = s; length = f - s; }
private:
const char *start;
size_t length;
public:
string_ref(const char *s = 0, size_t len = 0) : start(s), length(len) { }
string_ref(const char *s, const char *f) : start(s), length(f - s) { }
string_ref(const string_wref& w) : start(w.begin()), length(w.size()) { }
};
template <size_t N> inline bool
operator ==(const string_ref& x, const char (& y)[N]) {
return (x.size() == N - 1) && (::memcmp(x.begin(), y, N - 1) == 0);
}
inline bool
operator ==(const string_ref& x, const string_ref& y) {
return (x.size() == y.size()) &&
(::memcmp(x.begin(), y.begin(), x.size()) == 0);
}
inline bool
operator !=(const string_ref& x, const string_ref& y) {
return (x.size() != y.size()) ||
(::memcmp(x.begin(), y.begin(), x.size()) != 0);
}
struct string_ref_list_wrap {
string_ref_list_wrap() {
if (SPD_INIT_DYNAMIC_ARRAY2(&string_ref_list, sizeof(string_ref),
NULL, 16, 16, MYF(MY_WME)))
string_ref_list_init = FALSE;
else
string_ref_list_init = TRUE;
}
virtual ~string_ref_list_wrap() {
if (string_ref_list_init) delete_dynamic(&string_ref_list); }
void clear() {
if (string_ref_list_init) string_ref_list.elements = 0; }
void push_back(string_ref &e) {
if (string_ref_list_init) insert_dynamic(&string_ref_list, (uchar*) &e);
return; }
size_t size() {
return string_ref_list_init ? string_ref_list.elements : 0; }
bool resize(size_t new_size) {
if (string_ref_list_init) {
if (string_ref_list.max_element < new_size && allocate_dynamic(
&string_ref_list, new_size)) return TRUE;
string_ref_list.elements = new_size;
return FALSE;
}
return TRUE;
}
bool empty() {
return string_ref_list_init ? string_ref_list.elements ?
FALSE : TRUE : TRUE; }
string_ref &operator [](size_t n) {
return ((string_ref *) (string_ref_list.buffer +
string_ref_list.size_of_element * n))[0]; }
bool string_ref_list_init;
DYNAMIC_ARRAY string_ref_list;
};
inline String *
q_append_str(String *str, const char *p) {
uint32 p_len = strlen(p);
if (str->reserve(p_len)) return NULL;
str->q_append(p, p_len); return str;
}
};
#endif

View file

@ -1,202 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include <my_global.h>
#include "mysql_version.h"
#include "hs_compat.h"
#include "sql_priv.h"
#include "probes_mysql.h"
#include "string_util.hpp"
namespace dena {
string_wref
get_token(char *& wp, char *wp_end, char delim)
{
char *const wp_begin = wp;
char *const p = memchr_char(wp_begin, delim, wp_end - wp_begin);
if (p == 0) {
wp = wp_end;
return string_wref(wp_begin, wp_end - wp_begin);
}
wp = p + 1;
return string_wref(wp_begin, p - wp_begin);
}
uint32
atoi_uint32_nocheck(const char *start, const char *finish)
{
uint32 v = 0;
for (; start != finish; ++start) {
const char c = *start;
if (c < '0' || c > '9') {
break;
}
v *= 10;
v += (uint32) (c - '0');
}
return v;
}
long long
atoll_nocheck(const char *start, const char *finish)
{
long long v = 0;
bool negative = false;
if (start != finish) {
if (start[0] == '-') {
++start;
negative = true;
} else if (start[0] == '+') {
++start;
}
}
for (; start != finish; ++start) {
const char c = *start;
if (c < '0' || c > '9') {
break;
}
v *= 10;
if (negative) {
v -= (long long) (c - '0');
} else {
v += (long long) (c - '0');
}
}
return v;
}
void
append_uint32(string_buffer& buf, uint32 v)
{
char *const wp = buf.make_space(64);
const int len = snprintf(wp, 64, "%lu", static_cast<unsigned long>(v));
if (len > 0) {
buf.space_wrote(len);
}
}
/*
String *
to_stdstring(uint32 v)
{
char buf[64];
int str_len;
String *str;
str_len = snprintf(buf, sizeof(buf), "%lu", static_cast<unsigned long>(v));
if ((str = new String(str_len + 1)))
str->q_append(buf, str_len);
return str;
}
*/
int
errno_string(const char *s, int en, String& err_r)
{
char buf[64];
int str_len;
str_len = snprintf(buf, sizeof(buf), "%s: %d", s, en);
if (!err_r.reserve(str_len + 1))
err_r.q_append(buf, str_len);
return en;
}
size_t
split(char delim, const string_ref& buf, string_ref *parts,
size_t parts_len)
{
size_t i = 0;
const char *start = buf.begin();
const char *const finish = buf.end();
for (i = 0; i < parts_len; ++i) {
const char *const p = memchr_char(start, delim, finish - start);
if (p == 0) {
parts[i] = string_ref(start, finish - start);
++i;
break;
}
parts[i] = string_ref(start, p - start);
start = p + 1;
}
const size_t r = i;
for (; i < parts_len; ++i) {
parts[i] = string_ref();
}
return r;
}
size_t
split(char delim, const string_wref& buf, string_wref *parts,
size_t parts_len)
{
size_t i = 0;
char *start = buf.begin();
char *const finish = buf.end();
for (i = 0; i < parts_len; ++i) {
char *const p = memchr_char(start, delim, finish - start);
if (p == 0) {
parts[i] = string_wref(start, finish - start);
++i;
break;
}
parts[i] = string_wref(start, p - start);
start = p + 1;
}
const size_t r = i;
for (; i < parts_len; ++i) {
parts[i] = string_wref();
}
return r;
}
size_t
split(char delim, const string_ref& buf, DYNAMIC_ARRAY& parts_r)
{
size_t i = 0;
const char *start = buf.begin();
const char *finish = buf.end();
while (true) {
const char *p = memchr_char(start, delim, finish - start);
if (p == 0) {
string_ref param(start, finish - start);
insert_dynamic(&parts_r, (uchar *) &param);
break;
}
string_ref param(start, p - start);
insert_dynamic(&parts_r, (uchar *) &param);
start = p + 1;
}
const size_t r = i;
return r;
}
size_t
split(char delim, const string_wref& buf, DYNAMIC_ARRAY& parts_r)
{
size_t i = 0;
char *start = buf.begin();
char *finish = buf.end();
while (true) {
char *p = memchr_char(start, delim, finish - start);
if (p == 0) {
string_wref param(start, finish - start);
insert_dynamic(&parts_r, (uchar *) &param);
break;
}
string_wref param(start, p - start);
insert_dynamic(&parts_r, (uchar *) &param);
start = p + 1;
}
const size_t r = i;
return r;
}
};

View file

@ -1,51 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_STRING_UTIL_HPP
#define DENA_STRING_UTIL_HPP
#include "string_buffer.hpp"
#include "string_ref.hpp"
namespace dena {
inline const char *
memchr_char(const char *s, int c, size_t n)
{
return static_cast<const char *>(memchr(s, c, n));
}
inline char *
memchr_char(char *s, int c, size_t n)
{
return static_cast<char *>(memchr(s, c, n));
}
string_wref get_token(char *& wp, char *wp_end, char delim);
uint32 atoi_uint32_nocheck(const char *start, const char *finish);
/*
String *to_stdstring(uint32 v);
*/
void append_uint32(string_buffer& buf, uint32 v);
long long atoll_nocheck(const char *start, const char *finish);
int errno_string(const char *s, int en, String& err_r);
size_t split(char delim, const string_ref& buf, string_ref *parts,
size_t parts_len);
size_t split(char delim, const string_wref& buf, string_wref *parts,
size_t parts_len);
size_t split(char delim, const string_ref& buf,
DYNAMIC_ARRAY& parts_r);
size_t split(char delim, const string_wref& buf,
DYNAMIC_ARRAY& parts_r);
};
#endif

View file

@ -1,84 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_THREAD_HPP
#define DENA_THREAD_HPP
#include "fatal.hpp"
namespace dena {
/*
template <typename T>
struct thread : private noncopyable {
template <typename Ta> thread(const Ta& arg, size_t stack_sz = 256 * 1024)
: obj(arg), thr(0), need_join(false), stack_size(stack_sz) { }
template <typename Ta0, typename Ta1> thread(const Ta0& a0,
volatile Ta1& a1, size_t stack_sz = 256 * 1024)
: obj(a0, a1), thr(0), need_join(false), stack_size(stack_sz) { }
~thread() {
join();
}
void start() {
if (!start_nothrow()) {
fatal_abort("thread::start");
}
}
bool start_nothrow() {
if (need_join) {
return need_join;
}
void *const arg = this;
pthread_attr_t attr;
if (pthread_attr_init(&attr) != 0) {
fatal_abort("pthread_attr_init");
}
if (pthread_attr_setstacksize(&attr, stack_size) != 0) {
fatal_abort("pthread_attr_setstacksize");
}
const int r = pthread_create(&thr, &attr, thread_main, arg);
if (pthread_attr_destroy(&attr) != 0) {
fatal_abort("pthread_attr_destroy");
}
if (r != 0) {
return need_join;
}
need_join = true;
return need_join;
}
void join() {
if (!need_join) {
return;
}
int e = 0;
if ((e = pthread_join(thr, 0)) != 0) {
fatal_abort("pthread_join");
}
need_join = false;
}
T& operator *() { return obj; }
T *operator ->() { return &obj; }
private:
static void *thread_main(void *arg) {
thread *p = static_cast<thread *>(arg);
p->obj();
return 0;
}
private:
T obj;
pthread_t thr;
bool need_join;
size_t stack_size;
};
*/
};
#endif

View file

@ -1,25 +0,0 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_UTIL_HPP
#define DENA_UTIL_HPP
namespace dena {
/* boost::noncopyable */
struct noncopyable {
noncopyable() = default;
private:
noncopyable(const noncopyable&);
noncopyable& operator =(const noncopyable&);
};
};
#endif

View file

@ -0,0 +1,24 @@
#
# MDEV-29027 ASAN errors in spider_db_free_result after partition DDL
#
for master_1
for child2
child2_1
child2_2
child2_3
for child3
CREATE DATABASE auto_test_local;
USE auto_test_local;
CREATE TABLE tbl_a (
c INT
) ENGINE=Spider DEFAULT CHARSET=utf8 PARTITION BY HASH(c) (
PARTITION pt1
);
ALTER TABLE tbl_a ADD PARTITION (PARTITION pt2);
DROP DATABASE auto_test_local;
for master_1
for child2
child2_1
child2_2
child2_3
for child3

View file

@ -0,0 +1,15 @@
for master_1
for child2
for child3
set spider_same_server_link= 1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
CREATE TABLE t_spider (a INT) ENGINE=SPIDER PARTITION BY HASH(a) (PARTITION p1 COMMENT = "wrapper 'mysql', srv 'srv', table 't1'");
CREATE TABLE t2 (a INT);
ALTER TABLE t_spider ADD PARTITION (PARTITION p2 COMMENT = "wrapper 'mysql', srv 'srv', table 't2'");
DROP TABLE t_spider, t1, t2;
drop server srv;
for master_1
for child2
for child3

View file

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

View file

@ -0,0 +1,28 @@
--echo #
--echo # MDEV-29027 ASAN errors in spider_db_free_result after partition DDL
--echo #
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
CREATE DATABASE auto_test_local;
USE auto_test_local;
eval CREATE TABLE tbl_a (
c INT
) $MASTER_1_ENGINE $MASTER_1_CHARSET PARTITION BY HASH(c) (
PARTITION pt1
);
ALTER TABLE tbl_a ADD PARTITION (PARTITION pt2);
DROP DATABASE auto_test_local;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

View file

@ -0,0 +1,22 @@
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
--source include/have_partition.inc
set spider_same_server_link= 1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
CREATE TABLE t_spider (a INT) ENGINE=SPIDER PARTITION BY HASH(a) (PARTITION p1 COMMENT = "wrapper 'mysql', srv 'srv', table 't1'");
CREATE TABLE t2 (a INT);
ALTER TABLE t_spider ADD PARTITION (PARTITION p2 COMMENT = "wrapper 'mysql', srv 'srv', table 't2'");
DROP TABLE t_spider, t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

View file

@ -103,20 +103,6 @@ const char *spider_open_connections_func_name;
const char *spider_open_connections_file_name;
ulong spider_open_connections_line_no;
pthread_mutex_t spider_conn_mutex;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
HASH spider_hs_r_conn_hash;
uint spider_hs_r_conn_hash_id;
const char *spider_hs_r_conn_hash_func_name;
const char *spider_hs_r_conn_hash_file_name;
ulong spider_hs_r_conn_hash_line_no;
pthread_mutex_t spider_hs_r_conn_mutex;
HASH spider_hs_w_conn_hash;
uint spider_hs_w_conn_hash_id;
const char *spider_hs_w_conn_hash_func_name;
const char *spider_hs_w_conn_hash_file_name;
ulong spider_hs_w_conn_hash_line_no;
pthread_mutex_t spider_hs_w_conn_mutex;
#endif
/* for spider_open_connections and trx_conn_hash */
uchar *spider_conn_get_key(
@ -311,10 +297,6 @@ void spider_free_conn_from_trx(
spider_conn_clear_queue(conn);
conn->use_for_active_standby = FALSE;
conn->error_mode = 1;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
if (
trx_free ||
(
@ -413,134 +395,6 @@ void spider_free_conn_from_trx(
}
} else if (roop_count)
(*roop_count)++;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ)
{
spider_db_hs_request_buf_reset(conn);
if (
trx_free ||
(
(
conn->server_lost ||
spider_param_hs_r_conn_recycle_mode(trx->thd) != 2
) &&
!conn->opened_handlers
)
) {
conn->thd = NULL;
#ifdef HASH_UPDATE_WITH_HASH_VALUE
my_hash_delete_with_hash_value(&trx->trx_hs_r_conn_hash,
conn->conn_key_hash_value, (uchar*) conn);
#else
my_hash_delete(&trx->trx_hs_r_conn_hash, (uchar*) conn);
#endif
DBUG_ASSERT(conn->opened_handlers ==
conn->db_conn->get_opened_handler_count());
if (conn->db_conn->get_opened_handler_count())
{
conn->db_conn->reset_opened_handler();
}
if (
!trx_free &&
!conn->server_lost &&
!conn->queued_connect &&
spider_param_hs_r_conn_recycle_mode(trx->thd) == 1
) {
/* conn_recycle_mode == 1 */
*conn->conn_key = '0';
pthread_mutex_lock(&spider_hs_r_conn_mutex);
uint old_elements = spider_hs_r_conn_hash.array.max_element;
#ifdef HASH_UPDATE_WITH_HASH_VALUE
if (my_hash_insert_with_hash_value(&spider_hs_r_conn_hash,
conn->conn_key_hash_value, (uchar*) conn))
#else
if (my_hash_insert(&spider_hs_r_conn_hash, (uchar*) conn))
#endif
{
pthread_mutex_unlock(&spider_hs_r_conn_mutex);
spider_free_conn(conn);
} else {
if (spider_hs_r_conn_hash.array.max_element > old_elements)
{
spider_alloc_calc_mem(spider_current_trx,
spider_hs_r_conn_hash,
(spider_hs_r_conn_hash.array.max_element - old_elements) *
spider_hs_r_conn_hash.array.size_of_element);
}
pthread_mutex_unlock(&spider_hs_r_conn_mutex);
}
} else {
/* conn_recycle_mode == 0 */
spider_free_conn(conn);
}
} else if (roop_count)
(*roop_count)++;
} else {
spider_db_hs_request_buf_reset(conn);
if (
trx_free ||
(
(
conn->server_lost ||
spider_param_hs_w_conn_recycle_mode(trx->thd) != 2
) &&
!conn->opened_handlers
)
) {
conn->thd = NULL;
#ifdef HASH_UPDATE_WITH_HASH_VALUE
my_hash_delete_with_hash_value(&trx->trx_hs_w_conn_hash,
conn->conn_key_hash_value, (uchar*) conn);
#else
my_hash_delete(&trx->trx_hs_w_conn_hash, (uchar*) conn);
#endif
DBUG_ASSERT(conn->opened_handlers ==
conn->db_conn->get_opened_handler_count());
if (conn->db_conn->get_opened_handler_count())
{
conn->db_conn->reset_opened_handler();
}
if (
!trx_free &&
!conn->server_lost &&
!conn->queued_connect &&
spider_param_hs_w_conn_recycle_mode(trx->thd) == 1
) {
/* conn_recycle_mode == 1 */
*conn->conn_key = '0';
pthread_mutex_lock(&spider_hs_w_conn_mutex);
uint old_elements = spider_hs_w_conn_hash.array.max_element;
#ifdef HASH_UPDATE_WITH_HASH_VALUE
if (my_hash_insert_with_hash_value(&spider_hs_w_conn_hash,
conn->conn_key_hash_value, (uchar*) conn))
#else
if (my_hash_insert(&spider_hs_w_conn_hash, (uchar*) conn))
#endif
{
pthread_mutex_unlock(&spider_hs_w_conn_mutex);
spider_free_conn(conn);
} else {
if (spider_hs_w_conn_hash.array.max_element > old_elements)
{
spider_alloc_calc_mem(spider_current_trx,
spider_hs_w_conn_hash,
(spider_hs_w_conn_hash.array.max_element - old_elements) *
spider_hs_w_conn_hash.array.size_of_element);
}
pthread_mutex_unlock(&spider_hs_w_conn_mutex);
}
} else {
/* conn_recycle_mode == 0 */
spider_free_conn(conn);
}
} else if (roop_count)
(*roop_count)++;
}
#endif
DBUG_VOID_RETURN;
}
@ -568,10 +422,6 @@ SPIDER_CONN *spider_create_conn(
UTC = my_tz_find(current_thd, &tz_00_name);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
bool tables_on_different_db_are_joinable;
if (share->sql_dbton_ids[link_idx] != SPIDER_DBTON_SIZE)
{
@ -750,113 +600,13 @@ SPIDER_CONN *spider_create_conn(
conn->tgt_port = share->tgt_ports[link_idx];
conn->tgt_ssl_vsc = share->tgt_ssl_vscs[link_idx];
conn->dbton_id = share->sql_dbton_ids[link_idx];
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (conn_kind == SPIDER_CONN_KIND_HS_READ) {
if (!(conn = (SPIDER_CONN *)
spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_CONN_3, MYF(MY_WME | MY_ZEROFILL),
&conn, (uint) (sizeof(*conn)),
&tmp_name, (uint) (share->hs_read_conn_keys_lengths[link_idx] + 1),
&tmp_host, (uint) (share->tgt_hosts_lengths[link_idx] + 1),
&tmp_socket, (uint) (share->hs_read_socks_lengths[link_idx] + 1),
&tmp_wrapper,
(uint) (share->tgt_wrappers_lengths[link_idx] + 1),
&need_mon, (uint) (sizeof(int)),
NullS))
) {
*error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_conn;
}
conn->default_database.init_calc_mem(SPD_MID_CREATE_CONN_4);
conn->conn_key_length = share->hs_read_conn_keys_lengths[link_idx];
conn->conn_key = tmp_name;
memcpy(conn->conn_key, share->hs_read_conn_keys[link_idx],
share->hs_read_conn_keys_lengths[link_idx]);
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
conn->conn_key_hash_value = share->hs_read_conn_keys_hash_value[link_idx];
#endif
conn->tgt_host_length = share->tgt_hosts_lengths[link_idx];
conn->tgt_host = tmp_host;
memcpy(conn->tgt_host, share->tgt_hosts[link_idx],
share->tgt_hosts_lengths[link_idx]);
conn->hs_sock_length = share->hs_read_socks_lengths[link_idx];
if (conn->hs_sock_length)
{
conn->hs_sock = tmp_socket;
memcpy(conn->hs_sock, share->hs_read_socks[link_idx],
share->hs_read_socks_lengths[link_idx]);
} else
conn->hs_sock = NULL;
conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx];
conn->tgt_wrapper = tmp_wrapper;
memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx],
share->tgt_wrappers_lengths[link_idx]);
conn->hs_port = share->hs_read_ports[link_idx];
conn->dbton_id = share->hs_dbton_ids[link_idx];
} else {
if (!(conn = (SPIDER_CONN *)
spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_CONN_5, MYF(MY_WME | MY_ZEROFILL),
&conn, (uint) (sizeof(*conn)),
&tmp_name, (uint) (share->hs_write_conn_keys_lengths[link_idx] + 1),
&tmp_host, (uint) (share->tgt_hosts_lengths[link_idx] + 1),
&tmp_socket, (uint) (share->hs_write_socks_lengths[link_idx] + 1),
&tmp_wrapper,
(uint) (share->tgt_wrappers_lengths[link_idx] + 1),
&need_mon, (uint) (sizeof(int)),
NullS))
) {
*error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_conn;
}
conn->default_database.init_calc_mem(SPD_MID_CREATE_CONN_6);
conn->conn_key_length = share->hs_write_conn_keys_lengths[link_idx];
conn->conn_key = tmp_name;
memcpy(conn->conn_key, share->hs_write_conn_keys[link_idx],
share->hs_write_conn_keys_lengths[link_idx]);
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
conn->conn_key_hash_value = share->hs_write_conn_keys_hash_value[link_idx];
#endif
conn->tgt_host_length = share->tgt_hosts_lengths[link_idx];
conn->tgt_host = tmp_host;
memcpy(conn->tgt_host, share->tgt_hosts[link_idx],
share->tgt_hosts_lengths[link_idx]);
conn->hs_sock_length = share->hs_write_socks_lengths[link_idx];
if (conn->hs_sock_length)
{
conn->hs_sock = tmp_socket;
memcpy(conn->hs_sock, share->hs_write_socks[link_idx],
share->hs_write_socks_lengths[link_idx]);
} else
conn->hs_sock = NULL;
conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx];
conn->tgt_wrapper = tmp_wrapper;
memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx],
share->tgt_wrappers_lengths[link_idx]);
conn->hs_port = share->hs_write_ports[link_idx];
conn->dbton_id = share->hs_dbton_ids[link_idx];
}
#endif
if (conn->dbton_id == SPIDER_DBTON_SIZE)
{
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
my_printf_error(
ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM,
ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR,
MYF(0), conn->tgt_wrapper);
*error_num = ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
my_printf_error(
ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM,
ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR,
MYF(0), conn->tgt_wrapper);
*error_num = ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM;
}
#endif
goto error_invalid_wrapper;
}
if (!(conn->db_conn = spider_dbton[conn->dbton_id].create_db_conn(conn)))
@ -980,33 +730,11 @@ SPIDER_CONN *spider_get_conn(
DBUG_PRINT("info",("spider link_idx=%u", link_idx));
DBUG_PRINT("info",("spider base_link_idx=%u", base_link_idx));
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
#ifdef DBUG_TRACE
spider_print_keys(conn_key, share->conn_keys_lengths[link_idx]);
#endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (conn_kind == SPIDER_CONN_KIND_HS_READ)
{
conn_key = share->hs_read_conn_keys[link_idx];
#ifdef DBUG_TRACE
spider_print_keys(conn_key, share->hs_read_conn_keys_lengths[link_idx]);
#endif
} else {
conn_key = share->hs_write_conn_keys[link_idx];
#ifdef DBUG_TRACE
spider_print_keys(conn_key, share->hs_write_conn_keys_lengths[link_idx]);
#endif
}
#endif
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
if (
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(conn_kind == SPIDER_CONN_KIND_MYSQL &&
(
#endif
(another &&
!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
&trx->trx_another_conn_hash,
@ -1017,79 +745,25 @@ SPIDER_CONN *spider_get_conn(
&trx->trx_conn_hash,
share->conn_keys_hash_value[link_idx],
(uchar*) conn_key, share->conn_keys_lengths[link_idx])))
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
)
) ||
(conn_kind == SPIDER_CONN_KIND_HS_READ &&
!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
&trx->trx_hs_r_conn_hash,
share->hs_read_conn_keys_hash_value[link_idx],
(uchar*) conn_key, share->hs_read_conn_keys_lengths[link_idx]))
) ||
(conn_kind == SPIDER_CONN_KIND_HS_WRITE &&
!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
&trx->trx_hs_w_conn_hash,
share->hs_write_conn_keys_hash_value[link_idx],
(uchar*) conn_key, share->hs_write_conn_keys_lengths[link_idx]))
)
#endif
)
#else
if (
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(conn_kind == SPIDER_CONN_KIND_MYSQL &&
(
#endif
(another &&
!(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_another_conn_hash,
(uchar*) conn_key, share->conn_keys_lengths[link_idx]))) ||
(!another &&
!(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash,
(uchar*) conn_key, share->conn_keys_lengths[link_idx])))
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
)
) ||
(conn_kind == SPIDER_CONN_KIND_HS_READ &&
!(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_hs_r_conn_hash,
(uchar*) conn_key, share->hs_read_conn_keys_lengths[link_idx]))
) ||
(conn_kind == SPIDER_CONN_KIND_HS_WRITE &&
!(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_hs_w_conn_hash,
(uchar*) conn_key, share->hs_write_conn_keys_lengths[link_idx]))
)
#endif
)
#endif
{
if (
!trx->thd ||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(conn_kind == SPIDER_CONN_KIND_MYSQL &&
#endif
(
(spider_param_conn_recycle_mode(trx->thd) & 1) ||
spider_param_conn_recycle_strict(trx->thd)
)
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
) ||
(conn_kind == SPIDER_CONN_KIND_HS_READ &&
(
(spider_param_hs_r_conn_recycle_mode(trx->thd) & 1) ||
spider_param_hs_r_conn_recycle_strict(trx->thd)
)
) ||
(conn_kind == SPIDER_CONN_KIND_HS_WRITE &&
(
(spider_param_hs_w_conn_recycle_mode(trx->thd) & 1) ||
spider_param_hs_w_conn_recycle_strict(trx->thd)
)
)
#endif
) {
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
pthread_mutex_lock(&spider_conn_mutex);
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
@ -1141,94 +815,6 @@ SPIDER_CONN *spider_get_conn(
conn->use_for_active_standby = TRUE;
}
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (conn_kind == SPIDER_CONN_KIND_HS_READ)
{
pthread_mutex_lock(&spider_hs_r_conn_mutex);
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
&spider_hs_r_conn_hash,
share->hs_read_conn_keys_hash_value[link_idx],
(uchar*) share->hs_read_conn_keys[link_idx],
share->hs_read_conn_keys_lengths[link_idx])))
#else
if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_hs_r_conn_hash,
(uchar*) share->hs_read_conn_keys[link_idx],
share->hs_read_conn_keys_lengths[link_idx])))
#endif
{
pthread_mutex_unlock(&spider_hs_r_conn_mutex);
DBUG_PRINT("info",("spider create new hs r conn"));
if (!(conn = spider_create_conn(share, spider, link_idx,
base_link_idx, conn_kind, error_num)))
goto error;
*conn->conn_key = *conn_key;
if (spider)
{
spider->hs_r_conns[base_link_idx] = conn;
if (spider_bit_is_set(spider->conn_can_fo, base_link_idx))
conn->use_for_active_standby = TRUE;
}
} else {
#ifdef HASH_UPDATE_WITH_HASH_VALUE
my_hash_delete_with_hash_value(&spider_hs_r_conn_hash,
conn->conn_key_hash_value, (uchar*) conn);
#else
my_hash_delete(&spider_hs_r_conn_hash, (uchar*) conn);
#endif
pthread_mutex_unlock(&spider_hs_r_conn_mutex);
DBUG_PRINT("info",("spider get global hs r conn"));
if (spider)
{
spider->hs_r_conns[base_link_idx] = conn;
if (spider_bit_is_set(spider->conn_can_fo, base_link_idx))
conn->use_for_active_standby = TRUE;
}
}
} else {
pthread_mutex_lock(&spider_hs_w_conn_mutex);
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
&spider_hs_w_conn_hash,
share->hs_write_conn_keys_hash_value[link_idx],
(uchar*) share->hs_write_conn_keys[link_idx],
share->hs_write_conn_keys_lengths[link_idx])))
#else
if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_hs_w_conn_hash,
(uchar*) share->hs_write_conn_keys[link_idx],
share->hs_write_conn_keys_lengths[link_idx])))
#endif
{
pthread_mutex_unlock(&spider_hs_w_conn_mutex);
DBUG_PRINT("info",("spider create new hs w conn"));
if (!(conn = spider_create_conn(share, spider, link_idx,
base_link_idx, conn_kind, error_num)))
goto error;
*conn->conn_key = *conn_key;
if (spider)
{
spider->hs_w_conns[base_link_idx] = conn;
if (spider_bit_is_set(spider->conn_can_fo, base_link_idx))
conn->use_for_active_standby = TRUE;
}
} else {
#ifdef HASH_UPDATE_WITH_HASH_VALUE
my_hash_delete_with_hash_value(&spider_hs_w_conn_hash,
conn->conn_key_hash_value, (uchar*) conn);
#else
my_hash_delete(&spider_hs_w_conn_hash, (uchar*) conn);
#endif
pthread_mutex_unlock(&spider_hs_w_conn_mutex);
DBUG_PRINT("info",("spider get global hs w conn"));
if (spider)
{
spider->hs_w_conns[base_link_idx] = conn;
if (spider_bit_is_set(spider->conn_can_fo, base_link_idx))
conn->use_for_active_standby = TRUE;
}
}
}
#endif
} else {
DBUG_PRINT("info",("spider create new conn"));
/* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */
@ -1238,19 +824,7 @@ SPIDER_CONN *spider_get_conn(
*conn->conn_key = *conn_key;
if (spider)
{
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
spider->conns[base_link_idx] = conn;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (conn_kind == SPIDER_CONN_KIND_HS_READ)
{
spider->hs_r_conns[base_link_idx] = conn;
} else {
spider->hs_w_conns[base_link_idx] = conn;
}
#endif
if (spider_bit_is_set(spider->conn_can_fo, base_link_idx))
conn->use_for_active_standby = TRUE;
}
@ -1258,10 +832,6 @@ SPIDER_CONN *spider_get_conn(
conn->thd = trx->thd;
conn->priority = share->priority;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
if (another)
{
uint old_elements = trx->trx_another_conn_hash.array.max_element;
@ -1306,67 +876,9 @@ SPIDER_CONN *spider_get_conn(
trx->trx_conn_hash.array.size_of_element);
}
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (conn_kind == SPIDER_CONN_KIND_HS_READ)
{
uint old_elements = trx->trx_hs_r_conn_hash.array.max_element;
#ifdef HASH_UPDATE_WITH_HASH_VALUE
if (my_hash_insert_with_hash_value(&trx->trx_hs_r_conn_hash,
share->hs_read_conn_keys_hash_value[link_idx],
(uchar*) conn))
#else
if (my_hash_insert(&trx->trx_hs_r_conn_hash, (uchar*) conn))
#endif
{
spider_free_conn(conn);
*error_num = HA_ERR_OUT_OF_MEM;
goto error;
}
if (trx->trx_hs_r_conn_hash.array.max_element > old_elements)
{
spider_alloc_calc_mem(spider_current_trx,
trx->trx_hs_r_conn_hash,
(trx->trx_hs_r_conn_hash.array.max_element - old_elements) *
trx->trx_hs_r_conn_hash.array.size_of_element);
}
} else {
uint old_elements = trx->trx_hs_w_conn_hash.array.max_element;
#ifdef HASH_UPDATE_WITH_HASH_VALUE
if (my_hash_insert_with_hash_value(&trx->trx_hs_w_conn_hash,
share->hs_write_conn_keys_hash_value[link_idx],
(uchar*) conn))
#else
if (my_hash_insert(&trx->trx_hs_w_conn_hash, (uchar*) conn))
#endif
{
spider_free_conn(conn);
*error_num = HA_ERR_OUT_OF_MEM;
goto error;
}
if (trx->trx_hs_w_conn_hash.array.max_element > old_elements)
{
spider_alloc_calc_mem(spider_current_trx,
trx->trx_hs_w_conn_hash,
(trx->trx_hs_w_conn_hash.array.max_element - old_elements) *
trx->trx_hs_w_conn_hash.array.size_of_element);
}
}
#endif
} else if (spider)
{
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
spider->conns[base_link_idx] = conn;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (conn_kind == SPIDER_CONN_KIND_HS_READ)
{
spider->hs_r_conns[base_link_idx] = conn;
} else {
spider->hs_w_conns[base_link_idx] = conn;
}
#endif
if (spider_bit_is_set(spider->conn_can_fo, base_link_idx))
conn->use_for_active_standby = TRUE;
}
@ -1383,19 +895,12 @@ SPIDER_CONN *spider_get_conn(
conn->queued_ping = FALSE;
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
if (unlikely(spider && spider->wide_handler->top_share &&
(*error_num = spider_conn_queue_loop_check(
conn, spider, base_link_idx))))
{
goto error;
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
}
#endif
DBUG_PRINT("info",("spider conn=%p", conn));
DBUG_RETURN(conn);
@ -2430,14 +1935,6 @@ int spider_set_conn_bg_param(
) {
if ((error_num = spider_create_conn_thread(spider->conns[roop_count])))
DBUG_RETURN(error_num);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if ((error_num = spider_create_conn_thread(
spider->hs_r_conns[roop_count])))
DBUG_RETURN(error_num);
if ((error_num = spider_create_conn_thread(
spider->hs_w_conns[roop_count])))
DBUG_RETURN(error_num);
#endif
}
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
}
@ -2764,19 +2261,9 @@ int spider_bg_conn_search(
bool with_lock = FALSE;
DBUG_ENTER("spider_bg_conn_search");
DBUG_PRINT("info",("spider spider=%p", spider));
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL)
{
#endif
conn = spider->conns[link_idx];
with_lock = (spider_conn_lock_mode(spider) != SPIDER_LOCK_MODE_NO_LOCK);
first_conn = spider->conns[first_link_idx];
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ)
conn = spider->hs_r_conns[link_idx];
else
conn = spider->hs_w_conns[link_idx];
#endif
if (first)
{
if (spider->use_pre_call)
@ -3235,21 +2722,12 @@ void *spider_bg_conn_action(
!result_list->bgs_current->result
) {
ulong sql_type;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
if (spider->sql_kind[conn->link_idx] == SPIDER_SQL_KIND_SQL)
{
sql_type = SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL;
} else {
sql_type = SPIDER_SQL_TYPE_HANDLER;
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
sql_type = SPIDER_SQL_TYPE_SELECT_HS;
}
#endif
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (spider->use_fields)
{
@ -3577,27 +3055,12 @@ void *spider_bg_sts_action(
uint *conn_link_idx;
uchar *conn_can_fo;
char **conn_keys;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
char **hs_r_conn_keys;
char **hs_w_conn_keys;
#endif
spider_db_handler **dbton_hdl;
THD *thd;
my_thread_init();
DBUG_ENTER("spider_bg_sts_action");
/* init start */
char *ptr;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
ptr = (char *) my_alloca(
(sizeof(int) * share->link_count) +
(sizeof(SPIDER_CONN *) * share->link_count) +
(sizeof(uint) * share->link_count) +
(sizeof(uchar) * share->link_bitmap_size) +
(sizeof(char *) * share->link_count) +
(sizeof(char *) * share->link_count) +
(sizeof(char *) * share->link_count) +
(sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE));
#else
ptr = (char *) my_alloca(
(sizeof(int) * share->link_count) +
(sizeof(SPIDER_CONN *) * share->link_count) +
@ -3605,7 +3068,6 @@ void *spider_bg_sts_action(
(sizeof(uchar) * share->link_bitmap_size) +
(sizeof(char *) * share->link_count) +
(sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE));
#endif
if (!ptr)
{
pthread_mutex_lock(&share->sts_mutex);
@ -3626,12 +3088,6 @@ void *spider_bg_sts_action(
ptr += (sizeof(uchar) * share->link_bitmap_size);
conn_keys = (char **) ptr;
ptr += (sizeof(char *) * share->link_count);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
hs_r_conn_keys = (char **) ptr;
ptr += (sizeof(char *) * share->link_count);
hs_w_conn_keys = (char **) ptr;
ptr += (sizeof(char *) * share->link_count);
#endif
dbton_hdl = (spider_db_handler **) ptr;
pthread_mutex_lock(&share->sts_mutex);
if (!(thd = SPIDER_new_THD(next_thread_id())))
@ -3674,10 +3130,6 @@ void *spider_bg_sts_action(
spider.need_mons = need_mons;
spider.conn_keys_first_ptr = share->conn_keys[0];
spider.conn_keys = conn_keys;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
spider.hs_r_conn_keys = hs_r_conn_keys;
spider.hs_w_conn_keys = hs_w_conn_keys;
#endif
spider.dbton_handler = dbton_hdl;
memset(conns, 0, sizeof(SPIDER_CONN *) * share->link_count);
memset(need_mons, 0, sizeof(int) * share->link_count);
@ -3931,27 +3383,12 @@ void *spider_bg_crd_action(
uint *conn_link_idx;
uchar *conn_can_fo;
char **conn_keys;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
char **hs_r_conn_keys;
char **hs_w_conn_keys;
#endif
spider_db_handler **dbton_hdl;
THD *thd;
my_thread_init();
DBUG_ENTER("spider_bg_crd_action");
/* init start */
char *ptr;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
ptr = (char *) my_alloca(
(sizeof(int) * share->link_count) +
(sizeof(SPIDER_CONN *) * share->link_count) +
(sizeof(uint) * share->link_count) +
(sizeof(uchar) * share->link_bitmap_size) +
(sizeof(char *) * share->link_count) +
(sizeof(char *) * share->link_count) +
(sizeof(char *) * share->link_count) +
(sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE));
#else
ptr = (char *) my_alloca(
(sizeof(int) * share->link_count) +
(sizeof(SPIDER_CONN *) * share->link_count) +
@ -3959,7 +3396,6 @@ void *spider_bg_crd_action(
(sizeof(uchar) * share->link_bitmap_size) +
(sizeof(char *) * share->link_count) +
(sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE));
#endif
if (!ptr)
{
pthread_mutex_lock(&share->crd_mutex);
@ -3980,12 +3416,6 @@ void *spider_bg_crd_action(
ptr += (sizeof(uchar) * share->link_bitmap_size);
conn_keys = (char **) ptr;
ptr += (sizeof(char *) * share->link_count);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
hs_r_conn_keys = (char **) ptr;
ptr += (sizeof(char *) * share->link_count);
hs_w_conn_keys = (char **) ptr;
ptr += (sizeof(char *) * share->link_count);
#endif
dbton_hdl = (spider_db_handler **) ptr;
pthread_mutex_lock(&share->crd_mutex);
if (!(thd = SPIDER_new_THD(next_thread_id())))
@ -4032,10 +3462,6 @@ void *spider_bg_crd_action(
spider.need_mons = need_mons;
spider.conn_keys_first_ptr = share->conn_keys[0];
spider.conn_keys = conn_keys;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
spider.hs_r_conn_keys = hs_r_conn_keys;
spider.hs_w_conn_keys = hs_w_conn_keys;
#endif
spider.dbton_handler = dbton_hdl;
memset(conns, 0, sizeof(SPIDER_CONN *) * share->link_count);
memset(need_mons, 0, sizeof(int) * share->link_count);
@ -4717,51 +4143,14 @@ bool spider_conn_use_handler(
DBUG_PRINT("info",("spider use_handler=%d", use_handler));
DBUG_PRINT("info",("spider spider->conn_kind[link_idx]=%u",
spider->conn_kind[link_idx]));
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (spider->conn_kind[link_idx] != SPIDER_CONN_KIND_MYSQL)
{
DBUG_PRINT("info",("spider TRUE by HS"));
spider->sql_kinds |= SPIDER_SQL_KIND_HS;
spider->sql_kind[link_idx] = SPIDER_SQL_KIND_HS;
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
if (
spider->do_direct_update &&
spider_bit_is_set(spider->do_hs_direct_update, link_idx)
) {
DBUG_PRINT("info",("spider using HS direct_update"));
spider->direct_update_kinds |= SPIDER_SQL_KIND_HS;
}
#endif
DBUG_RETURN(TRUE);
}
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
if (spider->do_direct_update)
{
spider->sql_kinds |= SPIDER_SQL_KIND_SQL;
spider->sql_kind[link_idx] = SPIDER_SQL_KIND_SQL;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (spider_bit_is_set(spider->do_hs_direct_update, link_idx))
{
spider->direct_update_kinds |= SPIDER_SQL_KIND_HS;
DBUG_PRINT("info",("spider TRUE by using HS direct_update"));
DBUG_RETURN(TRUE);
} else {
#endif
spider->direct_update_kinds |= SPIDER_SQL_KIND_SQL;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
}
if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL)
{
#endif
DBUG_PRINT("info",("spider FALSE by using direct_update"));
DBUG_RETURN(FALSE);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
DBUG_PRINT("info",("spider TRUE by using BOTH"));
DBUG_RETURN(TRUE);
}
#endif
}
#endif
if (spider->use_spatial_index)
@ -4819,173 +4208,12 @@ bool spider_conn_need_open_handler(
uint idx,
int link_idx
) {
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
SPIDER_CONN *conn;
#endif
DBUG_ENTER("spider_conn_need_open_handler");
DBUG_PRINT("info",("spider spider=%p", spider));
if (spider->handler_opened(link_idx, spider->conn_kind[link_idx]))
{
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
if (
spider->do_direct_update &&
spider_bit_is_set(spider->do_hs_direct_update, link_idx)
) {
conn = spider->hs_w_conns[link_idx];
if (
!conn->server_lost &&
conn->hs_pre_age == spider->hs_w_conn_ages[link_idx]
) {
DBUG_PRINT("info",("spider hs_write is already opened"));
DBUG_RETURN(FALSE);
}
} else
#endif
if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL)
{
#endif
DBUG_PRINT("info",("spider HA already opened"));
DBUG_RETURN(FALSE);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ)
{
DBUG_PRINT("info",("spider r_handler_index[%d]=%d",
link_idx, spider->r_handler_index[link_idx]));
DBUG_PRINT("info",("spider idx=%d", idx));
DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu",
spider->hs_pushed_ret_fields_num));
DBUG_PRINT("info",("spider hs_r_ret_fields_num[%d]=%lu",
link_idx, spider->hs_r_ret_fields_num[link_idx]));
DBUG_PRINT("info",("spider hs_r_ret_fields[%d]=%p",
link_idx, spider->hs_r_ret_fields[link_idx]));
#ifndef DBUG_OFF
if (
spider->hs_pushed_ret_fields_num < MAX_FIELDS &&
spider->hs_r_ret_fields[link_idx] &&
spider->hs_pushed_ret_fields_num ==
spider->hs_r_ret_fields_num[link_idx]
) {
int roop_count;
for (roop_count = 0; roop_count < (int) spider->hs_pushed_ret_fields_num;
++roop_count)
{
DBUG_PRINT("info",("spider hs_pushed_ret_fields[%d]=%u",
roop_count, spider->hs_pushed_ret_fields[roop_count]));
DBUG_PRINT("info",("spider hs_r_ret_fields[%d][%d]=%u",
link_idx, roop_count,
spider->hs_r_ret_fields[link_idx][roop_count]));
}
}
#endif
if (
spider->r_handler_index[link_idx] == idx
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
&& (
(
spider->hs_pushed_ret_fields_num == MAX_FIELDS &&
spider->hs_r_ret_fields_num[link_idx] == MAX_FIELDS
) ||
(
spider->hs_pushed_ret_fields_num < MAX_FIELDS &&
spider->hs_r_ret_fields[link_idx] &&
spider->hs_pushed_ret_fields_num ==
spider->hs_r_ret_fields_num[link_idx] &&
!memcmp(spider->hs_pushed_ret_fields,
spider->hs_r_ret_fields[link_idx],
sizeof(uint32) * spider->hs_pushed_ret_fields_num)
)
)
#endif
) {
SPIDER_CONN *conn = spider->hs_r_conns[link_idx];
DBUG_PRINT("info",("spider conn=%p", conn));
DBUG_PRINT("info",("spider conn->conn_id=%llu", conn->conn_id));
DBUG_PRINT("info",("spider conn->connection_id=%llu",
conn->connection_id));
DBUG_PRINT("info",("spider conn->server_lost=%s",
conn->server_lost ? "TRUE" : "FALSE"));
DBUG_PRINT("info",("spider conn->hs_pre_age=%llu", conn->hs_pre_age));
DBUG_PRINT("info",("spider hs_w_conn_ages[%d]=%llu",
link_idx, spider->hs_w_conn_ages[link_idx]));
if (
!conn->server_lost &&
conn->hs_pre_age == spider->hs_r_conn_ages[link_idx]
) {
DBUG_PRINT("info",("spider hs_r same idx"));
DBUG_RETURN(FALSE);
}
}
} else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_WRITE)
{
DBUG_PRINT("info",("spider w_handler_index[%d]=%d",
link_idx, spider->w_handler_index[link_idx]));
DBUG_PRINT("info",("spider idx=%d", idx));
DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu",
spider->hs_pushed_ret_fields_num));
DBUG_PRINT("info",("spider hs_w_ret_fields_num[%d]=%lu",
link_idx, spider->hs_w_ret_fields_num[link_idx]));
DBUG_PRINT("info",("spider hs_w_ret_fields[%d]=%p",
link_idx, spider->hs_w_ret_fields[link_idx]));
#ifndef DBUG_OFF
if (
spider->hs_pushed_ret_fields_num < MAX_FIELDS &&
spider->hs_w_ret_fields[link_idx] &&
spider->hs_pushed_ret_fields_num ==
spider->hs_w_ret_fields_num[link_idx]
) {
int roop_count;
for (roop_count = 0; roop_count < (int) spider->hs_pushed_ret_fields_num;
++roop_count)
{
DBUG_PRINT("info",("spider hs_pushed_ret_fields[%d]=%u",
roop_count, spider->hs_pushed_ret_fields[roop_count]));
DBUG_PRINT("info",("spider hs_w_ret_fields[%d][%d]=%u",
link_idx, roop_count,
spider->hs_w_ret_fields[link_idx][roop_count]));
}
}
#endif
if (
spider->w_handler_index[link_idx] == idx
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
&& (
(
spider->hs_pushed_ret_fields_num == MAX_FIELDS &&
spider->hs_w_ret_fields_num[link_idx] == MAX_FIELDS
) ||
(
spider->hs_pushed_ret_fields_num < MAX_FIELDS &&
spider->hs_w_ret_fields[link_idx] &&
spider->hs_pushed_ret_fields_num ==
spider->hs_w_ret_fields_num[link_idx] &&
!memcmp(spider->hs_pushed_ret_fields,
spider->hs_w_ret_fields[link_idx],
sizeof(uint32) * spider->hs_pushed_ret_fields_num)
)
)
#endif
) {
SPIDER_CONN *conn = spider->hs_w_conns[link_idx];
DBUG_PRINT("info",("spider conn=%p", conn));
DBUG_PRINT("info",("spider conn->conn_id=%llu", conn->conn_id));
DBUG_PRINT("info",("spider conn->connection_id=%llu",
conn->connection_id));
DBUG_PRINT("info",("spider conn->server_lost=%s",
conn->server_lost ? "TRUE" : "FALSE"));
DBUG_PRINT("info",("spider conn->hs_pre_age=%llu", conn->hs_pre_age));
DBUG_PRINT("info",("spider hs_w_conn_ages[%d]=%llu",
link_idx, spider->hs_w_conn_ages[link_idx]));
if (
!conn->server_lost &&
conn->hs_pre_age == spider->hs_w_conn_ages[link_idx]
) {
DBUG_PRINT("info",("spider hs_w same idx"));
DBUG_RETURN(FALSE);
}
}
}
#endif
}
DBUG_RETURN(TRUE);
}

File diff suppressed because it is too large Load diff

View file

@ -1217,11 +1217,6 @@ int spider_db_close_handler(
uint tgt_conn_kind
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
void spider_db_hs_request_buf_reset(
SPIDER_CONN *conn
);
#endif
bool spider_db_conn_is_network_error(
int error_num

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -15,9 +15,6 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#include "hs_compat.h"
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#include "hstcpcli.hpp"
#endif
#define SPIDER_DBTON_SIZE 15
@ -91,26 +88,6 @@ typedef st_spider_result SPIDER_RESULT;
#define SPIDER_SQL_TABLE_NAME_STR "`table_name`"
#define SPIDER_SQL_TABLE_NAME_LEN sizeof(SPIDER_SQL_TABLE_NAME_STR) - 1
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#define SPIDER_SQL_HS_EQUAL_STR "="
#define SPIDER_SQL_HS_EQUAL_LEN (sizeof(SPIDER_SQL_HS_EQUAL_STR) - 1)
#define SPIDER_SQL_HS_GT_STR ">"
#define SPIDER_SQL_HS_GT_LEN (sizeof(SPIDER_SQL_HS_GT_STR) - 1)
#define SPIDER_SQL_HS_GTEQUAL_STR ">="
#define SPIDER_SQL_HS_GTEQUAL_LEN (sizeof(SPIDER_SQL_HS_GTEQUAL_STR) - 1)
#define SPIDER_SQL_HS_LT_STR "<"
#define SPIDER_SQL_HS_LT_LEN (sizeof(SPIDER_SQL_HS_LT_STR) - 1)
#define SPIDER_SQL_HS_INSERT_STR "+"
#define SPIDER_SQL_HS_INSERT_LEN (sizeof(SPIDER_SQL_HS_INSERT_STR) - 1)
#define SPIDER_SQL_HS_UPDATE_STR "U"
#define SPIDER_SQL_HS_UPDATE_LEN (sizeof(SPIDER_SQL_HS_UPDATE_STR) - 1)
#define SPIDER_SQL_HS_DELETE_STR "D"
#define SPIDER_SQL_HS_DELETE_LEN (sizeof(SPIDER_SQL_HS_DELETE_STR) - 1)
#define SPIDER_SQL_HS_INCREMENT_STR "+"
#define SPIDER_SQL_HS_INCREMENT_LEN (sizeof(SPIDER_SQL_HS_INCREMENT_STR) - 1)
#define SPIDER_SQL_HS_DECREMENT_STR "-"
#define SPIDER_SQL_HS_DECREMENT_LEN (sizeof(SPIDER_SQL_HS_DECREMENT_STR) - 1)
#endif
#define SPIDER_SQL_HS_LTEQUAL_STR "<="
#define SPIDER_SQL_HS_LTEQUAL_LEN (sizeof(SPIDER_SQL_HS_LTEQUAL_STR) - 1)
@ -202,16 +179,9 @@ typedef st_spider_result SPIDER_RESULT;
#define SPIDER_SQL_LOP_CHK_PRM_PRF_LEN (sizeof(SPIDER_SQL_LOP_CHK_PRM_PRF_STR) - 1)
#define SPIDER_CONN_KIND_MYSQL (1 << 0)
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#define SPIDER_CONN_KIND_HS_READ (1 << 2)
#define SPIDER_CONN_KIND_HS_WRITE (1 << 3)
#endif
#define SPIDER_SQL_KIND_SQL (1 << 0)
#define SPIDER_SQL_KIND_HANDLER (1 << 1)
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#define SPIDER_SQL_KIND_HS (1 << 2)
#endif
#define SPIDER_SQL_TYPE_SELECT_SQL (1 << 0)
#define SPIDER_SQL_TYPE_INSERT_SQL (1 << 1)
@ -222,11 +192,6 @@ typedef st_spider_result SPIDER_RESULT;
#define SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL (1 << 6)
#define SPIDER_SQL_TYPE_OTHER_SQL (1 << 7)
#define SPIDER_SQL_TYPE_HANDLER (1 << 8)
#define SPIDER_SQL_TYPE_SELECT_HS (1 << 9)
#define SPIDER_SQL_TYPE_INSERT_HS (1 << 10)
#define SPIDER_SQL_TYPE_UPDATE_HS (1 << 11)
#define SPIDER_SQL_TYPE_DELETE_HS (1 << 12)
#define SPIDER_SQL_TYPE_OTHER_HS (1 << 13)
enum spider_bulk_upd_start {
SPD_BU_NOT_START,
@ -684,70 +649,6 @@ public:
);
};
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#define SPIDER_HS_UINT32_INFO dena::uint32_info
#define SPIDER_HS_STRING_REF dena::string_ref
#ifndef HANDLERSOCKET_MYSQL_UTIL
#define SPIDER_HS_VECTOR std::vector
class spider_db_hs_string_ref_buffer
{
SPIDER_HS_VECTOR<SPIDER_HS_STRING_REF> hs_conds;
public:
spider_db_hs_string_ref_buffer();
~spider_db_hs_string_ref_buffer();
int init();
void clear();
int push_back(
SPIDER_HS_STRING_REF &cond
);
SPIDER_HS_STRING_REF *ptr();
uint size();
};
#else
class spider_db_hs_string_ref_buffer
{
bool hs_da_init;
DYNAMIC_ARRAY hs_conds;
uint hs_conds_id;
const char *hs_conds_func_name;
const char *hs_conds_file_name;
ulong hs_conds_line_no;
public:
spider_db_hs_string_ref_buffer();
~spider_db_hs_string_ref_buffer();
int init();
void clear();
int push_back(
SPIDER_HS_STRING_REF &cond
);
SPIDER_HS_STRING_REF *ptr();
uint size();
};
#endif
class spider_db_hs_str_buffer
{
bool hs_da_init;
DYNAMIC_ARRAY hs_conds;
uint hs_conds_id;
const char *hs_conds_func_name;
const char *hs_conds_file_name;
ulong hs_conds_line_no;
public:
spider_db_hs_str_buffer();
~spider_db_hs_str_buffer();
int init();
void clear();
spider_string *add(
uint *strs_pos,
const char *str,
uint str_len
);
};
#define SPIDER_DB_HS_STRING_REF_BUFFER spider_db_hs_string_ref_buffer
#define SPIDER_DB_HS_STR_BUFFER spider_db_hs_str_buffer
#endif
struct st_spider_db_request_key
{
@ -1153,54 +1054,6 @@ public:
SPIDER_DB_RESULT **res1,
SPIDER_DB_RESULT **res2
) = 0;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
virtual int append_sql(
char *sql,
ulong sql_length,
st_spider_db_request_key *request_key
) = 0;
virtual int append_open_handler(
uint handler_id,
const char *db_name,
const char *table_name,
const char *index_name,
const char *sql,
st_spider_db_request_key *request_key
) = 0;
virtual int append_select(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
) = 0;
virtual int append_insert(
uint handler_id,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
st_spider_db_request_key *request_key
) = 0;
virtual int append_update(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
int limit,
int skip,
bool increment,
bool decrement,
st_spider_db_request_key *request_key
) = 0;
virtual int append_delete(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
) = 0;
virtual void reset_request_queue() = 0;
#endif
virtual size_t escape_string(
char *to,
const char *from,
@ -1334,11 +1187,6 @@ public:
virtual int append_insert_part() = 0;
virtual int append_update_part() = 0;
virtual int append_delete_part() = 0;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
virtual int append_increment_update_set_part() = 0;
#endif
#endif
virtual int append_update_set_part() = 0;
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
virtual int append_direct_update_set_part() = 0;
@ -1577,23 +1425,6 @@ public:
virtual int reset_sql(
ulong sql_type
) = 0;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
virtual int reset_keys(
ulong sql_type
) = 0;
virtual int reset_upds(
ulong sql_type
) = 0;
virtual int reset_strs(
ulong sql_type
) = 0;
virtual int reset_strs_pos(
ulong sql_type
) = 0;
virtual int push_back_upds(
SPIDER_HS_STRING_REF &info
) = 0;
#endif
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
virtual int set_sql_for_exec(
ulong sql_type,
@ -1956,18 +1787,7 @@ typedef struct st_spider_result_list
SPIDER_RESULT *current;
KEY *key_info;
int key_order;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
ulonglong hs_upd_rows;
SPIDER_DB_RESULT *hs_result;
SPIDER_DB_RESULT_BUFFER *hs_result_buf;
bool hs_has_result;
SPIDER_DB_CONN *hs_conn;
#endif
#ifdef HA_CAN_BULK_ACCESS
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uchar *hs_r_bulk_open_index;
uchar *hs_w_bulk_open_index;
#endif
#endif
spider_string *sqls;
int ha_read_kind;

View file

@ -3549,96 +3549,6 @@ int spider_db_mbase::select_binlog_gtid_pos(
DBUG_RETURN(0);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int spider_db_mbase::append_sql(
char *sql,
ulong sql_length,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_mbase::append_sql");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_mbase::append_open_handler(
uint handler_id,
const char *db_name,
const char *table_name,
const char *index_name,
const char *sql,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_mbase::append_open_handler");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_mbase::append_select(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_mbase::append_select");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_mbase::append_insert(
uint handler_id,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_mbase::append_insert");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_mbase::append_update(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
int limit,
int skip,
bool increment,
bool decrement,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_mbase::append_update");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_mbase::append_delete(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_mbase::append_delete");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
void spider_db_mbase::reset_request_queue()
{
DBUG_ENTER("spider_db_mbase::reset_request_queue");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_VOID_RETURN;
}
#endif
size_t spider_db_mbase::escape_string(
char *to,
@ -8511,9 +8421,6 @@ int spider_mbase_handler::init()
mysql_share->db_table_str_hash_value[roop_count];
#endif
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
hs_upds.init();
#endif
DBUG_RETURN(0);
}
@ -9424,66 +9331,6 @@ int spider_mbase_handler::append_delete(
DBUG_RETURN(0);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
int spider_mbase_handler::append_increment_update_set_part()
{
int error_num;
DBUG_ENTER("spider_mbase_handler::append_increment_update_set_part");
DBUG_PRINT("info",("spider this=%p", this));
error_num = append_increment_update_set(&update_sql);
DBUG_RETURN(error_num);
}
int spider_mbase_handler::append_increment_update_set(
spider_string *str
) {
uint field_name_length;
uint roop_count;
Field *field;
DBUG_ENTER("spider_mbase_handler::append_increment_update_set");
if (str->reserve(SPIDER_SQL_SET_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN);
const SPIDER_HS_STRING_REF *value = hs_upds.ptr();
for (roop_count = 0; roop_count < hs_upds.size();
roop_count++)
{
if (
value[roop_count].size() == 1 &&
*(value[roop_count].begin()) == '0'
)
continue;
Field *top_table_field =
spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]);
if (!(field = spider->field_exchange(top_table_field)))
continue;
field_name_length =
mysql_share->column_name_str[field->field_index].length();
if (str->reserve(field_name_length * 2 + /* SPIDER_SQL_NAME_QUOTE_LEN */
4 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_HS_INCREMENT_LEN +
SPIDER_SQL_COMMA_LEN + value[roop_count].size()))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
mysql_share->append_column_name(str, field->field_index);
str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN);
mysql_share->append_column_name(str, field->field_index);
if (spider->hs_increment)
str->q_append(SPIDER_SQL_HS_INCREMENT_STR,
SPIDER_SQL_HS_INCREMENT_LEN);
else
str->q_append(SPIDER_SQL_HS_DECREMENT_STR,
SPIDER_SQL_HS_DECREMENT_LEN);
str->q_append(value[roop_count].begin(), value[roop_count].size());
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
}
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
DBUG_RETURN(0);
}
#endif
#endif
int spider_mbase_handler::append_update_set_part()
{
@ -9564,13 +9411,6 @@ int spider_mbase_handler::append_direct_update_set_part()
int spider_mbase_handler::append_direct_update_set(
spider_string *str
) {
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint field_name_length;
SPIDER_SHARE *share = spider->share;
#ifndef DBUG_OFF
TABLE *table = spider->get_table();
#endif
#endif
DBUG_ENTER("spider_mbase_handler::append_direct_update_set");
if (
spider->direct_update_kinds == SPIDER_SQL_KIND_SQL &&
@ -9586,61 +9426,7 @@ int spider_mbase_handler::append_direct_update_set(
if (
(spider->direct_update_kinds & SPIDER_SQL_KIND_SQL)
) {
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
size_t roop_count;
Field *field;
if (str->reserve(SPIDER_SQL_SET_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN);
for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num;
roop_count++)
{
Field *top_table_field =
spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]);
if (!(field = spider->field_exchange(top_table_field)))
continue;
field_name_length =
mysql_share->column_name_str[field->field_index].length();
if (top_table_field->is_null())
{
if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */
2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN +
SPIDER_SQL_COMMA_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
mysql_share->append_column_name(str, field->field_index);
str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN);
str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN);
} else {
if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */
2 + SPIDER_SQL_EQUAL_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
mysql_share->append_column_name(str, field->field_index);
str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN);
#ifndef DBUG_OFF
my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table,
table->read_set);
#endif
if (
spider_db_mbase_utility->
append_column_value(spider, str, top_table_field, NULL,
share->access_charset) ||
str->reserve(SPIDER_SQL_COMMA_LEN)
) {
#ifndef DBUG_OFF
dbug_tmp_restore_column_map(table->read_set, tmp_map);
#endif
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
#ifndef DBUG_OFF
dbug_tmp_restore_column_map(table->read_set, tmp_map);
#endif
}
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
}
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
#else
DBUG_ASSERT(0);
#endif
}
DBUG_RETURN(0);
}
@ -12695,23 +12481,14 @@ int spider_mbase_handler::append_from(
DBUG_RETURN(0);
}
int spider_mbase_handler::append_flush_tables_part(
ulong sql_type,
int link_idx,
bool lock
) {
int spider_mbase_handler::append_flush_tables_part(int link_idx, bool lock)
{
int error_num;
spider_string *str;
DBUG_ENTER("spider_mbase_handler::append_flush_tables_part");
DBUG_PRINT("info",("spider this=%p", this));
switch (sql_type)
{
case SPIDER_SQL_TYPE_OTHER_SQL:
str = &spider->result_list.sqls[link_idx];
break;
default:
DBUG_RETURN(0);
}
str= &spider->result_list.sqls[link_idx];
error_num = append_flush_tables(str, link_idx, lock);
DBUG_RETURN(error_num);
}
@ -12739,22 +12516,14 @@ int spider_mbase_handler::append_flush_tables(
DBUG_RETURN(0);
}
int spider_mbase_handler::append_optimize_table_part(
ulong sql_type,
int link_idx
) {
int spider_mbase_handler::append_optimize_table_part(int link_idx)
{
int error_num;
spider_string *str;
DBUG_ENTER("spider_mbase_handler::append_optimize_table_part");
DBUG_PRINT("info",("spider this=%p", this));
switch (sql_type)
{
case SPIDER_SQL_TYPE_OTHER_SQL:
str = &spider->result_list.sqls[link_idx];
break;
default:
DBUG_RETURN(0);
}
str= &spider->result_list.sqls[link_idx];
error_num = append_optimize_table(str, link_idx);
DBUG_RETURN(error_num);
}
@ -12785,22 +12554,14 @@ int spider_mbase_handler::append_optimize_table(
DBUG_RETURN(0);
}
int spider_mbase_handler::append_analyze_table_part(
ulong sql_type,
int link_idx
) {
int spider_mbase_handler::append_analyze_table_part(int link_idx)
{
int error_num;
spider_string *str;
DBUG_ENTER("spider_mbase_handler::append_analyze_table_part");
DBUG_PRINT("info",("spider this=%p", this));
switch (sql_type)
{
case SPIDER_SQL_TYPE_OTHER_SQL:
str = &spider->result_list.sqls[link_idx];
break;
default:
DBUG_RETURN(0);
}
str= &spider->result_list.sqls[link_idx];
error_num = append_analyze_table(str, link_idx);
DBUG_RETURN(error_num);
}
@ -12831,23 +12592,15 @@ int spider_mbase_handler::append_analyze_table(
DBUG_RETURN(0);
}
int spider_mbase_handler::append_repair_table_part(
ulong sql_type,
int link_idx,
HA_CHECK_OPT* check_opt
) {
int spider_mbase_handler::append_repair_table_part(int link_idx,
HA_CHECK_OPT *check_opt)
{
int error_num;
spider_string *str;
DBUG_ENTER("spider_mbase_handler::append_repair_table_part");
DBUG_PRINT("info",("spider this=%p", this));
switch (sql_type)
{
case SPIDER_SQL_TYPE_OTHER_SQL:
str = &spider->result_list.sqls[link_idx];
break;
default:
DBUG_RETURN(0);
}
str= &spider->result_list.sqls[link_idx];
error_num = append_repair_table(str, link_idx, check_opt);
DBUG_RETURN(error_num);
}
@ -12897,23 +12650,15 @@ int spider_mbase_handler::append_repair_table(
DBUG_RETURN(0);
}
int spider_mbase_handler::append_check_table_part(
ulong sql_type,
int link_idx,
HA_CHECK_OPT* check_opt
) {
int spider_mbase_handler::append_check_table_part(int link_idx,
HA_CHECK_OPT *check_opt)
{
int error_num;
spider_string *str;
DBUG_ENTER("spider_mbase_handler::append_check_table_part");
DBUG_PRINT("info",("spider this=%p", this));
switch (sql_type)
{
case SPIDER_SQL_TYPE_OTHER_SQL:
str = &spider->result_list.sqls[link_idx];
break;
default:
DBUG_RETURN(0);
}
str= &spider->result_list.sqls[link_idx];
error_num = append_check_table(str, link_idx, check_opt);
DBUG_RETURN(error_num);
}
@ -12962,22 +12707,14 @@ int spider_mbase_handler::append_check_table(
DBUG_RETURN(0);
}
int spider_mbase_handler::append_enable_keys_part(
ulong sql_type,
int link_idx
) {
int spider_mbase_handler::append_enable_keys_part(int link_idx)
{
int error_num;
spider_string *str;
DBUG_ENTER("spider_mbase_handler::append_enable_keys_part");
DBUG_PRINT("info",("spider this=%p", this));
switch (sql_type)
{
case SPIDER_SQL_TYPE_OTHER_SQL:
str = &spider->result_list.sqls[link_idx];
break;
default:
DBUG_RETURN(0);
}
str= &spider->result_list.sqls[link_idx];
error_num = append_enable_keys(str, link_idx);
DBUG_RETURN(error_num);
}
@ -13003,22 +12740,14 @@ int spider_mbase_handler::append_enable_keys(
DBUG_RETURN(0);
}
int spider_mbase_handler::append_disable_keys_part(
ulong sql_type,
int link_idx
) {
int spider_mbase_handler::append_disable_keys_part(int link_idx)
{
int error_num;
spider_string *str;
DBUG_ENTER("spider_mbase_handler::append_disable_keys_part");
DBUG_PRINT("info",("spider this=%p", this));
switch (sql_type)
{
case SPIDER_SQL_TYPE_OTHER_SQL:
str = &spider->result_list.sqls[link_idx];
break;
default:
DBUG_RETURN(0);
}
str= &spider->result_list.sqls[link_idx];
error_num = append_disable_keys(str, link_idx);
DBUG_RETURN(error_num);
}
@ -13623,53 +13352,6 @@ int spider_mbase_handler::reset_sql(
DBUG_RETURN(0);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int spider_mbase_handler::reset_keys(
ulong sql_type
) {
DBUG_ENTER("spider_mbase_handler::reset_keys");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_mbase_handler::reset_upds(
ulong sql_type
) {
DBUG_ENTER("spider_mbase_handler::reset_upds");
DBUG_PRINT("info",("spider this=%p", this));
hs_upds.clear();
DBUG_RETURN(0);
}
int spider_mbase_handler::reset_strs(
ulong sql_type
) {
DBUG_ENTER("spider_mbase_handler::reset_strs");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_mbase_handler::reset_strs_pos(
ulong sql_type
) {
DBUG_ENTER("spider_mbase_handler::reset_strs_pos");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_mbase_handler::push_back_upds(
SPIDER_HS_STRING_REF &info
) {
int error_num;
DBUG_ENTER("spider_mbase_handler::push_back_upds");
DBUG_PRINT("info",("spider this=%p", this));
error_num = hs_upds.push_back(info);
DBUG_RETURN(error_num);
}
#endif
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
int spider_mbase_handler::set_sql_for_exec(
@ -15141,8 +14823,7 @@ int spider_mbase_handler::disable_keys(
DBUG_ENTER("spider_mbase_handler::disable_keys");
DBUG_PRINT("info",("spider this=%p", this));
str->length(0);
if ((error_num = append_disable_keys_part(SPIDER_SQL_TYPE_OTHER_HS,
link_idx)))
if ((error_num= append_disable_keys_part(link_idx)))
{
DBUG_RETURN(error_num);
}
@ -15200,8 +14881,7 @@ int spider_mbase_handler::enable_keys(
DBUG_ENTER("spider_mbase_handler::enable_keys");
DBUG_PRINT("info",("spider this=%p", this));
str->length(0);
if ((error_num = append_enable_keys_part(SPIDER_SQL_TYPE_OTHER_HS,
link_idx)))
if ((error_num= append_enable_keys_part(link_idx)))
{
DBUG_RETURN(error_num);
}
@ -15260,8 +14940,7 @@ int spider_mbase_handler::check_table(
DBUG_ENTER("spider_mbase_handler::check_table");
DBUG_PRINT("info",("spider this=%p", this));
str->length(0);
if ((error_num = append_check_table_part(SPIDER_SQL_TYPE_OTHER_HS,
link_idx, check_opt)))
if ((error_num= append_check_table_part(link_idx, check_opt)))
{
DBUG_RETURN(error_num);
}
@ -15320,8 +14999,7 @@ int spider_mbase_handler::repair_table(
DBUG_ENTER("spider_mbase_handler::repair_table");
DBUG_PRINT("info",("spider this=%p", this));
str->length(0);
if ((error_num = append_repair_table_part(SPIDER_SQL_TYPE_OTHER_HS,
link_idx, check_opt)))
if ((error_num= append_repair_table_part(link_idx, check_opt)))
{
DBUG_RETURN(error_num);
}
@ -15379,8 +15057,7 @@ int spider_mbase_handler::analyze_table(
DBUG_ENTER("spider_mbase_handler::analyze_table");
DBUG_PRINT("info",("spider this=%p", this));
str->length(0);
if ((error_num = append_analyze_table_part(SPIDER_SQL_TYPE_OTHER_HS,
link_idx)))
if ((error_num= append_analyze_table_part(link_idx)))
{
DBUG_RETURN(error_num);
}
@ -15438,8 +15115,7 @@ int spider_mbase_handler::optimize_table(
DBUG_ENTER("spider_mbase_handler::optimize_table");
DBUG_PRINT("info",("spider this=%p", this));
str->length(0);
if ((error_num = append_optimize_table_part(SPIDER_SQL_TYPE_OTHER_HS,
link_idx)))
if ((error_num= append_optimize_table_part(link_idx)))
{
DBUG_RETURN(error_num);
}
@ -15498,8 +15174,7 @@ int spider_mbase_handler::flush_tables(
DBUG_ENTER("spider_mbase_handler::flush_tables");
DBUG_PRINT("info",("spider this=%p", this));
str->length(0);
if ((error_num = append_flush_tables_part(SPIDER_SQL_TYPE_OTHER_HS,
link_idx, lock)))
if ((error_num= append_flush_tables_part(link_idx, lock)))
{
DBUG_RETURN(error_num);
}

View file

@ -566,54 +566,6 @@ public:
uint binlog_pos_length,
SPIDER_DB_RESULT **res
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int append_sql(
char *sql,
ulong sql_length,
st_spider_db_request_key *request_key
);
int append_open_handler(
uint handler_id,
const char *db_name,
const char *table_name,
const char *index_name,
const char *sql,
st_spider_db_request_key *request_key
);
int append_select(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
);
int append_insert(
uint handler_id,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
st_spider_db_request_key *request_key
);
int append_update(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
int limit,
int skip,
bool increment,
bool decrement,
st_spider_db_request_key *request_key
);
int append_delete(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
);
void reset_request_queue();
#endif
size_t escape_string(
char *to,
const char *from,
@ -804,9 +756,6 @@ protected:
spider_string *exec_ha_sql;
bool reading_from_bulk_tmp_table;
bool filled_up;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
SPIDER_DB_HS_STRING_REF_BUFFER hs_upds;
#endif
SPIDER_INT_HLD *union_table_name_pos_first;
SPIDER_INT_HLD *union_table_name_pos_current;
public:
@ -913,14 +862,6 @@ public:
int append_delete(
spider_string *str
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
int append_increment_update_set_part();
int append_increment_update_set(
spider_string *str
);
#endif
#endif
int append_update_set_part();
int append_update_set(
spider_string *str
@ -1313,64 +1254,40 @@ public:
ulong sql_type,
int link_idx
);
int append_flush_tables_part(
ulong sql_type,
int link_idx,
bool lock
);
int append_flush_tables_part(int link_idx, bool lock);
int append_flush_tables(
spider_string *str,
int link_idx,
bool lock
);
int append_optimize_table_part(
ulong sql_type,
int link_idx
);
int append_optimize_table_part(int link_idx);
int append_optimize_table(
spider_string *str,
int link_idx
);
int append_analyze_table_part(
ulong sql_type,
int link_idx
);
int append_analyze_table_part(int link_idx);
int append_analyze_table(
spider_string *str,
int link_idx
);
int append_repair_table_part(
ulong sql_type,
int link_idx,
HA_CHECK_OPT* check_opt
);
int append_repair_table_part(int link_idx, HA_CHECK_OPT *check_opt);
int append_repair_table(
spider_string *str,
int link_idx,
HA_CHECK_OPT* check_opt
);
int append_check_table_part(
ulong sql_type,
int link_idx,
HA_CHECK_OPT* check_opt
);
int append_check_table_part(int link_idx, HA_CHECK_OPT *check_opt);
int append_check_table(
spider_string *str,
int link_idx,
HA_CHECK_OPT* check_opt
);
int append_enable_keys_part(
ulong sql_type,
int link_idx
);
int append_enable_keys_part(int link_idx);
int append_enable_keys(
spider_string *str,
int link_idx
);
int append_disable_keys_part(
ulong sql_type,
int link_idx
);
int append_disable_keys_part(int link_idx);
int append_disable_keys(
spider_string *str,
int link_idx
@ -1451,23 +1368,6 @@ public:
int reset_sql(
ulong sql_type
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int reset_keys(
ulong sql_type
);
int reset_upds(
ulong sql_type
);
int reset_strs(
ulong sql_type
);
int reset_strs_pos(
ulong sql_type
);
int push_back_upds(
SPIDER_HS_STRING_REF &info
);
#endif
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
int set_sql_for_exec(
ulong sql_type,

View file

@ -2249,96 +2249,6 @@ int spider_db_oracle::show_master_status(
DBUG_RETURN(0);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int spider_db_oracle::append_sql(
char *sql,
ulong sql_length,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_oracle::append_sql");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_oracle::append_open_handler(
uint handler_id,
const char *db_name,
const char *table_name,
const char *index_name,
const char *sql,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_oracle::append_sql");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_oracle::append_select(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_oracle::append_select");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_oracle::append_insert(
uint handler_id,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_oracle::append_insert");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_oracle::append_update(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
int limit,
int skip,
bool increment,
bool decrement,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_oracle::append_update");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_oracle::append_delete(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
) {
DBUG_ENTER("spider_db_oracle::append_delete");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
void spider_db_oracle::reset_request_queue()
{
DBUG_ENTER("spider_db_oracle::reset_request_queue");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_VOID_RETURN;
}
#endif
size_t spider_db_oracle::escape_string(
char *to,
@ -5621,9 +5531,6 @@ int spider_oracle_handler::init()
oracle_share->db_table_str_hash_value[roop_count];
#endif
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
hs_upds.init();
#endif
DBUG_RETURN(0);
}
@ -6392,77 +6299,6 @@ int spider_oracle_handler::append_delete(
DBUG_RETURN(0);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
int spider_oracle_handler::append_increment_update_set_part()
{
int error_num;
DBUG_ENTER("spider_oracle_handler::append_increment_update_set_part");
DBUG_PRINT("info",("spider this=%p", this));
error_num = append_increment_update_set(&update_sql);
DBUG_RETURN(error_num);
}
int spider_oracle_handler::append_increment_update_set(
spider_string *str
) {
uint field_name_length;
uint roop_count;
Field *field;
DBUG_ENTER("spider_oracle_handler::append_increment_update_set");
if (str->reserve(SPIDER_SQL_SET_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN);
const SPIDER_HS_STRING_REF *value = hs_upds.ptr();
for (roop_count = 0; roop_count < hs_upds.size();
roop_count++)
{
DBUG_PRINT("info",("spider value_size[%u]=%zu", roop_count,
value[roop_count].size()));
#ifndef DBUG_OFF
char print_buf[MAX_FIELD_WIDTH];
if (value[roop_count].size() < MAX_FIELD_WIDTH)
{
memcpy(print_buf, value[roop_count].begin(), value[roop_count].size());
print_buf[value[roop_count].size()] = '\0';
DBUG_PRINT("info",("spider value[%u]=%s", roop_count, print_buf));
}
#endif
if (
value[roop_count].size() == 1 &&
*(value[roop_count].begin()) == '0'
)
continue;
Field *top_table_field =
spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]);
if (!(field = spider->field_exchange(top_table_field)))
continue;
field_name_length =
oracle_share->column_name_str[field->field_index].length();
if (str->reserve(field_name_length * 2 + /* SPIDER_SQL_NAME_QUOTE_LEN */
4 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_HS_INCREMENT_LEN +
SPIDER_SQL_COMMA_LEN + value[roop_count].size()))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
oracle_share->append_column_name(str, field->field_index);
str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN);
oracle_share->append_column_name(str, field->field_index);
if (spider->hs_increment)
str->q_append(SPIDER_SQL_HS_INCREMENT_STR,
SPIDER_SQL_HS_INCREMENT_LEN);
else
str->q_append(SPIDER_SQL_HS_DECREMENT_STR,
SPIDER_SQL_HS_DECREMENT_LEN);
str->q_append(value[roop_count].begin(), value[roop_count].size());
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
}
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
DBUG_RETURN(0);
}
#endif
#endif
int spider_oracle_handler::append_update_set_part()
{
@ -6548,13 +6384,6 @@ int spider_oracle_handler::append_direct_update_set_part()
int spider_oracle_handler::append_direct_update_set(
spider_string *str
) {
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint field_name_length;
SPIDER_SHARE *share = spider->share;
#ifndef DBUG_OFF
TABLE *table = spider->get_table();
#endif
#endif
DBUG_ENTER("spider_oracle_handler::append_direct_update_set");
if (
spider->direct_update_kinds == SPIDER_SQL_KIND_SQL &&
@ -6569,61 +6398,7 @@ int spider_oracle_handler::append_direct_update_set(
if (
(spider->direct_update_kinds & SPIDER_SQL_KIND_SQL)
) {
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
size_t roop_count;
Field *field;
if (str->reserve(SPIDER_SQL_SET_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN);
for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num;
roop_count++)
{
Field *top_table_field =
spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]);
if (!(field = spider->field_exchange(top_table_field)))
continue;
field_name_length =
oracle_share->column_name_str[field->field_index].length();
if (top_table_field->is_null())
{
if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */
2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN +
SPIDER_SQL_COMMA_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
oracle_share->append_column_name(str, field->field_index);
str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN);
str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN);
} else {
if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */
2 + SPIDER_SQL_EQUAL_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
oracle_share->append_column_name(str, field->field_index);
str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN);
#ifndef DBUG_OFF
my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table,
table->read_set);
#endif
if (
spider_db_oracle_utility.
append_column_value(spider, str, top_table_field, NULL,
share->access_charset) ||
str->reserve(SPIDER_SQL_COMMA_LEN)
) {
#ifndef DBUG_OFF
dbug_tmp_restore_column_map(table->read_set, tmp_map);
#endif
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
#ifndef DBUG_OFF
dbug_tmp_restore_column_map(table->read_set, tmp_map);
#endif
}
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
}
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
#else
DBUG_ASSERT(0);
#endif
}
DBUG_RETURN(0);
}
@ -10755,53 +10530,6 @@ int spider_oracle_handler::reset_sql(
DBUG_RETURN(0);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int spider_oracle_handler::reset_keys(
ulong sql_type
) {
DBUG_ENTER("spider_oracle_handler::reset_keys");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_oracle_handler::reset_upds(
ulong sql_type
) {
DBUG_ENTER("spider_oracle_handler::reset_upds");
DBUG_PRINT("info",("spider this=%p", this));
hs_upds.clear();
DBUG_RETURN(0);
}
int spider_oracle_handler::reset_strs(
ulong sql_type
) {
DBUG_ENTER("spider_oracle_handler::reset_strs");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_oracle_handler::reset_strs_pos(
ulong sql_type
) {
DBUG_ENTER("spider_oracle_handler::reset_strs_pos");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_oracle_handler::push_back_upds(
SPIDER_HS_STRING_REF &info
) {
int error_num;
DBUG_ENTER("spider_oracle_handler::push_back_upds");
DBUG_PRINT("info",("spider this=%p", this));
error_num = hs_upds.push_back(info);
DBUG_RETURN(error_num);
}
#endif
bool spider_oracle_handler::need_lock_before_set_sql_for_exec(
ulong sql_type

View file

@ -473,54 +473,6 @@ public:
SPIDER_DB_RESULT **res1,
SPIDER_DB_RESULT **res2
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int append_sql(
char *sql,
ulong sql_length,
st_spider_db_request_key *request_key
);
int append_open_handler(
uint handler_id,
const char *db_name,
const char *table_name,
const char *index_name,
const char *sql,
st_spider_db_request_key *request_key
);
int append_select(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
);
int append_insert(
uint handler_id,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
st_spider_db_request_key *request_key
);
int append_update(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
SPIDER_DB_HS_STRING_REF_BUFFER *upds,
int limit,
int skip,
bool increment,
bool decrement,
st_spider_db_request_key *request_key
);
int append_delete(
uint handler_id,
spider_string *sql,
SPIDER_DB_HS_STRING_REF_BUFFER *keys,
int limit,
int skip,
st_spider_db_request_key *request_key
);
void reset_request_queue();
#endif
size_t escape_string(
char *to,
const char *from,
@ -685,9 +637,6 @@ private:
bool filled_up;
bool select_rownum_appended;
bool update_rownum_appended;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
SPIDER_DB_HS_STRING_REF_BUFFER hs_upds;
#endif
SPIDER_INT_HLD *union_table_name_pos_first;
SPIDER_INT_HLD *union_table_name_pos_current;
public:
@ -792,14 +741,6 @@ public:
int append_delete(
spider_string *str
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
int append_increment_update_set_part();
int append_increment_update_set(
spider_string *str
);
#endif
#endif
int append_update_set_part();
int append_update_set(
spider_string *str
@ -1330,23 +1271,6 @@ public:
int reset_sql(
ulong sql_type
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int reset_keys(
ulong sql_type
);
int reset_upds(
ulong sql_type
);
int reset_strs(
ulong sql_type
);
int reset_strs_pos(
ulong sql_type
);
int push_back_upds(
SPIDER_HS_STRING_REF &info
);
#endif
bool need_lock_before_set_sql_for_exec(
ulong sql_type
);

View file

@ -197,54 +197,23 @@ int spider_udf_direct_sql_create_conn_key(
spider_dbton[roop_count2].wrapper &&
!strcmp(direct_sql->tgt_wrapper, spider_dbton[roop_count2].wrapper)
) {
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
if (spider_dbton[roop_count2].db_access_type ==
SPIDER_DB_ACCESS_TYPE_SQL)
{
direct_sql->dbton_id = roop_count2;
break;
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
if (spider_dbton[roop_count2].db_access_type ==
SPIDER_DB_ACCESS_TYPE_NOSQL)
{
direct_sql->dbton_id = roop_count2;
break;
}
}
#endif
}
}
if (direct_sql->dbton_id == SPIDER_DBTON_SIZE)
{
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
my_printf_error(
ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM,
ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR,
MYF(0), direct_sql->tgt_wrapper);
DBUG_RETURN(ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
my_printf_error(
ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM,
ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR,
MYF(0), direct_sql->tgt_wrapper);
DBUG_RETURN(ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM);
}
#endif
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
tables_on_different_db_are_joinable =
spider_dbton[direct_sql->dbton_id].db_util->
tables_on_different_db_are_joinable();
@ -269,16 +238,6 @@ int spider_udf_direct_sql_create_conn_key(
+ direct_sql->tgt_dsn_length + 1
+ direct_sql->tgt_filedsn_length + 1
+ direct_sql->tgt_driver_length;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
direct_sql->conn_key_length
= 1
+ direct_sql->tgt_wrapper_length + 1
+ direct_sql->tgt_host_length + 1
+ 5 + 1
+ direct_sql->tgt_socket_length;
}
#endif
if (!(direct_sql->conn_key = (char *)
spider_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_KEY_1, direct_sql->conn_key_length + 1,
MYF(MY_WME | MY_ZEROFILL)))
@ -307,20 +266,16 @@ int spider_udf_direct_sql_create_conn_key(
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_socket);
} else
tmp_name++;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
if (!tables_on_different_db_are_joinable)
{
#endif
if (!tables_on_different_db_are_joinable)
if (direct_sql->tgt_default_db_name)
{
if (direct_sql->tgt_default_db_name)
{
DBUG_PRINT("info",("spider tgt_default_db_name=%s",
direct_sql->tgt_default_db_name));
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_db_name);
} else
tmp_name++;
}
DBUG_PRINT("info",("spider tgt_default_db_name=%s",
direct_sql->tgt_default_db_name));
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_db_name);
} else
tmp_name++;
}
if (direct_sql->tgt_username)
{
DBUG_PRINT("info",("spider tgt_username=%s", direct_sql->tgt_username));
@ -402,9 +357,6 @@ int spider_udf_direct_sql_create_conn_key(
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_driver);
} else
tmp_name++;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
}
#endif
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
direct_sql->conn_key_hash_value = my_calc_hash(&spider_open_connections,
(uchar*) direct_sql->conn_key, direct_sql->conn_key_length);
@ -450,10 +402,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
UTC = my_tz_find(current_thd, &tz_00_name);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
tables_on_different_db_are_joinable =
spider_dbton[direct_sql->dbton_id].db_util->
tables_on_different_db_are_joinable();
@ -490,24 +438,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
goto error_alloc_conn;
}
conn->default_database.init_calc_mem(SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_2);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
if (!(conn = (SPIDER_CONN *)
spider_bulk_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_3, MYF(MY_WME | MY_ZEROFILL),
&conn, (uint) (sizeof(*conn)),
&tmp_name, (uint) (direct_sql->conn_key_length + 1),
&tmp_host, (uint) (direct_sql->tgt_host_length + 1),
&tmp_socket, (uint) (direct_sql->tgt_socket_length + 1),
&tmp_wrapper, (uint) (direct_sql->tgt_wrapper_length + 1),
&need_mon, (uint) (sizeof(int)),
NullS))
) {
*error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_conn;
}
conn->default_database.init_calc_mem(SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_4);
}
#endif
conn->conn_key_length = direct_sql->conn_key_length;
conn->conn_key = tmp_name;
@ -519,10 +449,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
conn->tgt_host_length = direct_sql->tgt_host_length;
conn->tgt_host = tmp_host;
memcpy(conn->tgt_host, direct_sql->tgt_host, direct_sql->tgt_host_length);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
conn->tgt_port = direct_sql->tgt_port;
spider_maybe_memcpy_string(
&conn->tgt_socket, direct_sql->tgt_socket, tmp_socket,
@ -568,18 +494,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
&conn->tgt_driver, direct_sql->tgt_driver, tmp_driver,
&conn->tgt_driver_length, direct_sql->tgt_driver_length);
conn->tgt_ssl_vsc = direct_sql->tgt_ssl_vsc;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
conn->hs_port = direct_sql->tgt_port;
if (direct_sql->tgt_socket)
{
conn->hs_sock_length = direct_sql->tgt_socket_length;
conn->hs_sock = tmp_socket;
memcpy(conn->hs_sock, direct_sql->tgt_socket,
direct_sql->tgt_socket_length);
}
}
#endif
conn->dbton_id = direct_sql->dbton_id;
conn->conn_need_mon = need_mon;
conn->need_mon = need_mon;
@ -598,19 +512,7 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
conn->semi_trx_isolation = -2;
conn->semi_trx_isolation_chk = FALSE;
conn->semi_trx_chk = FALSE;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
conn->conn_kind = SPIDER_CONN_KIND_MYSQL;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (direct_sql->access_mode == 1)
{
conn->conn_kind = SPIDER_CONN_KIND_HS_READ;
} else {
conn->conn_kind = SPIDER_CONN_KIND_HS_WRITE;
}
#endif
if (mysql_mutex_init(spd_key_mutex_mta_conn, &conn->mta_conn_mutex,
MY_MUTEX_INIT_FAST))
@ -697,82 +599,26 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn(
) {
SPIDER_CONN *conn = NULL;
DBUG_ENTER("spider_udf_direct_sql_get_conn");
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
DBUG_PRINT("info",("spider direct_sql->access_mode=%d",
direct_sql->access_mode));
#endif
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
if (
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(direct_sql->access_mode == 0 &&
#endif
!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
&trx->trx_conn_hash, direct_sql->conn_key_hash_value,
(uchar*) direct_sql->conn_key, direct_sql->conn_key_length))
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
) ||
(direct_sql->access_mode == 1 &&
!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
&trx->trx_direct_hs_r_conn_hash, direct_sql->conn_key_hash_value,
(uchar*) direct_sql->conn_key, direct_sql->conn_key_length))
) ||
(direct_sql->access_mode == 2 &&
!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
&trx->trx_direct_hs_w_conn_hash, direct_sql->conn_key_hash_value,
(uchar*) direct_sql->conn_key, direct_sql->conn_key_length))
)
#endif
)
#else
if (
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(direct_sql->access_mode == 0 &&
#endif
!(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash,
(uchar*) direct_sql->conn_key, direct_sql->conn_key_length))
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
) ||
(direct_sql->access_mode == 1 &&
!(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_direct_hs_r_conn_hash,
(uchar*) direct_sql->conn_key, direct_sql->conn_key_length))
) ||
(direct_sql->access_mode == 2 &&
!(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_direct_hs_w_conn_hash,
(uchar*) direct_sql->conn_key, direct_sql->conn_key_length))
)
#endif
)
#endif
{
if (
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(direct_sql->access_mode == 0 &&
#endif
(
(spider_param_conn_recycle_mode(trx->thd) & 1) ||
spider_param_conn_recycle_strict(trx->thd)
)
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
) ||
(direct_sql->access_mode == 1 &&
(
(spider_param_hs_r_conn_recycle_mode(trx->thd) & 1) ||
spider_param_hs_r_conn_recycle_strict(trx->thd)
)
) ||
(direct_sql->access_mode == 2 &&
(
(spider_param_hs_w_conn_recycle_mode(trx->thd) & 1) ||
spider_param_hs_w_conn_recycle_strict(trx->thd)
)
)
#endif
) {
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
pthread_mutex_lock(&spider_conn_mutex);
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value(
@ -798,9 +644,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn(
pthread_mutex_unlock(&spider_conn_mutex);
DBUG_PRINT("info",("spider get global conn"));
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
}
#endif
} else {
DBUG_PRINT("info",("spider create new conn"));
/* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */
@ -810,10 +653,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn(
conn->thd = trx->thd;
conn->priority = direct_sql->priority;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
uint old_elements = trx->trx_conn_hash.array.max_element;
#ifdef HASH_UPDATE_WITH_HASH_VALUE
if (my_hash_insert_with_hash_value(&trx->trx_conn_hash,
@ -833,50 +672,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn(
(trx->trx_conn_hash.array.max_element - old_elements) *
trx->trx_conn_hash.array.size_of_element);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (direct_sql->access_mode == 1)
{
uint old_elements = trx->trx_direct_hs_r_conn_hash.array.max_element;
#ifdef HASH_UPDATE_WITH_HASH_VALUE
if (my_hash_insert_with_hash_value(&trx->trx_direct_hs_r_conn_hash,
direct_sql->conn_key_hash_value, (uchar*) conn))
#else
if (my_hash_insert(&trx->trx_direct_hs_r_conn_hash, (uchar*) conn))
#endif
{
spider_free_conn(conn);
*error_num = HA_ERR_OUT_OF_MEM;
goto error;
}
if (trx->trx_direct_hs_r_conn_hash.array.max_element > old_elements)
{
spider_alloc_calc_mem(spider_current_trx,
trx->trx_direct_hs_r_conn_hash,
(trx->trx_direct_hs_r_conn_hash.array.max_element - old_elements) *
trx->trx_direct_hs_r_conn_hash.array.size_of_element);
}
} else {
uint old_elements = trx->trx_direct_hs_w_conn_hash.array.max_element;
#ifdef HASH_UPDATE_WITH_HASH_VALUE
if (my_hash_insert_with_hash_value(&trx->trx_direct_hs_w_conn_hash,
direct_sql->conn_key_hash_value, (uchar*) conn))
#else
if (my_hash_insert(&trx->trx_direct_hs_w_conn_hash, (uchar*) conn))
#endif
{
spider_free_conn(conn);
*error_num = HA_ERR_OUT_OF_MEM;
goto error;
}
if (trx->trx_direct_hs_w_conn_hash.array.max_element > old_elements)
{
spider_alloc_calc_mem(spider_current_trx,
trx->trx_direct_hs_w_conn_hash,
(trx->trx_direct_hs_w_conn_hash.array.max_element - old_elements) *
trx->trx_direct_hs_w_conn_hash.array.size_of_element);
}
}
#endif
}
if (conn->queued_connect)
@ -1112,9 +907,6 @@ static void spider_minus_1(SPIDER_DIRECT_SQL *direct_sql)
direct_sql->net_write_timeout = -1;
direct_sql->bulk_insert_rows = -1;
direct_sql->connection_channel = -1;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
direct_sql->access_mode = -1;
#endif
direct_sql->use_real_table = -1;
direct_sql->error_rw_mode = -1;
for (int i = 0; i < direct_sql->table_count; i++)
@ -1165,9 +957,6 @@ int spider_udf_parse_direct_sql_param(
error_num= parse.fail(true);
goto error;
case 3:
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
SPIDER_PARAM_INT_WITH_MAX("acm", access_mode, 0, 2);
#endif
SPIDER_PARAM_LONGLONG("bir", bulk_insert_rows, 0);
SPIDER_PARAM_INT_WITH_MAX("cch", connection_channel, 0, 63);
SPIDER_PARAM_INT("cto", connect_timeout, 0);
@ -1224,9 +1013,6 @@ int spider_udf_parse_direct_sql_param(
error_num= parse.fail(true);
goto error;
case 11:
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
SPIDER_PARAM_INT_WITH_MAX("access_mode", access_mode, 0, 2);
#endif
error_num= parse.fail(true);
goto error;
case 12:
@ -1305,9 +1091,6 @@ int spider_udf_set_direct_sql_param_default(
}
if (
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
direct_sql->access_mode == 0 &&
#endif
!direct_sql->tgt_socket &&
(!direct_sql->tgt_host || !strcmp(direct_sql->tgt_host, my_localhost))
) {
@ -1474,20 +1257,9 @@ int spider_udf_set_direct_sql_param_default(
}
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == -1)
direct_sql->access_mode = 0;
#endif
if (port_has_default_value)
{
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 1)
direct_sql->tgt_port = 9998;
else if (direct_sql->access_mode == 2)
direct_sql->tgt_port = 9999;
else
#endif
direct_sql->tgt_port = MYSQL_PORT;
}
else if (direct_sql->tgt_port < 0)
@ -1730,15 +1502,8 @@ long long spider_direct_sql_body(
goto error;
}
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (trx->trx_start && direct_sql->access_mode != 1)
{
#endif
trx->updated_in_this_trx = TRUE;
DBUG_PRINT("info",("spider trx->updated_in_this_trx=TRUE"));
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
}
#endif
use_real_table = spider_param_udf_ds_use_real_table(thd,
direct_sql->use_real_table);
for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++)

View file

@ -619,11 +619,6 @@ typedef struct st_spider_conn
#endif
int link_idx;
spider_db_conn *db_conn;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
query_id_t hsc_query_id;
ulonglong hs_pre_age;
ulonglong hs_age;
#endif
uint opened_handlers;
ulonglong conn_id;
ulonglong connection_id;
@ -697,10 +692,6 @@ typedef struct st_spider_conn
char *tgt_driver;
long tgt_port;
long tgt_ssl_vsc;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
char *hs_sock;
long hs_port;
#endif
uint tgt_host_length;
uint tgt_username_length;
@ -718,9 +709,6 @@ typedef struct st_spider_conn
uint tgt_dsn_length;
uint tgt_filedsn_length;
uint tgt_driver_length;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint hs_sock_length;
#endif
uint dbton_id;
#ifndef WITHOUT_SPIDER_BG_SEARCH
@ -910,11 +898,6 @@ typedef struct st_spider_wide_handler
uchar *rnd_write_bitmap;
SPIDER_CONDITION *condition;
void *owner;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
uint32 *hs_pushed_ret_fields;
#endif
#endif
#ifdef WITH_PARTITION_STORAGE_ENGINE
SPIDER_PARTITION_HANDLER *partition_handler;
#endif
@ -925,11 +908,6 @@ typedef struct st_spider_wide_handler
TABLE_SHARE *top_share;
enum thr_lock_type lock_type;
uchar lock_table_type;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
uint32 hs_pushed_strref_num;
#endif
#endif
int lock_mode;
int external_lock_type;
int cond_check_error;
@ -942,13 +920,6 @@ typedef struct st_spider_wide_handler
#endif
#ifdef HA_CAN_BULK_ACCESS
ulonglong external_lock_cnt;
#endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
size_t hs_pushed_ret_fields_num;
size_t hs_pushed_ret_fields_size;
size_t hs_pushed_lcl_fields_num;
#endif
#endif
bool between_flg;
bool idx_bitmap_is_set;
@ -966,12 +937,6 @@ typedef struct st_spider_wide_handler
bool write_can_replace;
bool insert_with_update;
bool cond_check;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool hs_increment;
bool hs_decrement;
#endif
#endif
bool semi_table_lock;
} SPIDER_WIDE_HANDLER;
@ -1007,30 +972,6 @@ typedef struct st_spider_transaction
const char *trx_another_conn_hash_func_name;
const char *trx_another_conn_hash_file_name;
ulong trx_another_conn_hash_line_no;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
HASH trx_hs_r_conn_hash;
uint trx_hs_r_conn_hash_id;
const char *trx_hs_r_conn_hash_func_name;
const char *trx_hs_r_conn_hash_file_name;
ulong trx_hs_r_conn_hash_line_no;
HASH trx_hs_w_conn_hash;
uint trx_hs_w_conn_hash_id;
const char *trx_hs_w_conn_hash_func_name;
const char *trx_hs_w_conn_hash_file_name;
ulong trx_hs_w_conn_hash_line_no;
#endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
HASH trx_direct_hs_r_conn_hash;
uint trx_direct_hs_r_conn_hash_id;
const char *trx_direct_hs_r_conn_hash_func_name;
const char *trx_direct_hs_r_conn_hash_file_name;
ulong trx_direct_hs_r_conn_hash_line_no;
HASH trx_direct_hs_w_conn_hash;
uint trx_direct_hs_w_conn_hash_id;
const char *trx_direct_hs_w_conn_hash_func_name;
const char *trx_direct_hs_w_conn_hash_file_name;
ulong trx_direct_hs_w_conn_hash_line_no;
#endif
HASH trx_alter_table_hash;
uint trx_alter_table_hash_id;
const char *trx_alter_table_hash_func_name;
@ -1046,10 +987,6 @@ typedef struct st_spider_transaction
SPIDER_CONN *join_trx_top;
ulonglong spider_thread_id;
ulonglong trx_conn_adjustment;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
ulonglong trx_hs_r_conn_adjustment;
ulonglong trx_hs_w_conn_adjustment;
#endif
uint locked_connections;
ulonglong direct_update_count;
@ -1057,9 +994,6 @@ typedef struct st_spider_transaction
ulonglong direct_order_limit_count;
ulonglong direct_aggregate_count;
ulonglong parallel_search_count;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
ulonglong hs_result_free_count;
#endif
#ifdef HA_CAN_BULK_ACCESS
SPIDER_CONN *bulk_access_conn_first;
@ -1275,9 +1209,6 @@ typedef struct st_spider_share
int error_read_mode;
int error_write_mode;
int active_link_count;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
longlong hs_result_free_size;
#endif
#ifdef HA_CAN_BULK_ACCESS
int bulk_access_free;
#endif
@ -1296,10 +1227,6 @@ typedef struct st_spider_share
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
my_hash_value_type *conn_keys_hash_value;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
my_hash_value_type *hs_read_conn_keys_hash_value;
my_hash_value_type *hs_write_conn_keys_hash_value;
#endif
#endif
char **server_names;
char **tgt_table_names;
@ -1323,12 +1250,6 @@ typedef struct st_spider_share
char **tgt_pk_names;
char **tgt_sequence_names;
char **conn_keys;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
char **hs_read_socks;
char **hs_write_socks;
char **hs_read_conn_keys;
char **hs_write_conn_keys;
#endif
long *tgt_ports;
long *tgt_ssl_vscs;
long *link_statuses;
@ -1344,13 +1265,6 @@ typedef struct st_spider_share
#endif
longlong *monitoring_limit;
longlong *monitoring_sid;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
long *use_hs_reads;
long *use_hs_writes;
long *hs_read_ports;
long *hs_write_ports;
long *hs_write_to_reads;
#endif
long *use_handlers;
long *connect_timeouts;
long *net_read_timeouts;
@ -1381,17 +1295,8 @@ typedef struct st_spider_share
uint *tgt_pk_names_lengths;
uint *tgt_sequence_names_lengths;
uint *conn_keys_lengths;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint *hs_read_socks_lengths;
uint *hs_write_socks_lengths;
uint *hs_read_conn_keys_lengths;
uint *hs_write_conn_keys_lengths;
#endif
/* The index in `spider_dbton' of each data node link. */
uint *sql_dbton_ids;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint *hs_dbton_ids;
#endif
uint server_names_charlen;
uint tgt_table_names_charlen;
@ -1415,12 +1320,6 @@ typedef struct st_spider_share
uint tgt_pk_names_charlen;
uint tgt_sequence_names_charlen;
uint conn_keys_charlen;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint hs_read_socks_charlen;
uint hs_write_socks_charlen;
uint hs_read_conn_keys_charlen;
uint hs_write_conn_keys_charlen;
#endif
uint server_names_length;
uint tgt_table_names_length;
@ -1444,12 +1343,6 @@ typedef struct st_spider_share
uint tgt_pk_names_length;
uint tgt_sequence_names_length;
uint conn_keys_length;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint hs_read_socks_length;
uint hs_write_socks_length;
uint hs_read_conn_keys_length;
uint hs_write_conn_keys_length;
#endif
uint tgt_ports_length;
uint tgt_ssl_vscs_length;
uint link_statuses_length;
@ -1465,13 +1358,6 @@ typedef struct st_spider_share
#endif
uint monitoring_limit_length;
uint monitoring_sid_length;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint use_hs_reads_length;
uint use_hs_writes_length;
uint hs_read_ports_length;
uint hs_write_ports_length;
uint hs_write_to_reads_length;
#endif
uint use_handlers_length;
uint connect_timeouts_length;
uint net_read_timeouts_length;
@ -1495,14 +1381,6 @@ typedef struct st_spider_share
uint use_sql_dbton_ids[SPIDER_DBTON_SIZE];
/* Inverse map of `use_sql_dbton_ids'. */
uint sql_dbton_id_to_seq[SPIDER_DBTON_SIZE];
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint use_hs_dbton_count;
/* Actual size is `use_hs_dbton_count'. Values are the indices of
item in `spider_dbton'. */
uint use_hs_dbton_ids[SPIDER_DBTON_SIZE];
/* Inverse map of `use_hs_dbton_ids'. */
uint hs_dbton_id_to_seq[SPIDER_DBTON_SIZE];
#endif
SPIDER_ALTER_TABLE alter_table;
SPIDER_WIDE_SHARE *wide_share;
@ -1558,9 +1436,6 @@ typedef struct st_spider_direct_sql
int net_write_timeout;
longlong bulk_insert_rows;
int connection_channel;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int access_mode;
#endif
int use_real_table;
int error_rw_mode;

View file

@ -168,16 +168,6 @@ static int spider_parallel_search(THD *thd, SHOW_VAR *var, void *buff,
DBUG_RETURN(0);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
static int spider_hs_result_free(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
DBUG_ENTER("spider_hs_result_free");
spider_trx_status_var(thd, var, buff, &SPIDER_TRX::hs_result_free_count);
DBUG_RETURN(0);
}
#endif
struct st_mysql_show_var spider_status_variables[] =
{
{"Spider_mon_table_cache_version",
@ -207,13 +197,6 @@ struct st_mysql_show_var spider_status_variables[] =
(char *) &spider_direct_aggregate, SHOW_FUNC},
{"Spider_parallel_search",
(char *) &spider_parallel_search, SHOW_FUNC},
#endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC
{"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_SIMPLE_FUNC},
#else
{"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_FUNC},
#endif
#endif
{NullS, NullS, SHOW_LONG}
};
@ -575,25 +558,6 @@ static MYSQL_THDVAR_INT(
SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, reset_sql_alloc)
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
/*
-1 :fallback to default
0-:result free size for handlersocket
*/
static MYSQL_THDVAR_LONGLONG(
hs_result_free_size, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Result free size for handlersocket", /* comment */
NULL, /* check */
NULL, /* update */
1048576, /* def */
-1, /* min */
9223372036854775807LL, /* max */
0 /* blk */
);
SPIDER_THDVAR_OVERRIDE_VALUE_FUN(longlong, hs_result_free_size)
#endif
/*
-1 :fallback to default
@ -1529,25 +1493,6 @@ static MYSQL_THDVAR_INT(
SPIDER_THDVAR_VALUE_FUNC(double, ping_interval_at_trx_start)
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
/*
0 :always ping
1-:interval
*/
static MYSQL_THDVAR_INT(
hs_ping_interval, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Ping interval for handlersocket", /* comment */
NULL, /* check */
NULL, /* update */
30, /* def */
0, /* min */
2147483647, /* max */
0 /* blk */
);
SPIDER_THDVAR_VALUE_FUNC(double, hs_ping_interval)
#endif
/*
-1 :fallback to default
@ -1953,119 +1898,6 @@ static MYSQL_SYSVAR_LONGLONG(
SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(longlong, udf_ct_bulk_insert_rows)
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
/*
0: no recycle
1: recycle in instance
2: recycle in thread
*/
static MYSQL_THDVAR_UINT(
hs_r_conn_recycle_mode, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Handlersocket connection recycle mode", /* comment */
NULL, /* check */
NULL, /* update */
2, /* def */
0, /* min */
2, /* max */
0 /* blk */
);
SPIDER_THDVAR_VALUE_FUNC(uint, hs_r_conn_recycle_mode)
/*
0: weak
1: strict
*/
static MYSQL_THDVAR_UINT(
hs_r_conn_recycle_strict, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Strict handlersocket connection recycle", /* comment */
NULL, /* check */
NULL, /* update */
0, /* def */
0, /* min */
1, /* max */
0 /* blk */
);
SPIDER_THDVAR_VALUE_FUNC(uint, hs_r_conn_recycle_strict)
/*
0: no recycle
1: recycle in instance
2: recycle in thread
*/
static MYSQL_THDVAR_UINT(
hs_w_conn_recycle_mode, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Handlersocket connection recycle mode", /* comment */
NULL, /* check */
NULL, /* update */
2, /* def */
0, /* min */
2, /* max */
0 /* blk */
);
SPIDER_THDVAR_VALUE_FUNC(uint, hs_w_conn_recycle_mode)
/*
0: weak
1: strict
*/
static MYSQL_THDVAR_UINT(
hs_w_conn_recycle_strict, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Strict handlersocket connection recycle", /* comment */
NULL, /* check */
NULL, /* update */
0, /* def */
0, /* min */
1, /* max */
0 /* blk */
);
SPIDER_THDVAR_VALUE_FUNC(uint, hs_w_conn_recycle_strict)
/*
-1 :fallback to default
0 :not use
1 :use handlersocket
*/
static MYSQL_THDVAR_INT(
use_hs_read, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Use handlersocket for reading", /* comment */
NULL, /* check */
NULL, /* update */
0, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
SPIDER_THDVAR_OVERRIDE_VALUE_FUN(int, use_hs_read)
/*
-1 :fallback to default
0 :not use
1 :use handlersocket
*/
static MYSQL_THDVAR_INT(
use_hs_write, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Use handlersocket for writing", /* comment */
NULL, /* check */
NULL, /* update */
0, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
SPIDER_THDVAR_OVERRIDE_VALUE_FUN(int, use_hs_write)
#endif
/*
-1 :fallback to default
@ -2737,9 +2569,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(semi_split_read_limit),
MYSQL_SYSVAR(init_sql_alloc_size),
MYSQL_SYSVAR(reset_sql_alloc),
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
MYSQL_SYSVAR(hs_result_free_size),
#endif
MYSQL_SYSVAR(multi_split_read),
MYSQL_SYSVAR(max_order),
MYSQL_SYSVAR(semi_trx_isolation),
@ -2800,9 +2629,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(sts_bg_mode),
#endif
MYSQL_SYSVAR(ping_interval_at_trx_start),
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
MYSQL_SYSVAR(hs_ping_interval),
#endif
MYSQL_SYSVAR(auto_increment_mode),
MYSQL_SYSVAR(same_server_link),
MYSQL_SYSVAR(local_lock_table),
@ -2825,14 +2651,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(bka_mode),
MYSQL_SYSVAR(udf_ct_bulk_insert_interval),
MYSQL_SYSVAR(udf_ct_bulk_insert_rows),
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
MYSQL_SYSVAR(hs_r_conn_recycle_mode),
MYSQL_SYSVAR(hs_r_conn_recycle_strict),
MYSQL_SYSVAR(hs_w_conn_recycle_mode),
MYSQL_SYSVAR(hs_w_conn_recycle_strict),
MYSQL_SYSVAR(use_hs_read),
MYSQL_SYSVAR(use_hs_write),
#endif
MYSQL_SYSVAR(use_handler),
MYSQL_SYSVAR(error_read_mode),
MYSQL_SYSVAR(error_write_mode),

View file

@ -73,12 +73,6 @@ int spider_param_reset_sql_alloc(
THD *thd,
int reset_sql_alloc
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
longlong spider_param_hs_result_free_size(
THD *thd,
longlong hs_result_free_size
);
#endif
int spider_param_multi_split_read(
THD *thd,
int multi_split_read
@ -261,11 +255,6 @@ int spider_param_sts_bg_mode(
double spider_param_ping_interval_at_trx_start(
THD *thd
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
double spider_param_hs_ping_interval(
THD *thd
);
#endif
int spider_param_auto_increment_mode(
THD *thd,
int auto_increment_mode
@ -320,28 +309,6 @@ int spider_param_udf_ct_bulk_insert_interval(
longlong spider_param_udf_ct_bulk_insert_rows(
longlong udf_ct_bulk_insert_rows
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint spider_param_hs_r_conn_recycle_mode(
THD *thd
);
uint spider_param_hs_r_conn_recycle_strict(
THD *thd
);
uint spider_param_hs_w_conn_recycle_mode(
THD *thd
);
uint spider_param_hs_w_conn_recycle_strict(
THD *thd
);
int spider_param_use_hs_read(
THD *thd,
int use_hs_read
);
int spider_param_use_hs_write(
THD *thd,
int use_hs_write
);
#endif
int spider_param_use_handler(
THD *thd,
int use_handler

File diff suppressed because it is too large Load diff

View file

@ -372,14 +372,6 @@ bool spider_check_pk_update(
TABLE *table
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
bool spider_check_hs_pk_update(
ha_spider *spider,
key_range *key
);
#endif
#endif
void spider_set_tmp_share_pointer(
SPIDER_SHARE *tmp_share,

View file

@ -1130,30 +1130,6 @@ int spider_free_trx_alloc(
trx->trx_another_conn_hash.array.max_element *
trx->trx_another_conn_hash.array.size_of_element);
my_hash_free(&trx->trx_another_conn_hash);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
spider_free_mem_calc(spider_current_trx,
trx->trx_direct_hs_r_conn_hash_id,
trx->trx_direct_hs_r_conn_hash.array.max_element *
trx->trx_direct_hs_r_conn_hash.array.size_of_element);
my_hash_free(&trx->trx_direct_hs_r_conn_hash);
spider_free_mem_calc(spider_current_trx,
trx->trx_direct_hs_w_conn_hash_id,
trx->trx_direct_hs_w_conn_hash.array.max_element *
trx->trx_direct_hs_w_conn_hash.array.size_of_element);
my_hash_free(&trx->trx_direct_hs_w_conn_hash);
#endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
spider_free_mem_calc(spider_current_trx,
trx->trx_hs_r_conn_hash_id,
trx->trx_hs_r_conn_hash.array.max_element *
trx->trx_hs_r_conn_hash.array.size_of_element);
my_hash_free(&trx->trx_hs_r_conn_hash);
spider_free_mem_calc(spider_current_trx,
trx->trx_hs_w_conn_hash_id,
trx->trx_hs_w_conn_hash.array.max_element *
trx->trx_hs_w_conn_hash.array.size_of_element);
my_hash_free(&trx->trx_hs_w_conn_hash);
#endif
spider_free_mem_calc(spider_current_trx,
trx->trx_ha_hash_id,
trx->trx_ha_hash.array.max_element *
@ -1235,57 +1211,7 @@ SPIDER_TRX *spider_get_trx(
trx->trx_another_conn_hash.array.max_element *
trx->trx_another_conn_hash.array.size_of_element);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (
my_hash_init(&trx->trx_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0,
(my_hash_get_key) spider_conn_get_key, 0, 0)
)
goto error_hs_r_init_hash;
spider_alloc_calc_mem_init(trx->trx_hs_r_conn_hash, SPD_MID_GET_TRX_4);
spider_alloc_calc_mem(
thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL,
trx->trx_hs_r_conn_hash,
trx->trx_hs_r_conn_hash.array.max_element *
trx->trx_hs_r_conn_hash.array.size_of_element);
if (
my_hash_init(&trx->trx_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0,
(my_hash_get_key) spider_conn_get_key, 0, 0)
)
goto error_hs_w_init_hash;
spider_alloc_calc_mem_init(trx->trx_hs_w_conn_hash, SPD_MID_GET_TRX_5);
spider_alloc_calc_mem(
thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL,
trx->trx_hs_w_conn_hash,
trx->trx_hs_w_conn_hash.array.max_element *
trx->trx_hs_w_conn_hash.array.size_of_element);
#endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (
my_hash_init(&trx->trx_direct_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32,
0, 0, (my_hash_get_key) spider_conn_get_key, 0, 0)
)
goto error_direct_hs_r_init_hash;
spider_alloc_calc_mem_init(trx->trx_direct_hs_r_conn_hash, SPD_MID_GET_TRX_6);
spider_alloc_calc_mem(
thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL,
trx->trx_direct_hs_r_conn_hash,
trx->trx_direct_hs_r_conn_hash.array.max_element *
trx->trx_direct_hs_r_conn_hash.array.size_of_element);
if (
my_hash_init(&trx->trx_direct_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32,
0, 0, (my_hash_get_key) spider_conn_get_key, 0, 0)
)
goto error_direct_hs_w_init_hash;
spider_alloc_calc_mem_init(trx->trx_direct_hs_w_conn_hash, SPD_MID_GET_TRX_7);
spider_alloc_calc_mem(
thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL,
trx->trx_direct_hs_w_conn_hash,
trx->trx_direct_hs_w_conn_hash.array.max_element *
trx->trx_direct_hs_w_conn_hash.array.size_of_element);
#endif
if (
my_hash_init(PSI_INSTRUMENT_ME, &trx->trx_alter_table_hash,
@ -1326,10 +1252,6 @@ SPIDER_TRX *spider_get_trx(
++spider_thread_id;
pthread_mutex_unlock(&spider_thread_id_mutex);
trx->trx_conn_adjustment = 1;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
trx->trx_hs_r_conn_adjustment = 1;
trx->trx_hs_w_conn_adjustment = 1;
#endif
if (thd)
{
@ -1483,38 +1405,6 @@ error_init_trx_ha_hash:
trx->trx_alter_table_hash.array.size_of_element);
my_hash_free(&trx->trx_alter_table_hash);
error_init_alter_hash:
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
spider_free_mem_calc(
thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL,
trx->trx_direct_hs_w_conn_hash_id,
trx->trx_direct_hs_w_conn_hash.array.max_element *
trx->trx_direct_hs_w_conn_hash.array.size_of_element);
my_hash_free(&trx->trx_direct_hs_w_conn_hash);
error_direct_hs_w_init_hash:
spider_free_mem_calc(
thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL,
trx->trx_direct_hs_r_conn_hash_id,
trx->trx_direct_hs_r_conn_hash.array.max_element *
trx->trx_direct_hs_r_conn_hash.array.size_of_element);
my_hash_free(&trx->trx_direct_hs_r_conn_hash);
error_direct_hs_r_init_hash:
#endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
spider_free_mem_calc(
thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL,
trx->trx_hs_w_conn_hash_id,
trx->trx_hs_w_conn_hash.array.max_element *
trx->trx_hs_w_conn_hash.array.size_of_element);
my_hash_free(&trx->trx_hs_w_conn_hash);
error_hs_w_init_hash:
spider_free_mem_calc(
thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL,
trx->trx_hs_r_conn_hash_id,
trx->trx_hs_r_conn_hash.array.max_element *
trx->trx_hs_r_conn_hash.array.size_of_element);
my_hash_free(&trx->trx_hs_r_conn_hash);
error_hs_r_init_hash:
#endif
spider_free_mem_calc(
thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL,
trx->trx_another_conn_hash_id,
@ -3670,24 +3560,6 @@ int spider_check_trx_and_get_conn(
if (!trx_ha || trx_ha->wait_for_reusing)
spider_trx_set_link_idx_for_all(spider);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
if (use_conn_kind)
{
for (roop_count = 0; roop_count < (int) share->link_count; roop_count++)
{
if (
share->hs_dbton_ids[spider->conn_link_idx[roop_count]] ==
SPIDER_DBTON_SIZE
) {
/* can't use hs interface */
spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL;
spider_clear_bit(spider->do_hs_direct_update, roop_count);
}
}
}
#endif
#endif
if (semi_table_lock_conn)
first_byte = '0' +
@ -3704,14 +3576,6 @@ int spider_check_trx_and_get_conn(
trx_ha->wait_for_reusing ||
trx->spider_thread_id != spider->spider_thread_id ||
trx->trx_conn_adjustment != spider->trx_conn_adjustment ||
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(use_conn_kind &&
(
trx->trx_hs_r_conn_adjustment != spider->trx_hs_r_conn_adjustment ||
trx->trx_hs_w_conn_adjustment != spider->trx_hs_w_conn_adjustment
)
) ||
#endif
first_byte != *spider->conn_keys[0] ||
share->link_statuses[spider->conn_link_idx[spider->search_link_idx]] ==
SPIDER_LINK_STATUS_NG
@ -3721,13 +3585,6 @@ int spider_check_trx_and_get_conn(
"spider change thd" : "spider next trx"));
spider->wide_handler->trx = trx;
spider->trx_conn_adjustment = trx->trx_conn_adjustment;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (use_conn_kind)
{
spider->trx_hs_r_conn_adjustment = trx->trx_hs_r_conn_adjustment;
spider->trx_hs_w_conn_adjustment = trx->trx_hs_w_conn_adjustment;
}
#endif
if (
spider->spider_thread_id != trx->spider_thread_id ||
spider->search_link_query_id != thd->query_id
@ -3772,12 +3629,6 @@ int spider_check_trx_and_get_conn(
{
if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_MYSQL))
spider->conns[roop_count] = NULL;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_READ))
spider->hs_r_conns[roop_count] = NULL;
if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_WRITE))
spider->hs_w_conns[roop_count] = NULL;
#endif
}
bool search_link_idx_is_checked = FALSE;
for (
@ -3794,18 +3645,8 @@ int spider_check_trx_and_get_conn(
if (roop_count == spider->search_link_idx)
search_link_idx_is_checked = TRUE;
if (
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(
#endif
tgt_conn_kind == SPIDER_CONN_KIND_MYSQL &&
!spider->conns[roop_count]
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
) ||
(tgt_conn_kind == SPIDER_CONN_KIND_HS_READ &&
!spider->hs_r_conns[roop_count]) ||
(tgt_conn_kind == SPIDER_CONN_KIND_HS_WRITE &&
!spider->hs_w_conns[roop_count])
#endif
) {
*spider->conn_keys[roop_count] = first_byte;
if (
@ -3845,51 +3686,6 @@ int spider_check_trx_and_get_conn(
}
conn->error_mode &= spider->error_mode;
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
if (
spider->do_direct_update &&
spider_bit_is_set(spider->do_hs_direct_update, roop_count) &&
!spider->hs_w_conns[roop_count]
) {
if (
!(conn =
spider_get_conn(share, roop_count,
spider->conn_keys[roop_count], trx,
spider, FALSE, TRUE,
SPIDER_CONN_KIND_HS_WRITE,
&error_num))
) {
if (
share->monitoring_kind[roop_count] &&
spider->need_mons[roop_count]
) {
error_num = spider_ping_table_mon_from_table(
trx,
trx->thd,
share,
roop_count,
(uint32) share->monitoring_sid[roop_count],
share->table_name,
share->table_name_length,
spider->conn_link_idx[roop_count],
NULL,
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
share->monitoring_flag[roop_count],
TRUE
);
}
DBUG_PRINT("info",("spider get conn error"));
*spider->conn_keys[0] = first_byte_bak;
spider->spider_thread_id = 0;
DBUG_RETURN(error_num);
}
conn->error_mode &= spider->error_mode;
}
#endif
#endif
}
if (!search_link_idx_is_checked)
{
@ -3928,21 +3724,7 @@ int spider_check_trx_and_get_conn(
) {
if (roop_count == spider->search_link_idx)
search_link_idx_is_checked = TRUE;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (
!use_conn_kind ||
spider->conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL
) {
#endif
conn = spider->conns[roop_count];
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else if (spider->conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ)
{
conn = spider->hs_r_conns[roop_count];
} else {
conn = spider->hs_w_conns[roop_count];
}
#endif
conn = spider->conns[roop_count];
if (!conn)
{
@ -3982,53 +3764,6 @@ int spider_check_trx_and_get_conn(
}
}
conn->error_mode &= spider->error_mode;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
if (
spider->do_direct_update &&
spider_bit_is_set(spider->do_hs_direct_update, roop_count)
) {
conn = spider->hs_w_conns[roop_count];
if (!conn)
{
DBUG_PRINT("info",("spider get hs_w_conn %d", roop_count));
if (
!(conn =
spider_get_conn(share, roop_count,
spider->conn_keys[roop_count], trx,
spider, FALSE, TRUE,
SPIDER_CONN_KIND_HS_WRITE,
&error_num))
) {
if (
share->monitoring_kind[roop_count] &&
spider->need_mons[roop_count]
) {
error_num = spider_ping_table_mon_from_table(
trx,
trx->thd,
share,
roop_count,
(uint32) share->monitoring_sid[roop_count],
share->table_name,
share->table_name_length,
spider->conn_link_idx[roop_count],
NULL,
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
share->monitoring_flag[roop_count],
TRUE
);
}
DBUG_PRINT("info",("spider get conn error"));
DBUG_RETURN(error_num);
}
}
}
conn->error_mode &= spider->error_mode;
#endif
#endif
}
if (!search_link_idx_is_checked)
{
@ -4269,20 +4004,6 @@ void spider_trx_set_link_idx_for_all(
share->conn_keys[0]), char*);
DBUG_PRINT("info",("spider conn_keys[%d]=%s",
roop_count, spider->conn_keys[roop_count]));
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
spider->hs_r_conn_keys[roop_count] =
ADD_TO_PTR(spider->conn_keys_first_ptr,
PTR_BYTE_DIFF(share->hs_read_conn_keys[conn_link_idx[roop_count]],
share->conn_keys[0]), char*);
DBUG_PRINT("info",("spider hs_r_conn_keys[%d]=%s",
roop_count, spider->hs_r_conn_keys[roop_count]));
spider->hs_w_conn_keys[roop_count] =
ADD_TO_PTR(spider->conn_keys_first_ptr,
PTR_BYTE_DIFF(share->hs_write_conn_keys[conn_link_idx[roop_count]],
share->conn_keys[0]), char*);
DBUG_PRINT("info",("spider hs_w_conn_keys[%d]=%s",
roop_count, spider->hs_w_conn_keys[roop_count]));
#endif
}
DBUG_VOID_RETURN;
}