Commit 207594af authored by Kentoku SHIBA's avatar Kentoku SHIBA Committed by Monty

merge Spider 3.3.13

New features in 3.3.13 are:
- Join Push Down for 1 by 1 table and single partition.
parent e53ef202
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_HANDLERSOCKET")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_HANDLERSOCKET")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG)
IF(HAVE_WVLA)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-vla")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-vla")
ENDIF()
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
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
)
......@@ -21,11 +25,11 @@ IF(DEFINED ENV{ORACLE_HOME})
ENDIF()
IF(EXISTS ${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake)
SET(CMAKE_CXX_FLAGS_DEBUG
SET(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi")
SET(CMAKE_C_FLAGS_DEBUG
SET(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MAP /MAPINFO:EXPORTS")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MAP /MAPINFO:EXPORTS")
INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
INCLUDE_DIRECTORIES(
......@@ -53,3 +57,12 @@ IF(ORACLE_INCLUDE_DIR AND ORACLE_OCI_LIBRARY)
TARGET_LINK_LIBRARIES (spider ${ORACLE_OCI_LIBRARY})
ENDIF()
ENDIF()
IF(MSVC)
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_CUSTOM_COMMAND(TARGET spider
POST_BUILD
COMMAND if not exist ..\\..\\sql\\lib mkdir ..\\..\\sql\\lib\\plugin
COMMAND copy Debug\\ha_spider.dll ..\\..\\sql\\lib\\plugin\\ha_spider.dll)
ENDIF()
ENDIF()
This diff is collapsed.
/* Copyright (C) 2008-2015 Kentoku Shiba
/* Copyright (C) 2008-2017 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -11,14 +11,12 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef USE_PRAGMA_INTERFACE
#pragma interface
#endif
#include "spd_environ.h"
#define SPIDER_CONNECT_INFO_MAX_LEN 64
#define SPIDER_CONNECT_INFO_PATH_MAX_LEN FN_REFLEN
#define SPIDER_LONGLONG_LEN 20
......@@ -131,6 +129,14 @@ class ha_spider: public handler
bool da_status;
bool use_spatial_index;
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
uint idx_for_direct_join;
bool use_fields;
spider_fields *fields;
SPIDER_LINK_IDX_CHAIN *link_idx_chain;
SPIDER_LINK_IDX_CHAIN *result_link_idx_chain;
#endif
/* for mrr */
bool mrr_with_cnt;
uint multi_range_cnt;
......@@ -249,6 +255,11 @@ class ha_spider: public handler
/* for dbton */
spider_db_handler **dbton_handler;
/* for direct limit offset */
longlong direct_select_offset;
longlong direct_current_offset;
longlong direct_select_limit;
ha_spider();
ha_spider(
handlerton *hton,
......@@ -575,6 +586,7 @@ class ha_spider: public handler
const uchar *new_data
);
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
inline int direct_update_rows_init()
{
return direct_update_rows_init(2, NULL, 0, FALSE, NULL);
......@@ -586,7 +598,11 @@ class ha_spider: public handler
bool sorted,
const uchar *new_data
);
#else
int direct_update_rows_init();
#endif
#ifdef HA_CAN_BULK_ACCESS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
inline int pre_direct_update_rows_init()
{
return pre_direct_update_rows_init(2, NULL, 0, FALSE, NULL);
......@@ -598,13 +614,11 @@ class ha_spider: public handler
bool sorted,
uchar *new_data
);
#else
int pre_direct_update_rows_init();
#endif
inline int ha_direct_update_rows(KEY_MULTI_RANGE *ranges,
uint range_count, bool sorted,
uchar *new_data, ha_rows *update_rows)
{
return handler::ha_direct_update_rows(update_rows);
}
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
inline int direct_update_rows(ha_rows *update_rows)
{
return direct_update_rows(NULL, 0, FALSE, NULL, update_rows);
......@@ -616,7 +630,13 @@ class ha_spider: public handler
uchar *new_data,
ha_rows *update_rows
);
#else
int direct_update_rows(
ha_rows *update_rows
);
#endif
#ifdef HA_CAN_BULK_ACCESS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
inline int pre_direct_update_rows()
{
ha_rows update_rows;
......@@ -630,6 +650,9 @@ class ha_spider: public handler
uchar *new_data,
ha_rows *update_rows
);
#else
int pre_direct_update_rows();
#endif
#endif
#endif
bool start_bulk_delete();
......@@ -638,6 +661,7 @@ class ha_spider: public handler
const uchar *buf
);
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
inline int direct_delete_rows_init()
{
return direct_delete_rows_init(2, NULL, 0, FALSE);
......@@ -648,7 +672,11 @@ class ha_spider: public handler
uint range_count,
bool sorted
);
#else
int direct_delete_rows_init();
#endif
#ifdef HA_CAN_BULK_ACCESS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
inline int pre_direct_delete_rows_init()
{
return pre_direct_delete_rows_init(2, NULL, 0, FALSE);
......@@ -659,13 +687,11 @@ class ha_spider: public handler
uint range_count,
bool sorted
);
#else
int pre_direct_delete_rows_init();
#endif
inline int ha_direct_delete_rows(KEY_MULTI_RANGE *ranges,
uint range_count, bool sorted,
ha_rows *delete_rows)
{
return handler::ha_direct_delete_rows(delete_rows);
}
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
inline int direct_delete_rows(ha_rows *delete_rows)
{
return direct_delete_rows(NULL, 0, FALSE, delete_rows);
......@@ -676,7 +702,13 @@ class ha_spider: public handler
bool sorted,
ha_rows *delete_rows
);
#else
int direct_delete_rows(
ha_rows *delete_rows
);
#endif
#ifdef HA_CAN_BULK_ACCESS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
inline int pre_direct_delete_rows()
{
ha_rows delete_rows;
......@@ -689,6 +721,9 @@ class ha_spider: public handler
bool sorted,
ha_rows *delete_rows
);
#else
int pre_direct_delete_rows();
#endif
#endif
#endif
int delete_all_rows();
......@@ -798,7 +833,9 @@ class ha_spider: public handler
uint check_partitioned();
void check_direct_order_limit();
void check_distinct_key_query();
bool is_sole_projection_field( uint16 field_index );
bool is_sole_projection_field(
uint16 field_index
);
int check_ha_range_eof();
int drop_tmp_tables();
bool handler_opened(
......
......@@ -3,7 +3,7 @@
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
......@@ -31,11 +31,11 @@ extern "C" {
#if 1
#define DENA_ALLOCA_ALLOCATE(typ, len) \
(typ *) alloca((len) * sizeof(typ))
(typ *) (alloca((len) * sizeof(typ)))
#define DENA_ALLOCA_FREE(x)
#else
#define DENA_ALLOCA_ALLOCATE(typ, len) \
static_cast<typ *>(malloc((len) * sizeof(typ)))
(typ *) (malloc((len) * sizeof(typ)))
#define DENA_ALLOCA_FREE(x) free(x)
#endif
......
......@@ -3,7 +3,7 @@
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
......@@ -263,8 +263,8 @@ parse_args(int argc, char **argv, config& conf)
}
if (!(param = new conf_param()))
continue;
uint32 key_len = (uint32)(eq - arg);
uint32 val_len = (uint32)(strlen(eq + 1));
uint32 key_len = eq - arg;
uint32 val_len = strlen(eq + 1);
if (
param->key.reserve(key_len + 1) ||
param->val.reserve(val_len + 1)
......
......@@ -3,6 +3,7 @@
/*
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
......
......@@ -3,7 +3,7 @@
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
......
......@@ -3,7 +3,7 @@
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
......
......@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef HS_COMPAT_H
#define HS_COMPAT_H
......
......@@ -3,7 +3,7 @@
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
......@@ -497,7 +497,7 @@ hstcpcli::response_recv(size_t& num_flds_r)
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);
String e = String(err_begin, err_end - err_begin, &my_charset_bin);
if (!e.length()) {
e = String("unknown_error", &my_charset_bin);
}
......
......@@ -3,11 +3,12 @@
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include <my_global.h>
#include <my_config.h>
#ifndef __WIN__
#include <sys/types.h>
#include <sys/un.h>
......@@ -223,7 +224,7 @@ socket_set_options(auto_file& fd, const socket_args& args, String& err_r)
int
socket_open(auto_file& fd, const socket_args& args, String& err_r)
{
fd.reset((int)socket(args.family, args.socktype, args.protocol));
fd.reset(socket(args.family, args.socktype, args.protocol));
if (fd.get() < 0) {
return errno_string("socket", errno, err_r);
}
......@@ -253,7 +254,7 @@ socket_connect(auto_file& fd, const socket_args& args, String& err_r)
int
socket_bind(auto_file& fd, const socket_args& args, String& err_r)
{
fd.reset((int)socket(args.family, args.socktype, args.protocol));
fd.reset(socket(args.family, args.socktype, args.protocol));
if (fd.get() < 0) {
return errno_string("socket", errno, err_r);
}
......@@ -300,7 +301,7 @@ 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),
fd.reset(accept(listen_fd, reinterpret_cast<sockaddr *>(&addr_r),
&addrlen_r));
if (fd.get() < 0) {
return errno_string("accept", errno, err_r);
......
......@@ -3,7 +3,7 @@
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
......
......@@ -54,31 +54,31 @@ COUNT(*)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 1
Spider_direct_aggregate 0
SELECT MAX(a) FROM ta_l;
MAX(a)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 2
Spider_direct_aggregate 1
SELECT MIN(a) FROM ta_l;
MIN(a)
1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 3
Spider_direct_aggregate 2
SELECT MAX(a) FROM ta_l WHERE a < 5;
MAX(a)
4
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 4
Spider_direct_aggregate 3
SELECT MIN(a) FROM ta_l WHERE a > 1;
MIN(a)
2
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 5
Spider_direct_aggregate 4
deinit
connection master_1;
......
......@@ -6,9 +6,13 @@ DROP FUNCTION spider_flush_table_mon_cache;
UNINSTALL PLUGIN spider;
DROP TABLE IF EXISTS mysql.spider_xa;
DROP TABLE IF EXISTS mysql.spider_xa_member;
DROP TABLE IF EXISTS mysql.spider_xa_failed_log;
DROP TABLE IF EXISTS mysql.spider_tables;
DROP TABLE IF EXISTS mysql.spider_link_mon_servers;
DROP TABLE IF EXISTS mysql.spider_link_failed_log;
DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery;
DROP TABLE IF EXISTS mysql.spider_table_sts;
DROP TABLE IF EXISTS mysql.spider_table_crd;
DROP SERVER s_2_1;
DROP SERVER s_2_2;
DROP SERVER s_2_3;
......
......@@ -277,10 +277,35 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
default_group char(64) default null,
KEY idx1 (data, format_id, gtrid_length, host)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS mysql.spider_xa_failed_log;
CREATE TABLE mysql.spider_xa_failed_log(
format_id int not null default 0,
gtrid_length int not null default 0,
bqual_length int not null default 0,
data char(128) charset binary not null default '',
scheme char(64) not null default '',
host char(64) not null default '',
port char(5) not null default '',
socket text not null,
username char(64) not null default '',
password char(64) not null default '',
ssl_ca text,
ssl_capath text,
ssl_cert text,
ssl_cipher char(64) default null,
ssl_key text,
ssl_verify_server_cert tinyint not null default 0,
default_file text,
default_group char(64) default null,
thread_id int default null,
status char(8) not null default '',
failed_time timestamp not null default current_timestamp,
key idx1 (data, format_id, gtrid_length, host)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS mysql.spider_tables;
CREATE TABLE mysql.spider_tables(
db_name char(64) not null default '',
table_name char(64) not null default '',
table_name char(199) not null default '',
link_id int not null default 0,
priority bigint not null default 0,
server char(64) default null,
......@@ -296,18 +321,22 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
ssl_cipher char(64) default null,
ssl_key text default null,
ssl_verify_server_cert tinyint not null default 0,
monitoring_binlog_pos_at_failing tinyint not null default 0,
default_file text default null,
default_group char(64) default null,
tgt_db_name char(64) default null,
tgt_table_name char(64) default null,
link_status tinyint not null default 1,
block_status tinyint not null default 0,
static_link_id char(64) default null,
PRIMARY KEY (db_name, table_name, link_id),
KEY idx1 (priority)
KEY idx1 (priority),
UNIQUE KEY uidx1 (db_name, table_name, static_link_id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS mysql.spider_link_mon_servers;
CREATE TABLE mysql.spider_link_mon_servers(
db_name char(64) not null default '',
table_name char(64) not null default '',
table_name char(199) not null default '',
link_id char(5) not null default '',
sid int not null default 0,
server char(64) default null,
......@@ -330,10 +359,43 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
DROP TABLE IF EXISTS mysql.spider_link_failed_log;
CREATE TABLE mysql.spider_link_failed_log(
db_name char(64) not null default '',
table_name char(64) not null default '',
table_name char(199) not null default '',
link_id int not null default 0,
failed_time timestamp not null default current_timestamp
) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery;
CREATE TABLE mysql.spider_table_position_for_recovery(
db_name char(64) not null default '',
table_name char(199) not null default '',
failed_link_id int not null default 0,
source_link_id int not null default 0,
file text,
position text,
gtid text,
primary key (db_name, table_name, failed_link_id, source_link_id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS mysql.spider_table_sts;
CREATE TABLE mysql.spider_table_sts(
db_name char(64) not null default '',
table_name char(199) not null default '',
data_file_length bigint unsigned not null default 0,
max_data_file_length bigint unsigned not null default 0,
index_file_length bigint unsigned not null default 0,
records bigint unsigned not null default 0,
mean_rec_length bigint unsigned not null default 0,
check_time datetime not null default '0000-00-00 00:00:00',
create_time datetime not null default '0000-00-00 00:00:00',
update_time datetime not null default '0000-00-00 00:00:00',
primary key (db_name, table_name)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS mysql.spider_table_crd;
CREATE TABLE mysql.spider_table_crd(
db_name char(64) not null default '',
table_name char(199) not null default '',
key_seq int unsigned not null default 0,
cardinality bigint not null default 0,
primary key (db_name, table_name, key_seq)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
}
SET spider_internal_sql_log_off= 0;
......@@ -54,31 +54,31 @@ COUNT(*)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 1
Spider_direct_aggregate 0
SELECT MAX(a) FROM ta_l;
MAX(a)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 2
Spider_direct_aggregate 1
SELECT MIN(a) FROM ta_l;
MIN(a)
1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 3
Spider_direct_aggregate 2
SELECT MAX(a) FROM ta_l WHERE a < 5;
MAX(a)
4
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 4
Spider_direct_aggregate 3
SELECT MIN(a) FROM ta_l WHERE a > 1;
MIN(a)
2
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 5
Spider_direct_aggregate 4
deinit
connection master_1;
......
# Copyright (C) 2010-2013 Kentoku Shiba
# Copyright (C) 2010-2016 Kentoku Shiba
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -73,7 +73,7 @@ create table if not exists mysql.spider_xa_failed_log(
) engine=MyISAM default charset=utf8 collate=utf8_bin;
create table if not exists mysql.spider_tables(
db_name char(64) not null default '',
table_name char(64) not null default '',
table_name char(199) not null default '',
link_id int not null default 0,
priority bigint not null default 0,
server char(64) default null,
......@@ -89,18 +89,22 @@ create table if not exists mysql.spider_tables(
ssl_cipher char(64) default null,
ssl_key text,
ssl_verify_server_cert tinyint not null default 0,
monitoring_binlog_pos_at_failing tinyint not null default 0,
default_file text,
default_group char(64) default null,
tgt_db_name char(64) default null,
tgt_table_name char(64) default null,
link_status tinyint not null default 1,
block_status tinyint not null default 0,
static_link_id char(64) default null,
primary key (db_name, table_name, link_id),
key idx1 (priority)
key idx1 (priority),
unique key uidx1 (db_name, table_name, static_link_id)
) engine=MyISAM default charset=utf8 collate=utf8_bin;
create table if not exists mysql.spider_link_mon_servers(
db_name char(64) not null default '',
table_name char(64) not null default '',
link_id char(5) not null default '',
table_name char(199) not null default '',
link_id char(64) not null default '',
sid int unsigned not null default 0,
server char(64) default null,
scheme char(64) default null,
......@@ -121,10 +125,40 @@ create table if not exists mysql.spider_link_mon_servers(
) engine=MyISAM default charset=utf8 collate=utf8_bin;
create table if not exists mysql.spider_link_failed_log(
db_name char(64) not null default '',
table_name char(64) not null default '',
link_id int not null default 0,
table_name char(199) not null default '',
link_id char(64) not null default '',
failed_time timestamp not null default current_timestamp
) engine=MyISAM default charset=utf8 collate=utf8_bin;
create table if not exists mysql.spider_table_position_for_recovery(
db_name char(64) not null default '',
table_name char(199) not null default '',
failed_link_id int not null default 0,
source_link_id int not null default 0,
file text,
position text,
gtid text,
primary key (db_name, table_name, failed_link_id, source_link_id)
) engine=MyISAM default charset=utf8 collate=utf8_bin;
create table if not exists mysql.spider_table_sts(
db_name char(64) not null default '',
table_name char(199) not null default '',
data_file_length bigint unsigned not null default 0,
max_data_file_length bigint unsigned not null default 0,
index_file_length bigint unsigned not null default 0,
records bigint unsigned not null default 0,
mean_rec_length bigint unsigned not null default 0,
check_time datetime not null default '0000-00-00 00:00:00',
create_time datetime not null default '0000-00-00 00:00:00',
update_time datetime not null default '0000-00-00 00:00:00',
primary key (db_name, table_name)
) engine=MyISAM default charset=utf8 collate=utf8_bin;
create table if not exists mysql.spider_table_crd(
db_name char(64) not null default '',
table_name char(199) not null default '',
key_seq int unsigned not null default 0,
cardinality bigint not null default 0,
primary key (db_name, table_name, key_seq)
) engine=MyISAM default charset=utf8 collate=utf8_bin;
-- If tables already exist and their definition differ from the latest ones,
-- we fix them here.
......@@ -222,14 +256,14 @@ begin
add column default_group char(64) default null after default_file');
-- Fix for version 2.25
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'mysql'
AND TABLE_NAME = 'spider_link_mon_servers'
AND COLUMN_NAME = 'link_id';
if @col_type != 'char(5)' then
alter table mysql.spider_link_mon_servers
modify link_id char(5) not null default '';
end if;
-- select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
-- where TABLE_SCHEMA = 'mysql'
-- AND TABLE_NAME = 'spider_link_mon_servers'
-- AND COLUMN_NAME = 'link_id';
-- if @col_type != 'char(5)' then
-- alter table mysql.spider_link_mon_servers
-- modify link_id char(5) not null default '';
-- end if;
-- Fix for version 2.28
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
......@@ -283,6 +317,87 @@ begin
modify ssl_key text,
modify default_file text;
end if;
-- Fix for version 3.3.0
call mysql.spider_fix_one_table('spider_tables',
'monitoring_binlog_pos_at_failing',
'alter table mysql.spider_tables
add monitoring_binlog_pos_at_failing tinyint not null default 0 after ssl_verify_server_cert');
-- Fix for version 3.3.6
call mysql.spider_fix_one_table('spider_tables', 'block_status',
'alter table mysql.spider_tables
add column block_status tinyint not null default 0 after link_status');
call mysql.spider_fix_one_table('spider_tables', 'static_link_id',
'alter table mysql.spider_tables
add column static_link_id char(64) default null after block_status,
add unique index uidx1 (db_name, table_name, static_link_id)');
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'mysql'
AND TABLE_NAME = 'spider_link_mon_servers'
AND COLUMN_NAME = 'link_id';
if @col_type != 'char(64)' then
alter table mysql.spider_link_mon_servers
modify link_id char(64) not null default '';
end if;
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'mysql'
AND TABLE_NAME = 'spider_link_failed_log'
AND COLUMN_NAME = 'link_id';
if @col_type != 'char(64)' then
alter table mysql.spider_link_failed_log
modify link_id char(64) not null default '';
end if;
-- Fix for version 3.3.10
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'mysql'
AND TABLE_NAME = 'spider_tables'
AND COLUMN_NAME = 'table_name';
if @col_type != 'char(199)' then
alter table mysql.spider_tables
modify table_name char(199) not null default '';
end if;
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'mysql'
AND TABLE_NAME = 'spider_link_mon_servers'
AND COLUMN_NAME = 'table_name';
if @col_type != 'char(199)' then
alter table mysql.spider_link_mon_servers
modify table_name char(199) not null default '';
end if;
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'mysql'
AND TABLE_NAME = 'spider_link_failed_log'
AND COLUMN_NAME = 'table_name';
if @col_type != 'char(199)' then
alter table mysql.spider_link_failed_log
modify table_name char(199) not null default '';
end if;
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'mysql'
AND TABLE_NAME = 'spider_table_position_for_recovery'
AND COLUMN_NAME = 'table_name';
if @col_type != 'char(199)' then
alter table mysql.spider_table_position_for_recovery
modify table_name char(199) not null default '';
end if;
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'mysql'
AND TABLE_NAME = 'spider_table_sts'
AND COLUMN_NAME = 'table_name';
if @col_type != 'char(199)' then
alter table mysql.spider_table_sts
modify table_name char(199) not null default '';
end if;
select COLUMN_TYPE INTO @col_type from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'mysql'
AND TABLE_NAME = 'spider_table_crd'
AND COLUMN_NAME = 'table_name';
if @col_type != 'char(199)' then
alter table mysql.spider_table_crd
modify table_name char(199) not null default '';
end if;
end;//
delimiter ;
call mysql.spider_fix_system_tables;
......
This diff is collapsed.
/* Copyright (C) 2008-2014 Kentoku Shiba
/* Copyright (C) 2008-2017 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define SPIDER_LOCK_MODE_NO_LOCK 0
#define SPIDER_LOCK_MODE_SHARED 1
......@@ -28,6 +28,12 @@ uchar *spider_conn_get_key(
my_bool not_used __attribute__ ((unused))
);
uchar *spider_ipport_conn_get_key(
SPIDER_IP_PORT_CONN *ip_port,
size_t *length,
my_bool not_used __attribute__ ((unused))
);
int spider_reset_conn_setted_parameter(
SPIDER_CONN *conn,
THD *thd
......@@ -315,6 +321,12 @@ int spider_conn_link_idx_next(
int link_status
);
int spider_conn_get_link_status(
long *link_statuses,
uint *conn_link_idx,
int link_idx
);
int spider_conn_lock_mode(
ha_spider *spider
);
......@@ -334,3 +346,16 @@ bool spider_conn_need_open_handler(
uint idx,
int link_idx
);
SPIDER_IP_PORT_CONN *spider_create_ipport_conn(SPIDER_CONN *conn) ;
SPIDER_CONN* spider_get_conn_from_idle_connection
(
SPIDER_SHARE *share,
int link_idx,
char *conn_key,
ha_spider *spider,
uint conn_kind,
int base_link_idx,
int *error_num
);
void spider_free_ipport_conn(void *info);
/* Copyright (C) 2009-2014 Kentoku Shiba
/* Copyright (C) 2009-2017 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define MYSQL_SERVER 1
#include <my_global.h>
......@@ -993,6 +993,8 @@ long long spider_copy_tables_body(
reprepare_observer_backup = thd->m_reprepare_observer;
thd->m_reprepare_observer = NULL;
copy_tables->trx->trx_start = TRUE;
copy_tables->trx->updated_in_this_trx = FALSE;
DBUG_PRINT("info",("spider trx->updated_in_this_trx=FALSE"));
#if MYSQL_VERSION_ID < 50500
if (open_and_lock_tables(thd, table_list))
#else
......@@ -1008,6 +1010,8 @@ long long spider_copy_tables_body(
{
thd->m_reprepare_observer = reprepare_observer_backup;
copy_tables->trx->trx_start = FALSE;
copy_tables->trx->updated_in_this_trx = FALSE;
DBUG_PRINT("info",("spider trx->updated_in_this_trx=FALSE"));
my_printf_error(ER_SPIDER_UDF_CANT_OPEN_TABLE_NUM,
ER_SPIDER_UDF_CANT_OPEN_TABLE_STR, MYF(0), table_list->db,
table_list->table_name);
......@@ -1015,6 +1019,8 @@ long long spider_copy_tables_body(
}
thd->m_reprepare_observer = reprepare_observer_backup;
copy_tables->trx->trx_start = FALSE;
copy_tables->trx->updated_in_this_trx = FALSE;
DBUG_PRINT("info",("spider trx->updated_in_this_trx=FALSE"));
table = table_list->table;
table_share = table->s;
......
......@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
int spider_udf_set_copy_tables_param_default(
SPIDER_COPY_TABLES *copy_tables
......
This diff is collapsed.
/* Copyright (C) 2008-2015 Kentoku Shiba
/* Copyright (C) 2008-2017 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define SPIDER_DB_WRAPPER_STR "mysql"
#define SPIDER_DB_WRAPPER_LEN (sizeof(SPIDER_DB_WRAPPER_STR) - 1)
......@@ -192,6 +192,8 @@
#define SPIDER_SQL_PF_EQUAL_LEN (sizeof(SPIDER_SQL_PF_EQUAL_STR) - 1)
#define SPIDER_SQL_GROUP_STR " group by "
#define SPIDER_SQL_GROUP_LEN (sizeof(SPIDER_SQL_GROUP_STR) - 1)
#define SPIDER_SQL_HAVING_STR " having "
#define SPIDER_SQL_HAVING_LEN (sizeof(SPIDER_SQL_HAVING_STR) - 1)
#define SPIDER_SQL_PLUS_STR " + "
#define SPIDER_SQL_PLUS_LEN (sizeof(SPIDER_SQL_PLUS_STR) - 1)
#define SPIDER_SQL_MINUS_STR " - "
......@@ -250,6 +252,13 @@
#define SPIDER_SQL_B_STR "b"
#define SPIDER_SQL_B_LEN (sizeof(SPIDER_SQL_B_STR) - 1)
#define SPIDER_SQL_INDEX_IGNORE_STR " IGNORE INDEX "
#define SPIDER_SQL_INDEX_IGNORE_LEN (sizeof(SPIDER_SQL_INDEX_IGNORE_STR) - 1)
#define SPIDER_SQL_INDEX_USE_STR " USE INDEX "
#define SPIDER_SQL_INDEX_USE_LEN (sizeof(SPIDER_SQL_INDEX_USE_STR) - 1)
#define SPIDER_SQL_INDEX_FORCE_STR " FORCE INDEX "
#define SPIDER_SQL_INDEX_FORCE_LEN (sizeof(SPIDER_SQL_INDEX_FORCE_STR) - 1)
#define SPIDER_SQL_INT_LEN 20
#define SPIDER_SQL_HANDLER_CID_LEN 6
#define SPIDER_SQL_HANDLER_CID_FORMAT "t%05u"
......@@ -263,6 +272,13 @@ int spider_db_connect(
int link_idx
);
int spider_db_ping_internal(
SPIDER_SHARE *share,
SPIDER_CONN *conn,
int all_link_idx,
int *need_mon
);
int spider_db_ping(
ha_spider *spider,
SPIDER_CONN *conn,
......@@ -729,6 +745,7 @@ int spider_db_update(
);
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
int spider_db_direct_update(
ha_spider *spider,
TABLE *table,
......@@ -736,6 +753,13 @@ int spider_db_direct_update(
uint range_count,
ha_rows *update_rows
);
#else
int spider_db_direct_update(
ha_spider *spider,
TABLE *table,
ha_rows *update_rows
);
#endif
#endif
#ifdef HA_CAN_BULK_ACCESS
......@@ -758,6 +782,7 @@ int spider_db_delete(
);
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
int spider_db_direct_delete(
ha_spider *spider,
TABLE *table,
......@@ -765,6 +790,13 @@ int spider_db_direct_delete(
uint range_count,
ha_rows *delete_rows
);
#else
int spider_db_direct_delete(
ha_spider *spider,
TABLE *table,
ha_rows *delete_rows
);
#endif
#endif
int spider_db_delete_all_rows(
......@@ -812,7 +844,9 @@ int spider_db_print_item_type(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_open_item_cond(
......@@ -821,7 +855,9 @@ int spider_db_open_item_cond(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_open_item_func(
......@@ -830,7 +866,9 @@ int spider_db_open_item_func(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
......@@ -840,7 +878,9 @@ int spider_db_open_item_sum_func(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
#endif
......@@ -850,7 +890,9 @@ int spider_db_open_item_ident(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_open_item_field(
......@@ -859,7 +901,9 @@ int spider_db_open_item_field(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_open_item_ref(
......@@ -868,7 +912,9 @@ int spider_db_open_item_ref(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_open_item_row(
......@@ -877,7 +923,9 @@ int spider_db_open_item_row(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_open_item_string(
......@@ -886,7 +934,9 @@ int spider_db_open_item_string(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_open_item_int(
......@@ -895,7 +945,9 @@ int spider_db_open_item_int(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_open_item_cache(
......@@ -904,7 +956,9 @@ int spider_db_open_item_cache(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_open_item_insert_value(
......@@ -913,7 +967,9 @@ int spider_db_open_item_insert_value(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
int spider_db_append_condition(
......@@ -929,7 +985,9 @@ int spider_db_append_update_columns(
spider_string *str,
const char *alias,
uint alias_length,
uint dbton_id
uint dbton_id,
bool use_fields,
spider_fields *fields
);
#endif
......
This diff is collapsed.
/* Copyright (C) 2012-2014 Kentoku Shiba
/* Copyright (C) 2012-2017 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define SPIDER_HS_CONN dena::hstcpcli_ptr
#define SPIDER_HS_CONN_CREATE dena::hstcpcli_i::create
......@@ -94,7 +94,9 @@ class spider_db_handlersocket_util: public spider_db_util
ha_spider *spider,
spider_string *str,
const char *alias,
uint alias_length
uint alias_length,
bool use_fields,
spider_fields *fields
);
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
int open_item_sum_func(
......@@ -102,13 +104,36 @@ class spider_db_handlersocket_util: public spider_db_util
ha_spider *spider,
spider_string *str,
const char *alias,
uint alias_length
uint alias_length,
bool use_fields,
spider_fields *fields
);
#endif
int append_escaped_util(
spider_string *to,
String *from
);
int append_escaped_util(
spider_string *to,
String *from
);
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
int append_from_and_tables(
spider_fields *fields,
spider_string *str
);
int reappend_tables(
spider_fields *fields,
SPIDER_LINK_IDX_CHAIN *link_idx_chain,
spider_string *str
);
int append_where(
spider_string *str
);
int append_having(
spider_string *str
);
#endif
};
class spider_db_handlersocket_row: public spider_db_row
......@@ -167,7 +192,7 @@ class spider_db_handlersocket_result: public spider_db_result
SPIDER_HS_STRING_REF hs_row;
uint field_count;
int store_error_num;
spider_db_handlersocket_result();
spider_db_handlersocket_result(SPIDER_DB_CONN *in_db_conn);
~spider_db_handlersocket_result();
bool has_result();
void free_result();
......@@ -355,6 +380,17 @@ class spider_db_handlersocket: public spider_db_conn
Time_zone *time_zone,
int *need_mon
);
int show_master_status(
SPIDER_TRX *trx,
SPIDER_SHARE *share,
int all_link_idx,
int *need_mon,
TABLE *table,
spider_string *str,
int mode,
SPIDER_DB_RESULT **res1,
SPIDER_DB_RESULT **res2
);
int append_sql(
char *sql,
ulong sql_length,
......@@ -505,6 +541,11 @@ class spider_handlersocket_handler: public spider_db_handler
);
~spider_handlersocket_handler();
int init();
int append_index_hint(
spider_string *str,
int link_idx,
ulong sql_type
);
int append_table_name_with_adjusting(
spider_string *str,
int link_idx,
......@@ -849,6 +890,13 @@ class spider_handlersocket_handler: public spider_db_handler
bool need_lock_before_set_sql_for_exec(
ulong sql_type
);
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
int set_sql_for_exec(
ulong sql_type,
int link_idx,
SPIDER_LINK_IDX_CHAIN *link_idx_chain
);
#endif
int set_sql_for_exec(
ulong sql_type,
int link_idx
......@@ -960,4 +1008,52 @@ class spider_handlersocket_handler: public spider_db_handler
int link_idx,
ulong sql_type
);
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
int append_from_and_tables_part(
spider_fields *fields,
ulong sql_type
);
int reappend_tables_part(
spider_fields *fields,
ulong sql_type
);
int append_where_part(
ulong sql_type
);
int append_having_part(
ulong sql_type
);
int append_item_type_part(
Item *item,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
);
int append_list_item_select_part(
List<Item> *select,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
);
int append_group_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
);
int append_order_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
);
#endif
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Copyright (C) 2009-2015 Kentoku Shiba
/* Copyright (C) 2009-2017 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define MYSQL_SERVER 1
#include <my_global.h>
......@@ -59,7 +59,11 @@ extern PSI_cond_key spd_key_cond_bg_direct_sql;
#endif
extern HASH spider_open_connections;
extern HASH spider_ipport_conns;
extern pthread_mutex_t spider_conn_mutex;
extern pthread_mutex_t spider_conn_id_mutex;
extern pthread_mutex_t spider_ipport_conn_mutex;
extern ulonglong spider_conn_id;
uint spider_udf_calc_hash(
char *key,
......@@ -351,6 +355,27 @@ int spider_udf_direct_sql_create_conn_key(
#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
}
#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);
......@@ -363,6 +388,7 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
int *error_num
) {
SPIDER_CONN *conn;
SPIDER_IP_PORT_CONN *ip_port_conn;
char *tmp_name, *tmp_host, *tmp_username, *tmp_password, *tmp_socket;
char *tmp_wrapper, *tmp_ssl_ca, *tmp_ssl_capath, *tmp_ssl_cert;
char *tmp_ssl_cipher, *tmp_ssl_key, *tmp_default_file, *tmp_default_group;
......@@ -560,12 +586,57 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
goto error;
conn->ping_time = (time_t) time((time_t*) 0);
conn->connect_error_time = conn->ping_time;
pthread_mutex_lock(&spider_conn_id_mutex);
conn->conn_id = spider_conn_id;
++spider_conn_id;
pthread_mutex_unlock(&spider_conn_id_mutex);
pthread_mutex_lock(&spider_ipport_conn_mutex);
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
if ((ip_port_conn = (SPIDER_IP_PORT_CONN*) my_hash_search_using_hash_value(
&spider_ipport_conns, conn->conn_key_hash_value,
(uchar*)conn->conn_key, conn->conn_key_length)))
#else
if ((ip_port_conn = (SPIDER_IP_PORT_CONN*) my_hash_search(
&spider_ipport_conns, (uchar*)conn->conn_key, conn->conn_key_length)))
#endif
{ /* exists, +1 */
pthread_mutex_unlock(&spider_ipport_conn_mutex);
pthread_mutex_lock(&ip_port_conn->mutex);
if (spider_param_max_connections())
{ /* enable conncetion pool */
if (ip_port_conn->ip_port_count >= spider_param_max_connections())
{ /* bigger than the max num of connections, free conn and return NULL */
pthread_mutex_unlock(&ip_port_conn->mutex);
goto error_too_many_ipport_count;
}
}
ip_port_conn->ip_port_count++;
pthread_mutex_unlock(&ip_port_conn->mutex);
}
else
{// do not exist
ip_port_conn = spider_create_ipport_conn(conn);
if (!ip_port_conn) {
/* failed, always do not effect 'create conn' */
pthread_mutex_unlock(&spider_ipport_conn_mutex);
DBUG_RETURN(conn);
}
if (my_hash_insert(&spider_ipport_conns, (uchar *)ip_port_conn)) {
/* insert failed, always do not effect 'create conn' */
pthread_mutex_unlock(&spider_ipport_conn_mutex);
DBUG_RETURN(conn);
}
pthread_mutex_unlock(&spider_ipport_conn_mutex);
}
conn->ip_port_conn = ip_port_conn;
DBUG_RETURN(conn);
error:
DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name);
pthread_mutex_destroy(&conn->mta_conn_mutex);
error_too_many_ipport_count:
error_mta_conn_mutex_init:
error_db_conn_init:
delete conn->db_conn;
......@@ -1624,6 +1695,15 @@ 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
#if MYSQL_VERSION_ID < 50500
#else
use_real_table = spider_param_udf_ds_use_real_table(thd,
......@@ -1642,7 +1722,7 @@ long long spider_direct_sql_body(
table_list.table_name = direct_sql->table_names[roop_count];
#endif
if (!(direct_sql->tables[roop_count] =
thd->find_temporary_table(&table_list)))
SPIDER_find_temporary_table(thd, &table_list)))
{
#if MYSQL_VERSION_ID < 50500
#else
......
......@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
uint spider_udf_calc_hash(
char *key,
......
/* Copyright (C) 2008-2015 Kentoku Shiba & 2017 MariaDB corp
/* Copyright (C) 2008-2017 Kentoku Shiba & 2017 MariaDB corp
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -23,13 +23,14 @@
#define SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS
#endif
#if MYSQL_VERSION_ID >= 100204
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100100
#define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100204
#define HANDLER_HAS_TOP_TABLE_FIELDS
#define HANDLER_HAS_DIRECT_UPDATE_ROWS
#define HANDLER_HAS_DIRECT_AGGREGATE
#define PARTITION_HAS_EXTRA_ATTACH_CHILDREN
#define PARTITION_HAS_GET_CHILD_HANDLERS
#define PARTITION_HAS_EXTRA_ATTACH_CHILDREN
#define PARTITION_HAS_GET_CHILD_HANDLERS
#define HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN
#define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment