merge Spider 3.3.13

New features in 3.3.13 are:
- Join Push Down for 1 by 1 table and single partition.
This commit is contained in:
Kentoku SHIBA 2017-11-27 21:53:02 +02:00 committed by Monty
parent e53ef202bd
commit 207594afac
52 changed files with 12169 additions and 1433 deletions

View file

@ -1,13 +1,17 @@
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()

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* 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 @@ public:
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 @@ public:
/* 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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
uchar *new_data,
ha_rows *update_rows
);
#else
int pre_direct_update_rows();
#endif
#endif
#endif
bool start_bulk_delete();
@ -638,6 +661,7 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
bool sorted,
ha_rows *delete_rows
);
#else
int pre_direct_delete_rows();
#endif
#endif
#endif
int delete_all_rows();
@ -798,7 +833,9 @@ public:
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(

View file

@ -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

View file

@ -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)

View file

@ -3,6 +3,7 @@
/*
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011-2017 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/

View file

@ -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.
*/

View file

@ -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.
*/

View file

@ -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

View file

@ -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);
}

View file

@ -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);

View file

@ -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.
*/

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -1,4 +1,4 @@
# 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;

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* 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);

View file

@ -1,4 +1,4 @@
/* 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;

View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* 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

View file

@ -1,4 +1,4 @@
/* 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 MYSQL_SERVER 1
#include <my_global.h>
@ -40,6 +40,7 @@
extern handlerton *spider_hton_ptr;
extern HASH spider_open_connections;
extern HASH spider_ipport_conns;
extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE];
extern const char spider_dig_upper[];
@ -107,6 +108,12 @@ SPIDER_DB_CONN *spider_handlersocket_create_conn(
DBUG_RETURN(new spider_db_handlersocket(conn));
}
bool spider_handlersocket_support_direct_join(
) {
DBUG_ENTER("spider_handlersocket_support_direct_join");
DBUG_RETURN(FALSE);
}
spider_db_handlersocket_util spider_db_handlersocket_utility;
SPIDER_DBTON spider_dbton_handlersocket = {
@ -119,6 +126,7 @@ SPIDER_DBTON spider_dbton_handlersocket = {
spider_handlersocket_create_handler,
NULL,
spider_handlersocket_create_conn,
spider_handlersocket_support_direct_join,
&spider_db_handlersocket_utility
};
@ -591,7 +599,8 @@ bool spider_db_handlersocket_result_buffer::check_size(
}
spider_db_handlersocket_result::spider_db_handlersocket_result(
) : spider_db_result(spider_dbton_handlersocket.dbton_id)
SPIDER_DB_CONN *in_db_conn
) : spider_db_result(in_db_conn, spider_dbton_handlersocket.dbton_id)
{
DBUG_ENTER("spider_db_handlersocket_result::spider_db_handlersocket_result");
DBUG_PRINT("info",("spider this=%p", this));
@ -1228,7 +1237,7 @@ spider_db_result *spider_db_handlersocket::store_result(
*spider_res_buf = (spider_db_result_buffer *) hs_res_buf;
}
hs_res_buf->clear();
if (!(result = new spider_db_handlersocket_result()))
if (!(result = new spider_db_handlersocket_result(this)))
{
*error_num = HA_ERR_OUT_OF_MEM;
DBUG_RETURN(NULL);
@ -1438,7 +1447,7 @@ spider_db_result *spider_db_handlersocket::use_result(
spider_db_handlersocket_result *result;
DBUG_ENTER("spider_db_handlersocket::use_result");
DBUG_PRINT("info",("spider this=%p", this));
if (!(result = new spider_db_handlersocket_result()))
if (!(result = new spider_db_handlersocket_result(this)))
{
*error_num = HA_ERR_OUT_OF_MEM;
DBUG_RETURN(NULL);
@ -1841,6 +1850,22 @@ int spider_db_handlersocket::set_time_zone(
DBUG_RETURN(0);
}
int spider_db_handlersocket::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
) {
DBUG_ENTER("spider_db_handlersocket::show_master_status");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(0);
}
int spider_db_handlersocket::append_sql(
char *sql,
ulong sql_length,
@ -2721,7 +2746,9 @@ int spider_db_handlersocket_util::open_item_func(
ha_spider *spider,
spider_string *str,
const char *alias,
uint alias_length
uint alias_length,
bool use_fields,
spider_fields *fields
) {
uint dbton_id = spider_dbton_handlersocket.dbton_id;
int error_num;
@ -2734,6 +2761,7 @@ int spider_db_handlersocket_util::open_item_func(
separete_str_length = SPIDER_SQL_NULL_CHAR_LEN,
last_str_length = SPIDER_SQL_NULL_CHAR_LEN;
int use_pushdown_udf;
bool merge_func = FALSE;
DBUG_ENTER("spider_db_handlersocket_util::open_item_func");
if (str)
{
@ -2797,7 +2825,7 @@ int spider_db_handlersocket_util::open_item_func(
if (str)
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(spider_db_open_item_int(item_func, spider, str,
alias, alias_length, dbton_id));
alias, alias_length, dbton_id, use_fields, fields));
} else if (
!strncasecmp("case", func_name, func_name_length)
) {
@ -2813,7 +2841,7 @@ int spider_db_handlersocket_util::open_item_func(
{
if ((error_num = spider_db_print_item_type(
item_list[item_func_case->first_expr_num], spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
}
for (roop_count = 0; roop_count < item_func_case->ncases;
@ -2827,7 +2855,7 @@ int spider_db_handlersocket_util::open_item_func(
}
if ((error_num = spider_db_print_item_type(
item_list[roop_count], spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
if (str)
{
@ -2837,7 +2865,7 @@ int spider_db_handlersocket_util::open_item_func(
}
if ((error_num = spider_db_print_item_type(
item_list[roop_count + 1], spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
}
if (item_func_case->else_expr_num != -1)
@ -2850,7 +2878,7 @@ int spider_db_handlersocket_util::open_item_func(
}
if ((error_num = spider_db_print_item_type(
item_list[item_func_case->else_expr_num], spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
}
if (str)
@ -2887,7 +2915,7 @@ int spider_db_handlersocket_util::open_item_func(
if (str)
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
alias, alias_length, dbton_id));
alias, alias_length, dbton_id, use_fields, fields));
} else if (
!strncasecmp("convert", func_name, func_name_length)
) {
@ -2912,41 +2940,110 @@ int spider_db_handlersocket_util::open_item_func(
if (str)
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
alias, alias_length, dbton_id));
alias, alias_length, dbton_id, use_fields, fields));
} else if (func_name_length == 9 &&
!strncasecmp("isnottrue", func_name, func_name_length)
) {
last_str = SPIDER_SQL_IS_NOT_TRUE_STR;
last_str_length = SPIDER_SQL_IS_NOT_TRUE_LEN;
break;
} else if (func_name_length == 10 &&
!strncasecmp("isnotfalse", func_name, func_name_length)
) {
last_str = SPIDER_SQL_IS_NOT_FALSE_STR;
last_str_length = SPIDER_SQL_IS_NOT_FALSE_LEN;
break;
} else if (func_name_length == 12)
} else if (func_name_length == 10)
{
if (!strncasecmp("cast_as_date", func_name, func_name_length))
if (!strncasecmp("isnotfalse", func_name, func_name_length))
{
last_str = SPIDER_SQL_IS_NOT_FALSE_STR;
last_str_length = SPIDER_SQL_IS_NOT_FALSE_LEN;
break;
} else if (!strncasecmp("column_get", func_name, func_name_length))
{
if (str)
{
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (str->reserve(SPIDER_SQL_CAST_LEN))
if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
str->q_append(func_name, func_name_length);
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
}
func_name = SPIDER_SQL_COMMA_STR;
func_name_length = SPIDER_SQL_COMMA_LEN;
separete_str = SPIDER_SQL_COMMA_STR;
separete_str_length = SPIDER_SQL_COMMA_LEN;
break;
}
} else if (func_name_length == 12)
{
if (!strncasecmp("cast_as_date", func_name, func_name_length))
{
item = item_list[0];
if (item->type() == Item::FUNC_ITEM)
{
DBUG_PRINT("info",("spider child is FUNC_ITEM"));
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
child_func_name = (char*) ifunc->func_name();
child_func_name_length = strlen(child_func_name);
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
!strncasecmp("column_get", child_func_name, child_func_name_length)
) {
DBUG_PRINT("info",("spider this is merge func"));
merge_func = TRUE;
}
}
}
if (str)
{
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (!merge_func)
{
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
}
}
last_str = SPIDER_SQL_AS_DATE_STR;
last_str_length = SPIDER_SQL_AS_DATE_LEN;
break;
} else if (!strncasecmp("cast_as_time", func_name, func_name_length))
{
item = item_list[0];
if (item->type() == Item::FUNC_ITEM)
{
DBUG_PRINT("info",("spider child is FUNC_ITEM"));
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
child_func_name = (char*) ifunc->func_name();
child_func_name_length = strlen(child_func_name);
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
!strncasecmp("column_get", child_func_name, child_func_name_length)
) {
DBUG_PRINT("info",("spider this is merge func"));
merge_func = TRUE;
}
}
}
if (str)
{
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
if (!merge_func)
{
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
}
}
last_str = SPIDER_SQL_AS_TIME_STR;
last_str_length = SPIDER_SQL_AS_TIME_LEN;
@ -2959,7 +3056,7 @@ int spider_db_handlersocket_util::open_item_func(
if (str)
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
alias, alias_length, dbton_id));
alias, alias_length, dbton_id, use_fields, fields));
} else if (!strncasecmp("timestampdiff", func_name, func_name_length))
{
#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC
@ -3022,7 +3119,7 @@ int spider_db_handlersocket_util::open_item_func(
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
}
if ((error_num = spider_db_print_item_type(item_list[0], spider,
str, alias, alias_length, dbton_id)))
str, alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
if (str)
{
@ -3031,7 +3128,7 @@ int spider_db_handlersocket_util::open_item_func(
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
}
if ((error_num = spider_db_print_item_type(item_list[1], spider,
str, alias, alias_length, dbton_id)))
str, alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
if (str)
{
@ -3049,6 +3146,29 @@ int spider_db_handlersocket_util::open_item_func(
{
if (!strncasecmp("cast_as_binary", func_name, func_name_length))
{
item = item_list[0];
if (item->type() == Item::FUNC_ITEM)
{
DBUG_PRINT("info",("spider child is FUNC_ITEM"));
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
child_func_name = (char*) ifunc->func_name();
child_func_name_length = strlen(child_func_name);
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
!strncasecmp("column_get", child_func_name, child_func_name_length)
) {
DBUG_PRINT("info",("spider this is merge func"));
merge_func = TRUE;
}
}
}
if (str)
{
char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2;
@ -3056,9 +3176,12 @@ int spider_db_handlersocket_util::open_item_func(
tmp_str.init_calc_mem(123);
tmp_str.length(0);
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
if (!merge_func)
{
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
}
#if MYSQL_VERSION_ID < 50500
item_func->print(tmp_str.get_str(), QT_IS);
#else
@ -3077,12 +3200,38 @@ int spider_db_handlersocket_util::open_item_func(
break;
} else if (!strncasecmp("cast_as_signed", func_name, func_name_length))
{
item = item_list[0];
if (item->type() == Item::FUNC_ITEM)
{
DBUG_PRINT("info",("spider child is FUNC_ITEM"));
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
child_func_name = (char*) ifunc->func_name();
child_func_name_length = strlen(child_func_name);
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
!strncasecmp("column_get", child_func_name, child_func_name_length)
) {
DBUG_PRINT("info",("spider this is merge func"));
merge_func = TRUE;
}
}
}
if (str)
{
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
if (!merge_func)
{
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
}
}
last_str = SPIDER_SQL_AS_SIGNED_STR;
last_str_length = SPIDER_SQL_AS_SIGNED_LEN;
@ -3092,12 +3241,38 @@ int spider_db_handlersocket_util::open_item_func(
{
if (!strncasecmp("cast_as_unsigned", func_name, func_name_length))
{
item = item_list[0];
if (item->type() == Item::FUNC_ITEM)
{
DBUG_PRINT("info",("spider child is FUNC_ITEM"));
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
child_func_name = (char*) ifunc->func_name();
child_func_name_length = strlen(child_func_name);
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
!strncasecmp("column_get", child_func_name, child_func_name_length)
) {
DBUG_PRINT("info",("spider this is merge func"));
merge_func = TRUE;
}
}
}
if (str)
{
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
if (!merge_func)
{
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
}
}
last_str = SPIDER_SQL_AS_UNSIGNED_STR;
last_str_length = SPIDER_SQL_AS_UNSIGNED_LEN;
@ -3105,6 +3280,29 @@ int spider_db_handlersocket_util::open_item_func(
} else if (!strncasecmp("decimal_typecast", func_name,
func_name_length))
{
item = item_list[0];
if (item->type() == Item::FUNC_ITEM)
{
DBUG_PRINT("info",("spider child is FUNC_ITEM"));
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
child_func_name = (char*) ifunc->func_name();
child_func_name_length = strlen(child_func_name);
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
!strncasecmp("column_get", child_func_name, child_func_name_length)
) {
DBUG_PRINT("info",("spider this is merge func"));
merge_func = TRUE;
}
}
}
if (str)
{
char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2;
@ -3112,9 +3310,12 @@ int spider_db_handlersocket_util::open_item_func(
tmp_str.init_calc_mem(124);
tmp_str.length(0);
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
if (!merge_func)
{
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
}
#if MYSQL_VERSION_ID < 50500
item_func->print(tmp_str.get_str(), QT_IS);
#else
@ -3134,12 +3335,38 @@ int spider_db_handlersocket_util::open_item_func(
} else if (!strncasecmp("cast_as_datetime", func_name,
func_name_length))
{
item = item_list[0];
if (item->type() == Item::FUNC_ITEM)
{
DBUG_PRINT("info",("spider child is FUNC_ITEM"));
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
child_func_name = (char*) ifunc->func_name();
child_func_name_length = strlen(child_func_name);
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
!strncasecmp("column_get", child_func_name, child_func_name_length)
) {
DBUG_PRINT("info",("spider this is merge func"));
merge_func = TRUE;
}
}
}
if (str)
{
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
if (!merge_func)
{
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
}
}
last_str = SPIDER_SQL_AS_DATETIME_STR;
last_str_length = SPIDER_SQL_AS_DATETIME_LEN;
@ -3155,7 +3382,7 @@ int spider_db_handlersocket_util::open_item_func(
item_date_add_interval->int_type];
func_name_length = strlen(func_name);
if ((error_num = spider_db_print_item_type(item_list[0], spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
if (str)
{
@ -3172,7 +3399,7 @@ int spider_db_handlersocket_util::open_item_func(
}
}
if ((error_num = spider_db_print_item_type(item_list[1], spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
if (str)
{
@ -3203,9 +3430,33 @@ int spider_db_handlersocket_util::open_item_func(
if (str)
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
alias, alias_length, dbton_id));
alias, alias_length, dbton_id, use_fields, fields));
case Item_func::CHAR_TYPECAST_FUNC:
DBUG_PRINT("info",("spider CHAR_TYPECAST_FUNC"));
{
item = item_list[0];
if (item->type() == Item::FUNC_ITEM)
{
DBUG_PRINT("info",("spider child is FUNC_ITEM"));
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
child_func_name = (char*) ifunc->func_name();
child_func_name_length = strlen(child_func_name);
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
!strncasecmp("column_get", child_func_name, child_func_name_length)
) {
DBUG_PRINT("info",("spider this is merge func"));
merge_func = TRUE;
}
}
}
if (str)
{
char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2;
@ -3213,9 +3464,12 @@ int spider_db_handlersocket_util::open_item_func(
tmp_str.init_calc_mem(125);
tmp_str.length(0);
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
if (!merge_func)
{
if (str->reserve(SPIDER_SQL_CAST_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
}
#if MYSQL_VERSION_ID < 50500
item_func->print(tmp_str.get_str(), QT_IS);
#else
@ -3248,12 +3502,15 @@ int spider_db_handlersocket_util::open_item_func(
bool has_other_item = FALSE;
while((item = lif++))
{
#ifdef SPIDER_HAS_EXPR_CACHE_ITEM
if (
item->type() == Item::EXPR_CACHE_ITEM
) {
DBUG_PRINT("info",("spider EXPR_CACHE_ITEM"));
has_expr_cache_item = TRUE;
} else if (
} else
#endif
if (
item->type() == Item::FUNC_ITEM &&
((Item_func *) item)->functype() == Item_func::ISNOTNULL_FUNC
) {
@ -3357,7 +3614,7 @@ int spider_db_handlersocket_util::open_item_func(
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(
spider_db_open_item_cond((Item_cond *) item_func, spider, str,
alias, alias_length, dbton_id));
alias, alias_length, dbton_id, use_fields, fields));
case Item_func::TRIG_COND_FUNC:
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
case Item_func::GUSERVAR_FUNC:
@ -3365,10 +3622,10 @@ int spider_db_handlersocket_util::open_item_func(
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
if (item_func->result_type() == STRING_RESULT)
DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
alias, alias_length, dbton_id));
alias, alias_length, dbton_id, use_fields, fields));
else
DBUG_RETURN(spider_db_open_item_int(item_func, spider, str,
alias, alias_length, dbton_id));
alias, alias_length, dbton_id, use_fields, fields));
case Item_func::FT_FUNC:
if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY)
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
@ -3474,7 +3731,7 @@ int spider_db_handlersocket_util::open_item_func(
{
item = item_list[roop_count];
if ((error_num = spider_db_print_item_type(item, spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
if (roop_count == 1)
{
@ -3492,7 +3749,7 @@ int spider_db_handlersocket_util::open_item_func(
}
item = item_list[roop_count];
if ((error_num = spider_db_print_item_type(item, spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
}
if (item_func->functype() == Item_func::FT_FUNC)
@ -3506,7 +3763,7 @@ int spider_db_handlersocket_util::open_item_func(
}
item = item_list[0];
if ((error_num = spider_db_print_item_type(item, spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
if (str)
{
@ -3534,7 +3791,8 @@ int spider_db_handlersocket_util::open_item_func(
{
Item_func_conv_charset *item_func_conv_charset =
(Item_func_conv_charset *)item_func;
CHARSET_INFO *conv_charset = item_func_conv_charset->conv_charset;
CHARSET_INFO *conv_charset =
item_func_conv_charset->SPIDER_Item_func_conv_charset_conv_charset;
uint cset_length = strlen(conv_charset->csname);
if (str->reserve(SPIDER_SQL_USING_LEN + cset_length))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@ -3545,6 +3803,8 @@ int spider_db_handlersocket_util::open_item_func(
}
if (str)
{
if (merge_func)
str->length(str->length() - SPIDER_SQL_CLOSE_PAREN_LEN);
if (str->reserve(last_str_length + SPIDER_SQL_CLOSE_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(last_str, last_str_length);
@ -3559,7 +3819,9 @@ int spider_db_handlersocket_util::open_item_sum_func(
ha_spider *spider,
spider_string *str,
const char *alias,
uint alias_length
uint alias_length,
bool use_fields,
spider_fields *fields
) {
uint dbton_id = spider_dbton_handlersocket.dbton_id;
uint roop_count, item_count = item_sum->get_arg_count();
@ -3589,7 +3851,7 @@ int spider_db_handlersocket_util::open_item_sum_func(
{
item = args[roop_count];
if ((error_num = spider_db_print_item_type(item, spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
if (str)
{
@ -3600,7 +3862,7 @@ int spider_db_handlersocket_util::open_item_sum_func(
}
item = args[roop_count];
if ((error_num = spider_db_print_item_type(item, spider, str,
alias, alias_length, dbton_id)))
alias, alias_length, dbton_id, use_fields, fields)))
DBUG_RETURN(error_num);
}
if (str)
@ -3638,6 +3900,47 @@ int spider_db_handlersocket_util::append_escaped_util(
DBUG_RETURN(0);
}
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
int spider_db_handlersocket_util::append_from_and_tables(
spider_fields *fields,
spider_string *str
) {
DBUG_ENTER("spider_db_handlersocket_util::append_from_and_tables");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_handlersocket_util::reappend_tables(
spider_fields *fields,
SPIDER_LINK_IDX_CHAIN *link_idx_chain,
spider_string *str
) {
DBUG_ENTER("spider_db_handlersocket_util::reappend_tables");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_handlersocket_util::append_where(
spider_string *str
) {
DBUG_ENTER("spider_db_handlersocket_util::append_where");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_db_handlersocket_util::append_having(
spider_string *str
) {
DBUG_ENTER("spider_db_handlersocket_util::append_having");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
#endif
spider_handlersocket_share::spider_handlersocket_share(
st_spider_share *share
) : spider_db_share(
@ -4053,6 +4356,16 @@ int spider_handlersocket_handler::init()
DBUG_RETURN(0);
}
int spider_handlersocket_handler::append_index_hint(
spider_string *str,
int link_idx,
ulong sql_type
)
{
DBUG_ENTER("spider_handlersocket_handler::append_index_hint");
DBUG_RETURN(0);
}
int spider_handlersocket_handler::append_table_name_with_adjusting(
spider_string *str,
int link_idx,
@ -5000,7 +5313,7 @@ int spider_handlersocket_handler::is_sole_projection_field(
uint16 field_index
) {
DBUG_ENTER("spider_handlersocket_handler::is_sole_projection_field");
DBUG_PRINT("info", ("spider this=%p", this));
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
@ -5367,6 +5680,19 @@ bool spider_handlersocket_handler::need_lock_before_set_sql_for_exec(
DBUG_RETURN(TRUE);
}
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
int spider_handlersocket_handler::set_sql_for_exec(
ulong sql_type,
int link_idx,
SPIDER_LINK_IDX_CHAIN *link_idx_chain
) {
DBUG_ENTER("spider_handlersocket_handler::set_sql_for_exec");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
#endif
int spider_handlersocket_handler::set_sql_for_exec(
ulong sql_type,
int link_idx
@ -5444,7 +5770,7 @@ int spider_handlersocket_handler::show_table_status(
int sts_mode,
uint flag
) {
spider_db_handlersocket_result res;
spider_db_handlersocket_result res(NULL);
SPIDER_SHARE *share = spider->share;
ulonglong auto_increment_value = 0;
DBUG_ENTER("spider_handlersocket_show_table_status");
@ -5792,4 +6118,100 @@ int spider_handlersocket_handler::reset_union_table_name(
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
int spider_handlersocket_handler::append_list_item_select_part(
List<Item> *select,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
) {
DBUG_ENTER("spider_handlersocket_handler::append_list_item_select_part");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_handlersocket_handler::append_from_and_tables_part(
spider_fields *fields,
ulong sql_type
) {
DBUG_ENTER("spider_handlersocket_handler::append_from_and_tables_part");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_handlersocket_handler::reappend_tables_part(
spider_fields *fields,
ulong sql_type
) {
DBUG_ENTER("spider_handlersocket_handler::reappend_tables_part");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_handlersocket_handler::append_where_part(
ulong sql_type
) {
DBUG_ENTER("spider_handlersocket_handler::append_where_part");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_handlersocket_handler::append_having_part(
ulong sql_type
) {
DBUG_ENTER("spider_handlersocket_handler::append_having_part");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_handlersocket_handler::append_item_type_part(
Item *item,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
) {
DBUG_ENTER("spider_handlersocket_handler::append_item_type_part");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_handlersocket_handler::append_group_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
) {
DBUG_ENTER("spider_handlersocket_handler::append_group_by_part");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
int spider_handlersocket_handler::append_order_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
) {
DBUG_ENTER("spider_handlersocket_handler::append_order_by_part");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(0);
DBUG_RETURN(0);
}
#endif
#endif

View file

@ -1,4 +1,4 @@
/* 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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
);
~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 @@ public:
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 @@ public:
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
};

View file

@ -1,4 +1,4 @@
/* 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,15 +11,29 @@
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 */
#include "hs_compat.h"
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#include "hstcpcli.hpp"
#endif
#define SPIDER_DBTON_SIZE 15
#define SPIDER_DB_WRAPPER_MYSQL "mysql"
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100204
#define PLUGIN_VAR_CAN_MEMALLOC
/*
#define ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC
#define HASH_UPDATE_WITH_HASH_VALUE
*/
#else
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
#define HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
#endif
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002
#define SPIDER_HAS_DISCOVER_TABLE_STRUCTURE
#define SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE
@ -31,7 +45,6 @@
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100007
#define SPIDER_HAS_DISCOVER_TABLE_STRUCTURE_COMMENT
#define SPIDER_ITEM_HAS_CMP_TYPE
#endif
@ -47,6 +60,14 @@
#endif
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100108
#define SPIDER_HAS_GROUP_BY_HANDLER
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100200
#define SPIDER_ORDER_HAS_ENUM_ORDER
#endif
#if defined(MARIADB_BASE_VERSION)
#define SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
#define SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR
@ -182,32 +203,32 @@ typedef st_spider_result SPIDER_RESULT;
#define SPIDER_SQL_LCL_NAME_QUOTE_STR "`"
#define SPIDER_SQL_LCL_NAME_QUOTE_LEN (sizeof(SPIDER_SQL_LCL_NAME_QUOTE_STR) - 1)
#define SPIDER_CONN_KIND_MYSQL (1U << 0)
#define SPIDER_CONN_KIND_MYSQL (1 << 0)
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#define SPIDER_CONN_KIND_HS_READ (1U << 2)
#define SPIDER_CONN_KIND_HS_WRITE (1U << 3)
#define SPIDER_CONN_KIND_HS_READ (1 << 2)
#define SPIDER_CONN_KIND_HS_WRITE (1 << 3)
#endif
#define SPIDER_SQL_KIND_SQL (1U << 0)
#define SPIDER_SQL_KIND_HANDLER (1U << 1)
#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 (1U << 2)
#define SPIDER_SQL_KIND_HS (1 << 2)
#endif
#define SPIDER_SQL_TYPE_SELECT_SQL (1U << 0)
#define SPIDER_SQL_TYPE_INSERT_SQL (1U << 1)
#define SPIDER_SQL_TYPE_UPDATE_SQL (1U << 2)
#define SPIDER_SQL_TYPE_DELETE_SQL (1U << 3)
#define SPIDER_SQL_TYPE_BULK_UPDATE_SQL (1U << 4)
#define SPIDER_SQL_TYPE_TMP_SQL (1U << 5)
#define SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL (1U << 6)
#define SPIDER_SQL_TYPE_OTHER_SQL (1U << 7)
#define SPIDER_SQL_TYPE_HANDLER (1U << 8)
#define SPIDER_SQL_TYPE_SELECT_HS (1U << 9)
#define SPIDER_SQL_TYPE_INSERT_HS (1U << 10)
#define SPIDER_SQL_TYPE_UPDATE_HS (1U << 11)
#define SPIDER_SQL_TYPE_DELETE_HS (1U << 12)
#define SPIDER_SQL_TYPE_OTHER_HS (1U << 13)
#define SPIDER_SQL_TYPE_SELECT_SQL (1 << 0)
#define SPIDER_SQL_TYPE_INSERT_SQL (1 << 1)
#define SPIDER_SQL_TYPE_UPDATE_SQL (1 << 2)
#define SPIDER_SQL_TYPE_DELETE_SQL (1 << 3)
#define SPIDER_SQL_TYPE_BULK_UPDATE_SQL (1 << 4)
#define SPIDER_SQL_TYPE_TMP_SQL (1 << 5)
#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,
@ -531,6 +552,169 @@ public:
bool is_ascii() const;
};
typedef struct spider_table_link_idx_holder SPIDER_TABLE_LINK_IDX_HOLDER;
typedef struct spider_table_holder SPIDER_TABLE_HOLDER;
typedef struct spider_link_idx_holder
{
spider_table_link_idx_holder *table_link_idx_holder;
int link_idx;
int link_status;
spider_link_idx_holder *next_table;
spider_link_idx_holder *next;
} SPIDER_LINK_IDX_HOLDER;
typedef struct spider_link_idx_chain
{
SPIDER_CONN *conn;
spider_link_idx_holder *link_idx_holder;
spider_link_idx_holder *current_link_idx_holder;
int link_status;
spider_link_idx_chain *next;
} SPIDER_LINK_IDX_CHAIN;
typedef struct spider_table_link_idx_holder
{
spider_table_holder *table_holder;
spider_link_idx_holder *first_link_idx_holder;
spider_link_idx_holder *last_link_idx_holder;
spider_link_idx_holder *current_link_idx_holder;
uint link_idx_holder_count;
} SPIDER_TABLE_LINK_IDX_HOLDER;
typedef struct spider_conn_holder
{
SPIDER_CONN *conn;
spider_table_link_idx_holder *table_link_idx_holder;
uint link_idx_holder_count_max;
bool checked_for_same_conn;
long access_balance;
spider_conn_holder *prev;
spider_conn_holder *next;
} SPIDER_CONN_HOLDER;
typedef struct spider_table_holder
{
TABLE *table;
ha_spider *spider;
spider_string *alias;
} SPIDER_TABLE_HOLDER;
typedef struct spider_field_holder
{
Field *field;
ha_spider *spider;
spider_string *alias;
spider_field_holder *next;
} SPIDER_FIELD_HOLDER;
typedef struct spider_field_chain
{
spider_field_holder *field_holder;
spider_field_chain *next;
} SPIDER_FIELD_CHAIN;
class spider_fields
{
uint dbton_count;
uint current_dbton_num;
uint dbton_ids[SPIDER_DBTON_SIZE];
uint table_count;
uint current_table_num;
SPIDER_TABLE_HOLDER *table_holder;
SPIDER_LINK_IDX_CHAIN *first_link_idx_chain;
SPIDER_LINK_IDX_CHAIN *last_link_idx_chain;
SPIDER_LINK_IDX_CHAIN *current_link_idx_chain;
SPIDER_LINK_IDX_CHAIN *first_ok_link_idx_chain;
SPIDER_CONN_HOLDER *first_conn_holder;
SPIDER_CONN_HOLDER *last_conn_holder;
SPIDER_CONN_HOLDER *current_conn_holder;
SPIDER_FIELD_HOLDER *first_field_holder;
SPIDER_FIELD_HOLDER *last_field_holder;
SPIDER_FIELD_HOLDER *current_field_holder;
SPIDER_FIELD_CHAIN *first_field_chain;
SPIDER_FIELD_CHAIN *last_field_chain;
SPIDER_FIELD_CHAIN *current_field_chain;
Field **first_field_ptr;
Field **current_field_ptr;
public:
spider_fields();
virtual ~spider_fields();
void add_dbton_id(
uint dbton_id_arg
);
void set_pos_to_first_dbton_id();
uint get_next_dbton_id();
int make_link_idx_chain(
int link_status
);
SPIDER_LINK_IDX_CHAIN *create_link_idx_chain();
void set_pos_to_first_link_idx_chain();
SPIDER_LINK_IDX_CHAIN *get_next_link_idx_chain();
SPIDER_LINK_IDX_HOLDER *get_dup_link_idx_holder(
SPIDER_TABLE_LINK_IDX_HOLDER *table_link_idx_holder,
SPIDER_LINK_IDX_HOLDER *current
);
bool check_link_ok_chain();
bool is_first_link_ok_chain(
SPIDER_LINK_IDX_CHAIN *link_idx_chain_arg
);
int get_ok_link_idx();
void set_first_link_idx();
int add_link_idx(
SPIDER_CONN_HOLDER *conn_holder_arg,
ha_spider *spider_arg,
int link_idx
);
SPIDER_LINK_IDX_HOLDER *create_link_idx_holder();
void set_pos_to_first_table_on_link_idx_chain(
SPIDER_LINK_IDX_CHAIN *link_idx_chain_arg
);
SPIDER_LINK_IDX_HOLDER *get_next_table_on_link_idx_chain(
SPIDER_LINK_IDX_CHAIN *link_idx_chain_arg
);
SPIDER_CONN_HOLDER *add_conn(
SPIDER_CONN *conn_arg,
long access_balance
);
SPIDER_CONN_HOLDER *create_conn_holder();
void set_pos_to_first_conn_holder();
SPIDER_CONN_HOLDER *get_next_conn_holder();
bool has_conn_holder();
void clear_conn_holder_from_conn();
bool check_conn_same_conn(
SPIDER_CONN *conn_arg
);
bool remove_conn_if_not_checked();
void check_support_dbton(
uchar *dbton_bitmap
);
void choose_a_conn();
void free_conn_holder(
SPIDER_CONN_HOLDER *conn_holder_arg
);
SPIDER_TABLE_HOLDER *add_table(
ha_spider *spider_arg
);
int create_table_holder(
uint table_count_arg
);
void set_pos_to_first_table_holder();
SPIDER_TABLE_HOLDER *get_next_table_holder();
int add_field(Field *field_arg);
SPIDER_FIELD_HOLDER *create_field_holder();
void set_pos_to_first_field_holder();
SPIDER_FIELD_HOLDER *get_next_field_holder();
SPIDER_FIELD_CHAIN *create_field_chain();
void set_pos_to_first_field_chain();
SPIDER_FIELD_CHAIN *get_next_field_chain();
void set_field_ptr(Field **field_arg);
Field **get_next_field_ptr();
int ping_table_mon_from_table(
SPIDER_LINK_IDX_CHAIN *link_idx_chain
);
};
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#define SPIDER_HS_UINT32_INFO dena::uint32_info
#define SPIDER_HS_STRING_REF dena::string_ref
@ -681,7 +865,9 @@ public:
ha_spider *spider,
spider_string *str,
const char *alias,
uint alias_length
uint alias_length,
bool use_fields,
spider_fields *fields
) = 0;
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
virtual int open_item_sum_func(
@ -689,13 +875,32 @@ public:
ha_spider *spider,
spider_string *str,
const char *alias,
uint alias_length
uint alias_length,
bool use_fields,
spider_fields *fields
) = 0;
#endif
virtual int append_escaped_util(
spider_string *to,
String *from
) = 0;
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
virtual int append_from_and_tables(
spider_fields *fields,
spider_string *str
) = 0;
virtual int reappend_tables(
spider_fields *fields,
SPIDER_LINK_IDX_CHAIN *link_idx_chain,
spider_string *str
) = 0;
virtual int append_where(
spider_string *str
) = 0;
virtual int append_having(
spider_string *str
) = 0;
#endif
};
class spider_db_row
@ -745,9 +950,12 @@ public:
class spider_db_result
{
protected:
SPIDER_DB_CONN *db_conn;
public:
uint dbton_id;
spider_db_result(uint in_dbton_id) : dbton_id(in_dbton_id) {}
spider_db_result(SPIDER_DB_CONN *in_db_conn, uint in_dbton_id) :
db_conn(in_db_conn), dbton_id(in_dbton_id) {}
virtual ~spider_db_result() {}
virtual bool has_result() = 0;
virtual void free_result() = 0;
@ -922,6 +1130,17 @@ public:
Time_zone *time_zone,
int *need_mon
) = 0;
virtual 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
) = 0;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
virtual int append_sql(
char *sql,
@ -1041,10 +1260,18 @@ public:
ha_spider *spider;
spider_db_share *db_share;
int first_link_idx;
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
SPIDER_LINK_IDX_CHAIN *link_idx_chain;
#endif
spider_db_handler(ha_spider *spider, spider_db_share *db_share) :
spider(spider), db_share(db_share), first_link_idx(-1) {}
virtual ~spider_db_handler() {}
virtual int init() = 0;
virtual int append_index_hint(
spider_string *str,
int link_idx,
ulong sql_type
) = 0;
virtual int append_table_name_with_adjusting(
spider_string *str,
int link_idx,
@ -1104,6 +1331,10 @@ public:
virtual int append_select_part(
ulong sql_type
) = 0;
virtual int append_select(
spider_string *str,
ulong sql_type
) = 0;
virtual int append_table_select_part(
ulong sql_type
) = 0;
@ -1280,7 +1511,7 @@ public:
int link_idx
) = 0;
virtual bool is_sole_projection_field(
uint16 field_index
uint16 field_index
) = 0;
virtual bool is_bulk_insert_exec_period(
bool bulk_end
@ -1342,6 +1573,13 @@ public:
virtual bool need_lock_before_set_sql_for_exec(
ulong sql_type
) = 0;
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
virtual int set_sql_for_exec(
ulong sql_type,
int link_idx,
SPIDER_LINK_IDX_CHAIN *link_idx_chain
) = 0;
#endif
virtual int set_sql_for_exec(
ulong sql_type,
int link_idx
@ -1452,6 +1690,54 @@ public:
int link_idx,
ulong sql_type
) = 0;
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
virtual int append_from_and_tables_part(
spider_fields *fields,
ulong sql_type
) = 0;
virtual int reappend_tables_part(
spider_fields *fields,
ulong sql_type
) = 0;
virtual int append_where_part(
ulong sql_type
) = 0;
virtual int append_having_part(
ulong sql_type
) = 0;
virtual int append_item_type_part(
Item *item,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
) = 0;
virtual int append_list_item_select_part(
List<Item> *select,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
) = 0;
virtual int append_group_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
) = 0;
virtual int append_order_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
) = 0;
#endif
};
class spider_db_copy_table
@ -1539,9 +1825,9 @@ typedef struct st_spider_dbton
spider_db_copy_table *(*create_db_copy_table)(
spider_db_share *db_share);
SPIDER_DB_CONN *(*create_db_conn)(SPIDER_CONN *conn);
bool (*support_direct_join)();
spider_db_util *db_util;
} SPIDER_DBTON;
#define SPIDER_DBTON_SIZE 15
typedef struct st_spider_position
{
@ -1661,6 +1947,8 @@ typedef struct st_spider_result_list
spider_bulk_upd_start bulk_update_start;
bool check_direct_order_limit;
bool direct_order_limit;
/* the limit_offeset, without where condition */
bool direct_limit_offset;
bool direct_distinct;
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
bool direct_aggregate;

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* 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 */
class spider_db_mysql_util: public spider_db_util
{
@ -99,7 +99,9 @@ public:
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(
@ -107,13 +109,32 @@ public:
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
);
#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_mysql_row: public spider_db_row
@ -161,7 +182,7 @@ public:
spider_db_mysql_row row;
MYSQL_ROW_OFFSET first_row;
int store_error_num;
spider_db_mysql_result();
spider_db_mysql_result(SPIDER_DB_CONN *in_db_conn);
~spider_db_mysql_result();
bool has_result();
void free_result();
@ -199,6 +220,13 @@ public:
int fetch_table_mon_status(
int &status
);
int fetch_show_master_status(
const char **binlog_file_name,
const char **binlog_pos
);
int fetch_select_binlog_gtid_pos(
const char **gtid_pos
);
longlong num_rows();
uint num_fields();
void move_to_pos(
@ -224,9 +252,9 @@ public:
class spider_db_mysql: public spider_db_conn
{
MYSQL *db_conn;
int stored_error;
public:
MYSQL *db_conn;
HASH lock_table_hash;
bool lock_table_hash_inited;
uint lock_table_hash_id;
@ -351,6 +379,39 @@ public:
Time_zone *time_zone,
int *need_mon
);
int exec_simple_sql_with_result(
SPIDER_TRX *trx,
SPIDER_SHARE *share,
const char *sql,
uint sql_length,
int all_link_idx,
int *need_mon,
SPIDER_DB_RESULT **res
);
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 select_binlog_gtid_pos(
SPIDER_TRX *trx,
SPIDER_SHARE *share,
int all_link_idx,
int *need_mon,
TABLE *table,
spider_string *str,
const char *binlog_file_name,
uint binlog_file_name_length,
const char *binlog_pos,
uint binlog_pos_length,
SPIDER_DB_RESULT **res
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int append_sql(
char *sql,
@ -512,7 +573,9 @@ class spider_mysql_handler: public spider_db_handler
int where_pos;
int order_pos;
int limit_pos;
public:
int table_name_pos;
private:
int ha_read_pos;
int ha_next_pos;
int ha_where_pos;
@ -554,6 +617,11 @@ public:
);
~spider_mysql_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,
@ -1129,7 +1197,7 @@ public:
int link_idx
);
bool is_sole_projection_field(
uint16 field_index
uint16 field_index
);
bool is_bulk_insert_exec_period(
bool bulk_end
@ -1199,6 +1267,13 @@ public:
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
@ -1310,6 +1385,78 @@ public:
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_list_item_select(
List<Item> *select,
spider_string *str,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields
);
int append_group_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
);
int append_group_by(
ORDER *order,
spider_string *str,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields
);
int append_order_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
);
int append_order_by(
ORDER *order,
spider_string *str,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields
);
#endif
};
class spider_mysql_copy_table: public spider_db_copy_table

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* 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 */
class spider_db_oracle;
class spider_db_oracle_result;
@ -102,7 +102,9 @@ public:
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(
@ -110,7 +112,9 @@ public:
ha_spider *spider,
spider_string *str,
const char *alias,
uint alias_length
uint alias_length,
bool use_fields,
spider_fields *fields
);
#endif
size_t escape_string(
@ -123,6 +127,23 @@ public:
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_oracle_row: public spider_db_row
@ -195,7 +216,7 @@ public:
spider_db_oracle_row row;
int store_error_num;
spider_db_oracle_result();
spider_db_oracle_result(SPIDER_DB_CONN *in_db_conn);
~spider_db_oracle_result();
bool has_result();
void free_result();
@ -409,6 +430,17 @@ public:
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
);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int append_sql(
char *sql,
@ -586,7 +618,9 @@ class spider_oracle_handler: public spider_db_handler
int where_pos;
int order_pos;
int limit_pos;
public:
int table_name_pos;
private:
int update_set_pos;
int ha_read_pos;
int ha_next_pos;
@ -634,6 +668,11 @@ public:
);
~spider_oracle_handler();
int init();
int spider_oracle_handler::append_index_hint(
spider_string *str,
int link_idx,
ulong sql_type
);
int append_table_name_with_adjusting(
spider_string *str,
int link_idx,
@ -1209,7 +1248,7 @@ public:
int link_idx
);
bool is_sole_projection_field(
uint16 field_index
uint16 field_index
);
bool is_bulk_insert_exec_period(
bool bulk_end
@ -1279,6 +1318,13 @@ public:
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
@ -1393,6 +1439,78 @@ public:
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_list_item_select(
List<Item> *select,
spider_string *str,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields
);
int append_group_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
);
int append_group_by(
ORDER *order,
spider_string *str,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields
);
int append_order_by_part(
ORDER *order,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields,
ulong sql_type
);
int append_order_by(
ORDER *order,
spider_string *str,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields
);
#endif
};
class spider_oracle_copy_table: public spider_db_copy_table

View file

@ -1,4 +1,4 @@
/* 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

View file

@ -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,

View file

@ -1,4 +1,4 @@
/* 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

View file

@ -1,4 +1,4 @@
/* 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 ER_SPIDER_INVALID_CONNECT_INFO_NUM 12501
#define ER_SPIDER_INVALID_CONNECT_INFO_STR "The connect info '%-.64s' is invalid"
@ -21,10 +21,10 @@
#define ER_SPIDER_INVALID_UDF_PARAM_STR "The UDF parameter '%-.64s' is invalid"
#define ER_SPIDER_DIFFERENT_LINK_COUNT_NUM 12504
#define ER_SPIDER_DIFFERENT_LINK_COUNT_STR "Different multiple table link parameter's count"
#define ER_SPIDER_UDF_PING_TABLE_PARAM_TOO_LONG_NUM 12505
#define ER_SPIDER_UDF_PING_TABLE_PARAM_TOO_LONG_STR "Server name or table name are too long"
#define ER_SPIDER_UDF_PING_TABLE_PARAM_REQIRED_NUM 12506
#define ER_SPIDER_UDF_PING_TABLE_PARAM_REQIRED_STR "Server name or table name are required"
#define ER_SPIDER_UDF_PARAM_TOO_LONG_NUM 12505
#define ER_SPIDER_UDF_PARAM_TOO_LONG_STR "The UDF parameter '%-.64s' is too long"
#define ER_SPIDER_UDF_PARAM_REQIRED_NUM 12506
#define ER_SPIDER_UDF_PARAM_REQIRED_STR "The UDF parameter '%-.64s' is required"
#define ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM 12507
#define ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR "This UDF can't execute if other tables are opened"
#define ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM "This UDF can't execute if other tables are opened '%s'=%lld"
@ -65,6 +65,10 @@
#define ER_SPIDER_CANT_OPEN_SYS_TABLE_STR "Can't open system table %s.%s"
#define ER_SPIDER_LINK_MON_JUST_NG_NUM 12525
#define ER_SPIDER_LINK_MON_JUST_NG_STR "Table '%s.%s' just got a problem"
#define ER_SPIDER_INVALID_CONNECT_INFO_START_WITH_NUM_NUM 12526
#define ER_SPIDER_INVALID_CONNECT_INFO_START_WITH_NUM_STR "The connect info '%-.64s' for %s cannot start with number"
#define ER_SPIDER_INVALID_CONNECT_INFO_SAME_NUM 12527
#define ER_SPIDER_INVALID_CONNECT_INFO_SAME_STR "The connect info '%-.64s' for %s cannot use same name in same table"
#define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_NUM 12601
#define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_STR "Can't use both spider_use_consistent_snapshot = 1 and spider_internal_xa = 1"
@ -116,6 +120,10 @@
#define ER_SPIDER_ORACLE_STR "Error from Oracle %d %d %s"
#define ER_SPIDER_ORACLE_NUM 12712
#define ER_SPIDER_ORACLE_ERR "Oracle error"
#define ER_SPIDER_CON_COUNT_ERROR 12713
#define ER_SPIDER_CON_COUNT_ERROR_STR "Too many connections between spider and remote"
#define ER_SPIDER_TABLE_OPEN_TIMEOUT_NUM 12714
#define ER_SPIDER_TABLE_OPEN_TIMEOUT_STR "Table %s.%s open timeout"
#define ER_SPIDER_COND_SKIP_NUM 12801
#define ER_SPIDER_UNKNOWN_NUM 12500

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,44 @@
/* Copyright (C) 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
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
class spider_group_by_handler: public group_by_handler
{
Query query;
spider_fields *fields;
ha_spider *spider;
SPIDER_TRX *trx;
spider_db_result *result;
bool first;
longlong offset_limit;
int store_error;
public:
spider_group_by_handler(
THD *thd_arg,
Query *query_arg,
spider_fields *fields_arg
);
~spider_group_by_handler();
int init_scan();
int next_row();
int end_scan();
};
group_by_handler *spider_create_group_by_handler(
THD *thd,
Query *query
);
#endif

View file

@ -1,4 +1,4 @@
/* 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 MYSQL_SERVER 1
#include <my_global.h>

View file

@ -1,4 +1,4 @@
/* 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,15 @@
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_DETAIL_VERSION "3.2.37"
#define SPIDER_HEX_VERSION 0x0302
#define SPIDER_DETAIL_VERSION "3.3.13"
#define SPIDER_HEX_VERSION 0x0303
#if MYSQL_VERSION_ID < 50500
#define spider_my_free(A,B) my_free(A,B)
#else
#define my_free(A,B) my_free(A)
#define spider_my_free(A,B) my_free(A)
#ifdef pthread_mutex_t
#undef pthread_mutex_t
#endif
@ -66,6 +67,7 @@
#define my_sprintf(A,B) sprintf B
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100004
#define spider_stmt_da_message(A) thd_get_error_message(A)
#define spider_stmt_da_sql_errno(A) thd_get_error_number(A)
@ -129,6 +131,55 @@
#define SPIDER_Item_args_arg_count_IS_PROTECTED
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100112
#define SPIDER_Item_func_conv_charset_conv_charset collation.collation
#else
#define SPIDER_Item_func_conv_charset_conv_charset conv_charset
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100200
#define SPIDER_WITHOUT_HA_STATISTIC_INCREMENT
#define SPIDER_init_read_record(A,B,C,D,E,F,G,H) init_read_record(A,B,C,D,E,F,G,H)
#define SPIDER_HAS_NEXT_THREAD_ID
#define SPIDER_new_THD(A) (new THD(A))
#define SPIDER_order_direction_is_asc(A) (A->direction == ORDER::ORDER_ASC)
#else
#define SPIDER_init_read_record(A,B,C,D,E,F,G,H) init_read_record(A,B,C,D,F,G,H)
#define SPIDER_new_THD(A) (new THD())
#define SPIDER_order_direction_is_asc(A) (A->asc)
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100201
#define SPIDER_HAS_MY_CHARLEN
#define SPIDER_find_temporary_table(A,B) A->find_temporary_table(B)
#else
#define SPIDER_find_temporary_table(A,B) find_temporary_table(A,B)
#endif
#if defined(MARIADB_BASE_VERSION)
#if MYSQL_VERSION_ID >= 100209
#define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H) generate_partition_syntax(A,B,C,E,F,G)
#elif MYSQL_VERSION_ID >= 100200
#define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H) generate_partition_syntax(A,B,C,D,E,F,G,H)
#elif MYSQL_VERSION_ID >= 100007
#define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H) generate_partition_syntax(B,C,D,E,F,G,H)
#else
#define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H) generate_partition_syntax(B,C,D,E,F,G)
#endif
#else
#define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H)
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100209
#define SPIDER_create_partition_name(A,B,C,D,E,F) create_partition_name(A,B,C,D,E,F)
#define SPIDER_create_subpartition_name(A,B,C,D,E,F) create_subpartition_name(A,B,C,D,E,F)
#define SPIDER_free_part_syntax(A,B)
#else
#define SPIDER_create_partition_name(A,B,C,D,E,F) create_partition_name(A,C,D,E,F)
#define SPIDER_create_subpartition_name(A,B,C,D,E,F) create_subpartition_name(A,C,D,E,F)
#define SPIDER_free_part_syntax(A,B) spider_my_free(A,B)
#endif
#if MYSQL_VERSION_ID >= 50500
#define SPIDER_HAS_HASH_VALUE_TYPE
#endif
@ -151,12 +202,13 @@
#define SPIDER_LINK_MON_DRAW_FEW_MON 1
#define SPIDER_LINK_MON_DRAW 2
#define SPIDER_TMP_SHARE_CHAR_PTR_COUNT 19
#define SPIDER_TMP_SHARE_CHAR_PTR_COUNT 20
#define SPIDER_TMP_SHARE_UINT_COUNT 17
#define SPIDER_TMP_SHARE_LONG_COUNT 18
#define SPIDER_TMP_SHARE_LONG_COUNT 19
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
#define SPIDER_MEM_CALC_LIST_NUM 247
#define SPIDER_MEM_CALC_LIST_NUM 257
#define SPIDER_CONN_META_BUF_LEN 64
#define SPIDER_BACKUP_DASTATUS \
bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE;
@ -176,6 +228,25 @@
class ha_spider;
typedef struct st_spider_share SPIDER_SHARE;
typedef struct st_spider_table_mon_list SPIDER_TABLE_MON_LIST;
typedef struct st_spider_ip_port_conn SPIDER_IP_PORT_CONN;
#ifndef WITHOUT_SPIDER_BG_SEARCH
typedef struct st_spider_thread
{
uint thread_idx;
THD *thd;
volatile bool killed;
volatile bool thd_wait;
volatile bool first_free_wait;
pthread_t thread;
pthread_cond_t cond;
pthread_mutex_t mutex;
pthread_cond_t sync_cond;
volatile SPIDER_SHARE *queue_first;
volatile SPIDER_SHARE *queue_last;
} SPIDER_THREAD;
#endif
typedef struct st_spider_file_pos
{
@ -224,8 +295,10 @@ typedef struct st_spider_alter_table
char **tmp_tgt_ssl_keys;
char **tmp_tgt_default_files;
char **tmp_tgt_default_groups;
char **tmp_static_link_ids;
long *tmp_tgt_ports;
long *tmp_tgt_ssl_vscs;
long *tmp_monitoring_binlog_pos_at_failing;
long *tmp_link_statuses;
uint *tmp_server_names_lengths;
@ -243,6 +316,7 @@ typedef struct st_spider_alter_table
uint *tmp_tgt_ssl_keys_lengths;
uint *tmp_tgt_default_files_lengths;
uint *tmp_tgt_default_groups_lengths;
uint *tmp_static_link_ids_lengths;
uint tmp_server_names_charlen;
uint tmp_tgt_table_names_charlen;
@ -259,6 +333,7 @@ typedef struct st_spider_alter_table
uint tmp_tgt_ssl_keys_charlen;
uint tmp_tgt_default_files_charlen;
uint tmp_tgt_default_groups_charlen;
uint tmp_static_link_ids_charlen;
uint tmp_server_names_length;
uint tmp_tgt_table_names_length;
@ -275,8 +350,10 @@ typedef struct st_spider_alter_table
uint tmp_tgt_ssl_keys_length;
uint tmp_tgt_default_files_length;
uint tmp_tgt_default_groups_length;
uint tmp_static_link_ids_length;
uint tmp_tgt_ports_length;
uint tmp_tgt_ssl_vscs_length;
uint tmp_monitoring_binlog_pos_at_failing_length;
uint tmp_link_statuses_length;
} SPIDER_ALTER_TABLE;
@ -455,6 +532,12 @@ typedef struct st_spider_conn
THD *connect_error_thd;
query_id_t connect_error_query_id;
time_t connect_error_time;
#ifdef SPIDER_HAS_GROUP_BY_HANDLER
SPIDER_CONN_HOLDER *conn_holder_for_direct_join;
SPIDER_LINK_IDX_CHAIN *link_idx_chain;
#endif
SPIDER_IP_PORT_CONN *ip_port_conn;
} SPIDER_CONN;
typedef struct st_spider_lgtm_tblhnd_share
@ -489,6 +572,7 @@ typedef struct st_spider_patition_handler_share
bool between_flg;
bool idx_bitmap_is_set;
bool rnd_bitmap_is_set;
query_id_t parallel_search_query_id;
} SPIDER_PARTITION_HANDLER_SHARE;
typedef struct st_spider_patition_share
@ -544,6 +628,8 @@ typedef struct st_spider_transaction
bool tmp_flg;
bool registed_allocated_thds;
bool updated_in_this_trx;
THD *thd;
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
my_hash_value_type thd_hash_value;
@ -608,6 +694,7 @@ typedef struct st_spider_transaction
ulonglong direct_delete_count;
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
@ -719,6 +806,27 @@ typedef struct st_spider_share
pthread_cond_t *bg_mon_conds;
pthread_cond_t *bg_mon_sleep_conds;
#endif
#ifndef WITHOUT_SPIDER_BG_SEARCH
/* static bg thread for sts and crd */
TABLE table;
ha_spider *sts_spider;
ha_spider *crd_spider;
SPIDER_THREAD *sts_thread;
SPIDER_THREAD *crd_thread;
volatile bool sts_spider_init;
volatile bool sts_working;
volatile bool sts_wait;
volatile bool crd_spider_init;
volatile bool crd_working;
volatile bool crd_wait;
volatile SPIDER_SHARE *sts_prev;
volatile SPIDER_SHARE *sts_next;
volatile SPIDER_SHARE *crd_prev;
volatile SPIDER_SHARE *crd_next;
#endif
MEM_ROOT mem_root;
/*
volatile bool auto_increment_init;
volatile ulonglong auto_increment_lclval;
@ -755,6 +863,8 @@ typedef struct st_spider_share
#ifdef WITH_PARTITION_STORAGE_ENGINE
int sts_sync;
#endif
int store_last_sts;
int load_sts_at_startup;
#ifndef WITHOUT_SPIDER_BG_SEARCH
int crd_bg_mode;
#endif
@ -763,6 +873,8 @@ typedef struct st_spider_share
#ifdef WITH_PARTITION_STORAGE_ENGINE
int crd_sync;
#endif
int store_last_crd;
int load_crd_at_startup;
int crd_type;
double crd_weight;
longlong internal_offset;
@ -804,6 +916,7 @@ typedef struct st_spider_share
int use_table_charset;
int use_pushdown_udf;
int skip_default_condition;
int skip_parallel_search;
int direct_dup_insert;
longlong direct_order_limit;
int read_only_mode;
@ -851,6 +964,7 @@ typedef struct st_spider_share
char **tgt_ssl_keys;
char **tgt_default_files;
char **tgt_default_groups;
char **static_link_ids;
char **tgt_pk_names;
char **tgt_sequence_names;
char **conn_keys;
@ -867,6 +981,7 @@ typedef struct st_spider_share
long *monitoring_bg_flag;
long *monitoring_bg_kind;
#endif
long *monitoring_binlog_pos_at_failing;
long *monitoring_flag;
long *monitoring_kind;
#ifndef WITHOUT_SPIDER_BG_SEARCH
@ -903,6 +1018,7 @@ typedef struct st_spider_share
uint *tgt_ssl_keys_lengths;
uint *tgt_default_files_lengths;
uint *tgt_default_groups_lengths;
uint *static_link_ids_lengths;
uint *tgt_pk_names_lengths;
uint *tgt_sequence_names_lengths;
uint *conn_keys_lengths;
@ -932,6 +1048,7 @@ typedef struct st_spider_share
uint tgt_ssl_keys_charlen;
uint tgt_default_files_charlen;
uint tgt_default_groups_charlen;
uint static_link_ids_charlen;
uint tgt_pk_names_charlen;
uint tgt_sequence_names_charlen;
uint conn_keys_charlen;
@ -957,6 +1074,7 @@ typedef struct st_spider_share
uint tgt_ssl_keys_length;
uint tgt_default_files_length;
uint tgt_default_groups_length;
uint static_link_ids_length;
uint tgt_pk_names_length;
uint tgt_sequence_names_length;
uint conn_keys_length;
@ -973,6 +1091,7 @@ typedef struct st_spider_share
uint monitoring_bg_flag_length;
uint monitoring_bg_kind_length;
#endif
uint monitoring_binlog_pos_at_failing_length;
uint monitoring_flag_length;
uint monitoring_kind_length;
#ifndef WITHOUT_SPIDER_BG_SEARCH
@ -1143,6 +1262,7 @@ typedef struct st_spider_table_mon
{
SPIDER_SHARE *share;
uint32 server_id;
st_spider_table_mon_list *parent;
st_spider_table_mon *next;
} SPIDER_TABLE_MON;
@ -1276,3 +1396,19 @@ char *spider_create_string(
const char *str,
uint length
);
typedef struct st_spider_ip_port_conn {
char *key;
size_t key_len;
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
my_hash_value_type key_hash_value;
#endif
char remote_ip_str[SPIDER_CONN_META_BUF_LEN];
long remote_port;
ulong ip_port_count;
volatile ulong waiting_count;
pthread_mutex_t mutex;
pthread_cond_t cond;
ulonglong conn_id; /* each conn has it's own conn_id */
} SPIDER_IP_PORT_CONN;

View file

@ -1,4 +1,4 @@
/* 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 MYSQL_SERVER 1
#include <my_global.h>
@ -184,7 +184,7 @@ void spider_free_mem(
size = *((uint *) tmp_ptr);
tmp_ptr -= ALIGN_SIZE(sizeof(uint));
id = *((uint *) tmp_ptr);
my_free(tmp_ptr, my_flags);
spider_my_free(tmp_ptr, my_flags);
spider_free_mem_calc(trx, id, size);
DBUG_VOID_RETURN;

View file

@ -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_free(A,B,C) spider_free_mem(A,B,C)
#define spider_malloc(A,B,C,D) \

View file

@ -1,4 +1,4 @@
/* 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,11 +11,10 @@
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>
#include <my_global.h>
#include "mysql_version.h"
#include "spd_environ.h"
#if MYSQL_VERSION_ID < 50500
@ -89,6 +88,17 @@ static int spider_direct_aggregate(THD *thd, SHOW_VAR *var, char *buff)
DBUG_RETURN(error_num);
}
static int spider_parallel_search(THD *thd, SHOW_VAR *var, char *buff)
{
int error_num = 0;
SPIDER_TRX *trx;
DBUG_ENTER("spider_parallel_search");
var->type = SHOW_LONGLONG;
if ((trx = spider_get_trx(thd, TRUE, &error_num)))
var->value = (char *) &trx->parallel_search_count;
DBUG_RETURN(error_num);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
static int spider_hs_result_free(THD *thd, SHOW_VAR *var, char *buff)
{
@ -122,11 +132,15 @@ struct st_mysql_show_var spider_status_variables[] =
(char *) &spider_direct_order_limit, SHOW_SIMPLE_FUNC},
{"Spider_direct_aggregate",
(char *) &spider_direct_aggregate, SHOW_SIMPLE_FUNC},
{"Spider_parallel_search",
(char *) &spider_parallel_search, SHOW_SIMPLE_FUNC},
#else
{"Spider_direct_order_limit",
(char *) &spider_direct_order_limit, SHOW_FUNC},
{"Spider_direct_aggregate",
(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
@ -410,6 +424,29 @@ uint spider_param_force_commit(
DBUG_RETURN(THDVAR(thd, force_commit));
}
/*
0: register all XA transaction
1: register only write XA transaction
*/
static MYSQL_THDVAR_UINT(
xa_register_mode, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Mode of XA transaction register into system table", /* comment */
NULL, /* check */
NULL, /* update */
1, /* def */
0, /* min */
1, /* max */
0 /* blk */
);
uint spider_param_xa_register_mode(
THD *thd
) {
DBUG_ENTER("spider_param_xa_register_mode");
DBUG_RETURN(THDVAR(thd, xa_register_mode));
}
/*
-1 :use table parameter
0-:offset
@ -1668,7 +1705,8 @@ double spider_param_crd_weight(
/*
-1 :use table parameter
0 :Background confirmation is disabled
1 :Background confirmation is enabled
1 :Background confirmation is enabled (create thread per table/partition)
2 :Background confirmation is enabled (use static threads)
*/
static MYSQL_THDVAR_INT(
crd_bg_mode, /* name */
@ -1678,7 +1716,7 @@ static MYSQL_THDVAR_INT(
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
2, /* max */
0 /* blk */
);
@ -1779,7 +1817,8 @@ int spider_param_sts_sync(
/*
-1 :use table parameter
0 :Background confirmation is disabled
1 :Background confirmation is enabled
1 :Background confirmation is enabled (create thread per table/partition)
2 :Background confirmation is enabled (use static threads)
*/
static MYSQL_THDVAR_INT(
sts_bg_mode, /* name */
@ -1789,7 +1828,7 @@ static MYSQL_THDVAR_INT(
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
2, /* max */
0 /* blk */
);
@ -2702,6 +2741,34 @@ int spider_param_skip_default_condition(
skip_default_condition : THDVAR(thd, skip_default_condition));
}
/*
-1 :use table parameter
0 :not skip
1 :skip parallel search if query is not SELECT statement
2 :skip parallel search if query has SQL_NO_CACHE
3 :1+2
*/
static MYSQL_THDVAR_INT(
skip_parallel_search, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Skip parallel search by specific conditions", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
3, /* max */
0 /* blk */
);
int spider_param_skip_parallel_search(
THD *thd,
int skip_parallel_search
) {
DBUG_ENTER("spider_param_skip_parallel_search");
DBUG_RETURN(THDVAR(thd, skip_parallel_search) == -1 ?
skip_parallel_search : THDVAR(thd, skip_parallel_search));
}
/*
-1 :use table parameter
0 :not send directly
@ -2829,6 +2896,66 @@ my_bool spider_param_general_log()
DBUG_RETURN(spider_general_log);
}
/*
FALSE: no pushdown hints
TRUE: pushdown hints
*/
static MYSQL_THDVAR_BOOL(
index_hint_pushdown, /* name */
PLUGIN_VAR_OPCMDARG, /* opt */
"switch to control if push down index hint, like force_index", /* comment */
NULL, /* check */
NULL, /* update */
FALSE /* def */
);
my_bool spider_param_index_hint_pushdown(
THD *thd
) {
DBUG_ENTER("spider_param_index_hint_pushdown");
DBUG_RETURN(THDVAR(thd, index_hint_pushdown));
}
static uint spider_max_connections;
static MYSQL_SYSVAR_UINT(
max_connections,
spider_max_connections,
PLUGIN_VAR_RQCMDARG,
"the values, as the max conncetion from spider to remote mysql. Default 0, mean unlimit the connections",
NULL,
NULL,
0, /* def */
0, /* min */
99999, /* max */
0 /* blk */
);
uint spider_param_max_connections()
{
DBUG_ENTER("spider_param_max_connections");
DBUG_RETURN(spider_max_connections);
}
static uint spider_conn_wait_timeout;
static MYSQL_SYSVAR_UINT(
conn_wait_timeout,
spider_conn_wait_timeout,
PLUGIN_VAR_RQCMDARG,
"the values, as the max waiting time when spider get a remote conn",
NULL,
NULL,
10, /* def */
0, /* min */
1000, /* max */
0 /* blk */
);
uint spider_param_conn_wait_timeout()
{
DBUG_ENTER("spider_param_conn_wait_timeout");
DBUG_RETURN(spider_conn_wait_timeout);
}
static uint spider_log_result_errors;
/*
0: no log
@ -3012,6 +3139,162 @@ int spider_param_bka_table_name_type(
bka_table_name_type : THDVAR(thd, bka_table_name_type));
}
static int spider_store_last_sts;
/*
-1 : use table parameter
0 : do not store
1 : do store
*/
static MYSQL_SYSVAR_INT(
store_last_sts,
spider_store_last_sts,
PLUGIN_VAR_RQCMDARG,
"Store last sts result into system table",
NULL,
NULL,
-1,
-1,
1,
0
);
int spider_param_store_last_sts(
int store_last_sts
) {
DBUG_ENTER("spider_param_store_last_sts");
DBUG_RETURN(spider_store_last_sts == -1 ?
store_last_sts : spider_store_last_sts);
}
static int spider_store_last_crd;
/*
-1 : use table parameter
0 : do not store
1 : do store
*/
static MYSQL_SYSVAR_INT(
store_last_crd,
spider_store_last_crd,
PLUGIN_VAR_RQCMDARG,
"Store last crd result into system table",
NULL,
NULL,
-1,
-1,
1,
0
);
int spider_param_store_last_crd(
int store_last_crd
) {
DBUG_ENTER("spider_param_store_last_crd");
DBUG_RETURN(spider_store_last_crd == -1 ?
store_last_crd : spider_store_last_crd);
}
static int spider_load_sts_at_startup;
/*
-1 : use table parameter
0 : do not load
1 : do load
*/
static MYSQL_SYSVAR_INT(
load_sts_at_startup,
spider_load_sts_at_startup,
PLUGIN_VAR_RQCMDARG,
"Load sts from system table at startup",
NULL,
NULL,
-1,
-1,
1,
0
);
int spider_param_load_sts_at_startup(
int load_sts_at_startup
) {
DBUG_ENTER("spider_param_load_sts_at_startup");
DBUG_RETURN(spider_load_sts_at_startup == -1 ?
load_sts_at_startup : spider_load_sts_at_startup);
}
static int spider_load_crd_at_startup;
/*
-1 : use table parameter
0 : do not load
1 : do load
*/
static MYSQL_SYSVAR_INT(
load_crd_at_startup,
spider_load_crd_at_startup,
PLUGIN_VAR_RQCMDARG,
"Load crd from system table at startup",
NULL,
NULL,
-1,
-1,
1,
0
);
int spider_param_load_crd_at_startup(
int load_crd_at_startup
) {
DBUG_ENTER("spider_param_load_crd_at_startup");
DBUG_RETURN(spider_load_crd_at_startup == -1 ?
load_crd_at_startup : spider_load_crd_at_startup);
}
#ifndef WITHOUT_SPIDER_BG_SEARCH
static uint spider_table_sts_thread_count;
/*
1-: thread count
*/
static MYSQL_SYSVAR_UINT(
table_sts_thread_count,
spider_table_sts_thread_count,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Static thread count of table sts",
NULL,
NULL,
10,
1,
4294967295U,
0
);
uint spider_param_table_sts_thread_count()
{
DBUG_ENTER("spider_param_table_sts_thread_count");
DBUG_RETURN(spider_table_sts_thread_count);
}
static uint spider_table_crd_thread_count;
/*
1-: thread count
*/
static MYSQL_SYSVAR_UINT(
table_crd_thread_count,
spider_table_crd_thread_count,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Static thread count of table crd",
NULL,
NULL,
10,
1,
4294967295U,
0
);
uint spider_param_table_crd_thread_count()
{
DBUG_ENTER("spider_param_table_crd_thread_count");
DBUG_RETURN(spider_table_crd_thread_count);
}
#endif
static struct st_mysql_storage_engine spider_storage_engine =
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
@ -3026,6 +3309,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(internal_xa),
MYSQL_SYSVAR(internal_xa_snapshot),
MYSQL_SYSVAR(force_commit),
MYSQL_SYSVAR(xa_register_mode),
MYSQL_SYSVAR(internal_offset),
MYSQL_SYSVAR(internal_limit),
MYSQL_SYSVAR(split_read),
@ -3077,6 +3361,8 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
#ifdef WITH_PARTITION_STORAGE_ENGINE
MYSQL_SYSVAR(crd_sync),
#endif
MYSQL_SYSVAR(store_last_crd),
MYSQL_SYSVAR(load_crd_at_startup),
MYSQL_SYSVAR(crd_type),
MYSQL_SYSVAR(crd_weight),
#ifndef WITHOUT_SPIDER_BG_SEARCH
@ -3087,6 +3373,8 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
#ifdef WITH_PARTITION_STORAGE_ENGINE
MYSQL_SYSVAR(sts_sync),
#endif
MYSQL_SYSVAR(store_last_sts),
MYSQL_SYSVAR(load_sts_at_startup),
#ifndef WITHOUT_SPIDER_BG_SEARCH
MYSQL_SYSVAR(sts_bg_mode),
#endif
@ -3128,6 +3416,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(error_read_mode),
MYSQL_SYSVAR(error_write_mode),
MYSQL_SYSVAR(skip_default_condition),
MYSQL_SYSVAR(skip_parallel_search),
MYSQL_SYSVAR(direct_order_limit),
MYSQL_SYSVAR(read_only_mode),
#ifdef HA_CAN_BULK_ACCESS
@ -3138,6 +3427,9 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(udf_ds_use_real_table),
#endif
MYSQL_SYSVAR(general_log),
MYSQL_SYSVAR(index_hint_pushdown),
MYSQL_SYSVAR(max_connections),
MYSQL_SYSVAR(conn_wait_timeout),
MYSQL_SYSVAR(log_result_errors),
MYSQL_SYSVAR(log_result_error_with_sql),
MYSQL_SYSVAR(version),
@ -3147,6 +3439,10 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(delete_all_rows_type),
MYSQL_SYSVAR(bka_table_name_type),
MYSQL_SYSVAR(connect_error_interval),
#ifndef WITHOUT_SPIDER_BG_SEARCH
MYSQL_SYSVAR(table_sts_thread_count),
MYSQL_SYSVAR(table_crd_thread_count),
#endif
NULL
};

View file

@ -1,4 +1,4 @@
/* 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 */
my_bool spider_param_support_xa();
my_bool spider_param_connect_mutex();
@ -41,6 +41,9 @@ uint spider_param_internal_xa_snapshot(
uint spider_param_force_commit(
THD *thd
);
uint spider_param_xa_register_mode(
THD *thd
);
longlong spider_param_internal_offset(
THD *thd,
longlong internal_offset
@ -349,6 +352,10 @@ int spider_param_skip_default_condition(
THD *thd,
int skip_default_condition
);
int spider_param_skip_parallel_search(
THD *thd,
int skip_parallel_search
);
longlong spider_param_direct_order_limit(
THD *thd,
longlong direct_order_limit
@ -370,6 +377,11 @@ int spider_param_udf_ds_use_real_table(
);
#endif
my_bool spider_param_general_log();
my_bool spider_param_index_hint_pushdown(
THD *thd
);
uint spider_param_max_connections();
uint spider_param_conn_wait_timeout();
uint spider_param_log_result_errors();
uint spider_param_log_result_error_with_sql();
uint spider_param_internal_xa_id_type(
@ -388,3 +400,19 @@ int spider_param_bka_table_name_type(
THD *thd,
int bka_table_name_type
);
int spider_param_store_last_sts(
int store_last_sts
);
int spider_param_store_last_crd(
int store_last_crd
);
int spider_param_load_sts_at_startup(
int load_sts_at_startup
);
int spider_param_load_crd_at_startup(
int load_crd_at_startup
);
#ifndef WITHOUT_SPIDER_BG_SEARCH
uint spider_param_table_sts_thread_count();
uint spider_param_table_crd_thread_count();
#endif

View file

@ -1,4 +1,4 @@
/* 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>
@ -82,6 +82,8 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list(
spider_string *str,
uint conv_name_length,
int link_idx,
char *static_link_id,
uint static_link_id_length,
uint32 server_id,
bool need_lock,
int *error_num
@ -140,7 +142,8 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list(
spider_release_ping_table_mon_list_loop(mutex_hash, table_mon_list);
if (!(table_mon_list = spider_get_ping_table_tgt(thd, str->c_ptr(),
conv_name_length, link_idx, server_id, str, need_lock, error_num)))
conv_name_length, link_idx, static_link_id, static_link_id_length,
server_id, str, need_lock, error_num)))
{
pthread_mutex_unlock(&spider_udf_table_mon_mutexes[mutex_hash]);
goto error;
@ -228,14 +231,14 @@ void spider_release_ping_table_mon_list_loop(
DBUG_VOID_RETURN;
}
void spider_release_ping_table_mon_list(
int spider_release_ping_table_mon_list(
const char *conv_name,
uint conv_name_length,
int link_idx
) {
uint mutex_hash;
SPIDER_TABLE_MON_LIST *table_mon_list;
char link_idx_str[SPIDER_SQL_INT_LEN];
char link_idx_str[SPIDER_CONNECT_INFO_MAX_LEN + 1];
int link_idx_str_length;
DBUG_ENTER("spider_release_ping_table_mon_list");
DBUG_PRINT("info", ("spider conv_name=%s", conv_name));
@ -243,14 +246,14 @@ void spider_release_ping_table_mon_list(
DBUG_PRINT("info", ("spider link_idx=%d", link_idx));
link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d",
link_idx));
#if defined(_MSC_VER) || defined(__SUNPRO_CC)
spider_string conv_name_str(conv_name_length + link_idx_str_length + 1);
conv_name_str.set_charset(system_charset_info);
#else
char buf[conv_name_length + link_idx_str_length + 1];
char *buf = (char *) my_alloca(conv_name_length + link_idx_str_length + 1);
if (!buf)
{
my_error(HA_ERR_OUT_OF_MEM, MYF(0));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
spider_string conv_name_str(buf, conv_name_length + link_idx_str_length + 1,
system_charset_info);
#endif
conv_name_str.init_calc_mem(134);
conv_name_str.length(0);
conv_name_str.q_append(conv_name, conv_name_length);
@ -276,7 +279,8 @@ void spider_release_ping_table_mon_list(
#endif
spider_release_ping_table_mon_list_loop(mutex_hash, table_mon_list);
pthread_mutex_unlock(&spider_udf_table_mon_mutexes[mutex_hash]);
DBUG_VOID_RETURN;
my_afree(buf);
DBUG_RETURN(0);
}
int spider_get_ping_table_mon(
@ -315,6 +319,28 @@ int spider_get_ping_table_mon(
my_error(error_num, MYF(0));
goto error;
}
if (table_mon_list->share->static_link_ids[0])
{
spider_store_tables_name(table_link_mon, name, name_length);
spider_store_tables_link_idx_str(table_link_mon,
table_mon_list->share->static_link_ids[0],
table_mon_list->share->static_link_ids_lengths[0]);
if (!(error_num = spider_ping_table_cache_compare(table_link_mon, mem_root)))
goto create_table_mon;
if (error_num == HA_ERR_OUT_OF_MEM)
goto error;
if ((tmp_ptr = strstr(name, "#P#")))
{
*tmp_ptr = '\0';
spider_store_tables_name(table_link_mon, name, strlen(name));
*tmp_ptr = '#';
if (!(error_num = spider_ping_table_cache_compare(table_link_mon,
mem_root)))
goto create_table_mon;
if (error_num == HA_ERR_OUT_OF_MEM)
goto error;
}
}
spider_store_tables_name(table_link_mon, name, name_length);
spider_store_tables_link_idx(table_link_mon, link_idx);
if (!(error_num = spider_ping_table_cache_compare(table_link_mon, mem_root)))
@ -364,6 +390,7 @@ create_table_mon:
tmp_connect_info_length, tmp_long, tmp_longlong);
tmp_share->link_statuses[0] = -1;
table_mon->share = tmp_share;
table_mon->parent = table_mon_list;
if (table_mon_prev)
table_mon_prev->next = table_mon;
else
@ -442,6 +469,8 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt(
char *name,
uint name_length,
int link_idx,
char *static_link_id,
uint static_link_id_length,
uint32 server_id,
spider_string *str,
bool need_lock,
@ -498,9 +527,29 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt(
goto error;
}
spider_store_tables_name(table_tables, name, name_length);
spider_store_tables_link_idx(table_tables, link_idx);
if (static_link_id)
{
spider_store_tables_static_link_id(table_tables,
static_link_id, static_link_id_length);
if (
(*error_num = spider_get_sys_table_by_idx(table_tables, table_key, 2,
SPIDER_SYS_TABLES_UIDX1_COL_CNT)) ||
(*error_num = spider_get_sys_tables_link_idx(
table_tables, &link_idx, &mem_root))
) {
table_tables->file->print_error(*error_num, MYF(0));
goto error;
}
} else {
spider_store_tables_link_idx(table_tables, link_idx);
if (
(*error_num = spider_check_sys_table(table_tables, table_key))
) {
table_tables->file->print_error(*error_num, MYF(0));
goto error;
}
}
if (
(*error_num = spider_check_sys_table(table_tables, table_key)) ||
(*error_num = spider_get_sys_tables_connect_info(
table_tables, tmp_share, 0, &mem_root)) ||
(*error_num = spider_get_sys_tables_link_status(
@ -650,6 +699,165 @@ error:
DBUG_RETURN(NULL);
}
int spider_get_ping_table_gtid_pos(
SPIDER_TRX *trx,
THD *thd,
spider_string *str,
uint conv_name_length,
int failed_link_idx,
uint32 server_id,
bool need_lock,
spider_string *tmp_str
) {
int error_num, source_link_idx, need_mon;
char table_key[MAX_KEY_LENGTH];
TABLE *table_tables, *table_gtid_pos;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup_tables;
Open_tables_state open_tables_backup_gtid_pos;
#else
Open_tables_backup open_tables_backup_tables;
Open_tables_backup open_tables_backup_gtid_pos;
#endif
MEM_ROOT mem_root;
long link_status;
long monitoring_binlog_pos_at_failing;
SPIDER_TABLE_MON_LIST *table_mon_list;
SPIDER_CONN *ping_conn = NULL;
char *static_link_id;
uint static_link_id_length;
DBUG_ENTER("spider_get_ping_table_gtid_pos");
/*
select * from
mysql.spider_tables
where
db_name = setted db_name and
table_name = setted table_name
*/
if (
!(table_tables = spider_open_sys_table(
thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup_tables,
need_lock, &error_num))
)
goto error_open_table_tables;
if (
!(table_gtid_pos = spider_open_sys_table(
thd, SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_STR,
SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_LEN, TRUE,
&open_tables_backup_gtid_pos, need_lock, &error_num))
)
goto error_open_table_gtid_pos;
table_tables->use_all_columns();
table_gtid_pos->use_all_columns();
spider_store_tables_name(table_tables, str->ptr(), conv_name_length);
spider_store_tables_name(table_gtid_pos, str->ptr(), conv_name_length);
spider_store_binlog_pos_failed_link_idx(table_gtid_pos, failed_link_idx);
if ((error_num = spider_get_sys_table_by_idx(table_tables, table_key, 0,
SPIDER_SYS_TABLES_PK_COL_CNT - 1)))
{
if (error_num == HA_ERR_KEY_NOT_FOUND || error_num == HA_ERR_END_OF_FILE)
{
error_num = 0;
}
goto error_get_sys_table_by_idx;
}
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
do {
if (
(error_num = spider_get_sys_tables_link_status(table_tables,
&link_status, &mem_root)) ||
(error_num = spider_get_sys_tables_static_link_id(table_tables,
&static_link_id, &static_link_id_length, &mem_root)) ||
(error_num = spider_get_sys_tables_monitoring_binlog_pos_at_failing(
table_tables, &monitoring_binlog_pos_at_failing, &mem_root))
) {
goto error_get_sys_tables_link_status;
}
if (link_status == 1 && monitoring_binlog_pos_at_failing > 0)
{
if ((error_num = spider_get_sys_tables_link_idx(table_tables,
&source_link_idx, &mem_root)))
{
goto error_get_sys_tables_link_idx;
}
if (
(table_mon_list = spider_get_ping_table_mon_list(
trx,
thd,
str,
conv_name_length,
source_link_idx,
static_link_id,
static_link_id_length,
server_id,
need_lock,
&error_num
))
) {
SPIDER_DB_RESULT *res1 = NULL;
SPIDER_DB_RESULT *res2 = NULL;
if (
(ping_conn = spider_get_ping_table_tgt_conn(trx,
table_mon_list->share, &error_num
)) &&
!(error_num = ping_conn->db_conn->show_master_status(
trx, table_mon_list->share, 0, &need_mon, table_gtid_pos, tmp_str,
monitoring_binlog_pos_at_failing == 1 ? 0 : 1, &res1, &res2))
) {
spider_store_binlog_pos_source_link_idx(
table_gtid_pos, source_link_idx);
spider_insert_sys_table(table_gtid_pos);
}
if (res1)
{
res1->free_result();
delete res1;
}
if (res2)
{
res2->free_result();
delete res2;
}
spider_free_ping_table_mon_list(table_mon_list);
}
}
error_num = spider_sys_index_next_same(table_tables, table_key);
} while (error_num == 0);
free_root(&mem_root, MYF(0));
if ((error_num = spider_sys_index_end(table_tables)))
{
goto error_sys_index_end;
}
spider_close_sys_table(thd, table_gtid_pos, &open_tables_backup_gtid_pos,
need_lock);
spider_close_sys_table(thd, table_tables, &open_tables_backup_tables,
need_lock);
DBUG_RETURN(0);
error_get_sys_tables_link_idx:
error_get_sys_tables_link_status:
free_root(&mem_root, MYF(0));
spider_sys_index_end(table_tables);
error_sys_index_end:
error_get_sys_table_by_idx:
spider_close_sys_table(thd, table_gtid_pos, &open_tables_backup_gtid_pos,
need_lock);
error_open_table_gtid_pos:
spider_close_sys_table(thd, table_tables, &open_tables_backup_tables,
need_lock);
error_open_table_tables:
DBUG_RETURN(error_num);
}
int spider_init_ping_table_mon_cache(
THD *thd,
MEM_ROOT *mem_root,
@ -820,7 +1028,7 @@ long long spider_ping_table_body(
) {
int error_num = 0, link_idx, flags, full_mon_count, current_mon_count,
success_count, fault_count, tmp_error_num = 0;
uint32 first_sid;
uint32 first_sid, server_id;
longlong limit, tmp_sid = -1;
SPIDER_MON_TABLE_RESULT *mon_table_result =
(SPIDER_MON_TABLE_RESULT *) initid->ptr;
@ -831,15 +1039,24 @@ long long spider_ping_table_body(
SPIDER_TABLE_MON_LIST *table_mon_list;
SPIDER_TABLE_MON *table_mon;
char buf[MAX_FIELD_WIDTH];
char buf[MAX_FIELD_WIDTH], buf2[MAX_FIELD_WIDTH];
spider_string conv_name(buf, sizeof(buf), system_charset_info);
spider_string tmp_str(buf2, sizeof(buf2), system_charset_info);
int conv_name_length;
char link_idx_str[SPIDER_SQL_INT_LEN];
char link_idx_str[SPIDER_CONNECT_INFO_MAX_LEN + 1];
int link_idx_str_length;
bool get_lock = FALSE;
char *static_link_id = NULL;
int static_link_id_length = 0;
bool get_lock = FALSE, status_changed_to_ng = FALSE;
DBUG_ENTER("spider_ping_table_body");
conv_name.init_calc_mem(135);
tmp_str.init_calc_mem(247);
conv_name.length(0);
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002
server_id = global_system_variables.server_id;
#else
server_id = thd->server_id;
#endif
if (
thd->open_tables != 0 ||
thd->handler_tables_hash.records != 0 ||
@ -905,26 +1122,52 @@ long long spider_ping_table_body(
if (
args->lengths[0] > SPIDER_CONNECT_INFO_MAX_LEN
) {
my_printf_error(ER_SPIDER_UDF_PING_TABLE_PARAM_TOO_LONG_NUM,
ER_SPIDER_UDF_PING_TABLE_PARAM_TOO_LONG_STR, MYF(0));
my_printf_error(ER_SPIDER_UDF_PARAM_TOO_LONG_NUM,
ER_SPIDER_UDF_PARAM_TOO_LONG_STR, MYF(0), "table name");
goto error;
}
if (
args->lengths[0] == 0
) {
my_printf_error(ER_SPIDER_UDF_PING_TABLE_PARAM_REQIRED_NUM,
ER_SPIDER_UDF_PING_TABLE_PARAM_REQIRED_STR, MYF(0));
my_printf_error(ER_SPIDER_UDF_PARAM_REQIRED_NUM,
ER_SPIDER_UDF_PARAM_REQIRED_STR, MYF(0), "table name");
goto error;
}
link_idx = (int) (args->args[1] ? *((longlong *) args->args[1]) : 0);
if (args->arg_type[1] == STRING_RESULT)
{
if (
!args->args[1]
) {
my_printf_error(ER_SPIDER_UDF_PARAM_REQIRED_NUM,
ER_SPIDER_UDF_PARAM_REQIRED_STR, MYF(0), "link id");
goto error;
}
if (
args->lengths[1] > SPIDER_CONNECT_INFO_MAX_LEN
) {
my_printf_error(ER_SPIDER_UDF_PARAM_TOO_LONG_NUM,
ER_SPIDER_UDF_PARAM_TOO_LONG_STR, MYF(0), "link id");
goto error;
}
link_idx_str_length = args->lengths[1];
memcpy(link_idx_str, args->args[1], link_idx_str_length + 1);
if (link_idx_str[0] >= '0' && link_idx_str[0] <= '9')
{
link_idx = atoi(link_idx_str);
} else {
link_idx = -1;
static_link_id = link_idx_str;
static_link_id_length = link_idx_str_length;
}
} else {
link_idx = (int) (args->args[1] ? *((longlong *) args->args[1]) : 0);
link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d",
link_idx));
}
flags = (int) (args->args[2] ? *((longlong *) args->args[2]) : 0);
limit = args->args[3] ? *((longlong *) args->args[3]) : 0;
where_clause = args->args[4] ? args->args[4] : (char *) "";
link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d",
link_idx));
if (conv_name.append(args->args[0], args->lengths[0],
trx->thd->variables.character_set_client))
{
@ -940,14 +1183,10 @@ long long spider_ping_table_body(
conv_name.q_append(link_idx_str, link_idx_str_length + 1);
conv_name.length(conv_name.length() - 1);
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002
if (!(table_mon_list = spider_get_ping_table_mon_list(trx, trx->thd,
&conv_name, conv_name_length, link_idx, global_system_variables.server_id,
TRUE, &error_num)))
#else
if (!(table_mon_list = spider_get_ping_table_mon_list(trx, trx->thd,
&conv_name, conv_name_length, link_idx, thd->server_id, TRUE, &error_num)))
#endif
&conv_name, conv_name_length, link_idx,
static_link_id, static_link_id_length,
server_id, TRUE, &error_num)))
goto error;
if (table_mon_list->mon_status == SPIDER_LINK_MON_NG)
@ -974,11 +1213,7 @@ long long spider_ping_table_body(
goto error_with_free_table_mon_list;
}
} else {
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002
first_sid = global_system_variables.server_id;
#else
first_sid = thd->server_id;
#endif
first_sid = server_id;
full_mon_count = table_mon_list->list_size;
current_mon_count = 1;
}
@ -1040,11 +1275,21 @@ long long spider_ping_table_body(
SPIDER_LINK_STATUS_NG, TRUE);
spider_sys_log_tables_link_failed(trx->thd,
conv_name.c_ptr(), conv_name_length, link_idx, TRUE);
status_changed_to_ng = TRUE;
}
/*
pthread_mutex_unlock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
if (status_changed_to_ng)
{
bool is_error = trx->thd->is_error();
spider_get_ping_table_gtid_pos(trx, trx->thd,
&conv_name, conv_name_length, link_idx, server_id, TRUE,
&tmp_str);
if (!is_error && trx->thd->is_error())
trx->thd->clear_error();
}
}
goto end;
}
@ -1103,11 +1348,21 @@ long long spider_ping_table_body(
SPIDER_LINK_STATUS_NG, TRUE);
spider_sys_log_tables_link_failed(trx->thd,
conv_name.c_ptr(), conv_name_length, link_idx, TRUE);
status_changed_to_ng = TRUE;
}
/*
pthread_mutex_unlock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
if (status_changed_to_ng)
{
bool is_error = trx->thd->is_error();
spider_get_ping_table_gtid_pos(trx, trx->thd,
&conv_name, conv_name_length, link_idx, server_id, TRUE,
&tmp_str);
if (!is_error && trx->thd->is_error())
trx->thd->clear_error();
}
}
} else if (
(flags & SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES) &&
@ -1156,11 +1411,21 @@ long long spider_ping_table_body(
SPIDER_LINK_STATUS_NG, TRUE);
spider_sys_log_tables_link_failed(trx->thd,
conv_name.c_ptr(), conv_name_length, link_idx, TRUE);
status_changed_to_ng = TRUE;
}
/*
pthread_mutex_unlock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
if (status_changed_to_ng)
{
bool is_error = trx->thd->is_error();
spider_get_ping_table_gtid_pos(trx, trx->thd,
&conv_name, conv_name_length, link_idx, server_id, TRUE,
&tmp_str);
if (!is_error && trx->thd->is_error())
trx->thd->clear_error();
}
}
table_mon_list->last_receptor_result =
mon_table_result->result_status;
@ -1216,7 +1481,6 @@ my_bool spider_ping_table_init_body(
goto error;
}
if (
args->arg_type[1] != INT_RESULT ||
args->arg_type[2] != INT_RESULT ||
args->arg_type[3] != INT_RESULT ||
args->arg_type[5] != INT_RESULT ||
@ -1225,10 +1489,18 @@ my_bool spider_ping_table_init_body(
args->arg_type[8] != INT_RESULT ||
args->arg_type[9] != INT_RESULT
) {
strcpy(message, "spider_ping_table() requires integer 2nd, 3rd, 4,6,7,8,"
strcpy(message, "spider_ping_table() requires integer 3rd, 4,6,7,8,"
"9th and 10th argument");
goto error;
}
if (
args->arg_type[1] != INT_RESULT &&
args->arg_type[1] != STRING_RESULT
) {
strcpy(message, "spider_ping_table() requires string or integer for "
"2nd argument");
goto error;
}
if (!(trx = spider_get_trx(thd, TRUE, &error_num)))
{
@ -1312,6 +1584,7 @@ int spider_ping_table_mon_from_table(
SPIDER_TRX *trx,
THD *thd,
SPIDER_SHARE *share,
int base_link_idx,
uint32 server_id,
char *conv_name,
uint conv_name_length,
@ -1333,7 +1606,7 @@ int spider_ping_table_mon_from_table(
SPIDER_MON_TABLE_RESULT mon_table_result;
SPIDER_CONN *mon_conn;
TABLE_SHARE *table_share = share->table_share;
char link_idx_str[SPIDER_SQL_INT_LEN];
char link_idx_str[SPIDER_CONNECT_INFO_MAX_LEN + 1];
int link_idx_str_length;
uint sql_command = thd_sql_command(thd);
DBUG_ENTER("spider_ping_table_mon_from_table");
@ -1362,19 +1635,24 @@ int spider_ping_table_mon_from_table(
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
}
link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d",
link_idx));
#if defined(_MSC_VER) || defined(__SUNPRO_CC)
spider_string conv_name_str(conv_name_length + link_idx_str_length + 1);
conv_name_str.set_charset(system_charset_info);
*((char *)(conv_name_str.ptr() + conv_name_length + link_idx_str_length)) =
'\0';
#else
char buf[conv_name_length + link_idx_str_length + 1];
if (share->static_link_ids[link_idx])
{
memcpy(link_idx_str, share->static_link_ids[link_idx],
share->static_link_ids_lengths[link_idx] + 1);
link_idx_str_length = share->static_link_ids_lengths[link_idx];
} else {
link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d",
link_idx));
}
char *buf = (char *) my_alloca(conv_name_length + link_idx_str_length + 1);
if (!buf)
{
my_error(HA_ERR_OUT_OF_MEM, MYF(0));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
buf[conv_name_length + link_idx_str_length] = '\0';
spider_string conv_name_str(buf, conv_name_length + link_idx_str_length + 1,
system_charset_info);
#endif
conv_name_str.init_calc_mem(136);
conv_name_str.length(0);
conv_name_str.q_append(conv_name, conv_name_length);
@ -1392,9 +1670,14 @@ int spider_ping_table_mon_from_table(
flags |= SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES;
if (!(table_mon_list = spider_get_ping_table_mon_list(trx, thd,
&conv_name_str, conv_name_length, link_idx, server_id, need_lock,
&error_num)))
&conv_name_str, conv_name_length, link_idx,
share->static_link_ids[link_idx],
share->static_link_ids_lengths[link_idx],
server_id, need_lock, &error_num)))
{
my_afree(buf);
goto end;
}
if (table_mon_list->mon_status == SPIDER_LINK_MON_NG)
{
@ -1408,6 +1691,7 @@ int spider_ping_table_mon_from_table(
ER_SPIDER_LINK_MON_NG_STR, MYF(0),
table_mon_list->share->tgt_dbs[0],
table_mon_list->share->tgt_table_names[0]);
my_afree(buf);
goto end_with_free_table_mon_list;
}
@ -1580,6 +1864,7 @@ int spider_ping_table_mon_from_table(
pthread_mutex_unlock(&table_mon_list->caller_mutex);
}
my_afree(buf);
end_with_free_table_mon_list:
spider_free_ping_table_mon_list(table_mon_list);
end:

View file

@ -1,4 +1,4 @@
/* 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 */
SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list(
SPIDER_TRX *trx,
@ -19,6 +19,8 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list(
spider_string *str,
uint conv_name_length,
int link_idx,
char *static_link_id,
uint static_link_id_length,
uint32 server_id,
bool need_lock,
int *error_num
@ -33,7 +35,7 @@ void spider_release_ping_table_mon_list_loop(
SPIDER_TABLE_MON_LIST *table_mon_list
);
void spider_release_ping_table_mon_list(
int spider_release_ping_table_mon_list(
const char *conv_name,
uint conv_name_length,
int link_idx
@ -55,6 +57,8 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt(
char *name,
uint name_length,
int link_idx,
char *static_link_id,
uint static_link_id_length,
uint32 server_id,
spider_string *str,
bool need_lock,
@ -67,6 +71,17 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn(
int *error_num
);
int spider_get_ping_table_gtid_pos(
SPIDER_TRX *trx,
THD *thd,
spider_string *str,
uint conv_name_length,
int failed_link_idx,
uint32 server_id,
bool need_lock,
spider_string *tmp_str
);
int spider_init_ping_table_mon_cache(
THD *thd,
MEM_ROOT *mem_root,
@ -90,6 +105,7 @@ int spider_ping_table_mon_from_table(
SPIDER_TRX *trx,
THD *thd,
SPIDER_SHARE *share,
int base_link_idx,
uint32 server_id,
char *conv_name,
uint conv_name_length,

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2008-2014 Kentoku Shiba
/* Copyright (C) 2008-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
@ -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_SYS_XA_TABLE_NAME_STR "spider_xa"
#define SPIDER_SYS_XA_TABLE_NAME_LEN (sizeof(SPIDER_SYS_XA_TABLE_NAME_STR) - 1)
@ -25,6 +25,12 @@
#define SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN (sizeof(SPIDER_SYS_LINK_FAILED_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_XA_FAILED_TABLE_NAME_STR "spider_xa_failed_log"
#define SPIDER_SYS_XA_FAILED_TABLE_NAME_LEN (sizeof(SPIDER_SYS_XA_FAILED_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_STR "spider_table_position_for_recovery"
#define SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_LEN (sizeof(SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_TABLE_STS_TABLE_NAME_STR "spider_table_sts"
#define SPIDER_SYS_TABLE_STS_TABLE_NAME_LEN (sizeof(SPIDER_SYS_TABLE_STS_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_TABLE_CRD_TABLE_NAME_STR "spider_table_crd"
#define SPIDER_SYS_TABLE_CRD_TABLE_NAME_LEN (sizeof(SPIDER_SYS_TABLE_CRD_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_XA_PREPARED_STR "PREPARED"
#define SPIDER_SYS_XA_NOT_YET_STR "NOT YET"
@ -36,14 +42,20 @@
#define SPIDER_SYS_XA_IDX1_COL_CNT 1
#define SPIDER_SYS_XA_MEMBER_COL_CNT 18
#define SPIDER_SYS_XA_MEMBER_PK_COL_CNT 6
#define SPIDER_SYS_TABLES_COL_CNT 22
#define SPIDER_SYS_TABLES_PK_COL_CNT 2
#define SPIDER_SYS_TABLES_COL_CNT 25
#define SPIDER_SYS_TABLES_PK_COL_CNT 3
#define SPIDER_SYS_TABLES_IDX1_COL_CNT 1
#define SPIDER_SYS_TABLES_UIDX1_COL_CNT 3
#define SPIDER_SYS_LINK_MON_TABLE_COL_CNT 19
#define SPIDER_SYS_POS_FOR_RECOVERY_TABLE_COL_CNT 7
#define SPIDER_SYS_TABLE_STS_COL_CNT 10
#define SPIDER_SYS_TABLE_STS_PK_COL_CNT 2
#define SPIDER_SYS_TABLE_CRD_COL_CNT 4
#define SPIDER_SYS_TABLE_CRD_PK_COL_CNT 3
#define SPIDER_SYS_LINK_MON_TABLE_DB_NAME_SIZE 64
#define SPIDER_SYS_LINK_MON_TABLE_TABLE_NAME_SIZE 64
#define SPIDER_SYS_LINK_MON_TABLE_LINK_ID_SIZE 10
#define SPIDER_SYS_LINK_MON_TABLE_LINK_ID_SIZE 64
class SPIDER_MON_KEY: public SPIDER_SORT
{
@ -139,6 +151,11 @@ int spider_check_sys_table_with_find_flag(
enum ha_rkey_function find_flag
);
int spider_check_sys_table_for_update_all_columns(
TABLE *table,
char *table_key
);
int spider_get_sys_table_by_idx(
TABLE *table,
char *table_key,
@ -212,6 +229,12 @@ void spider_store_tables_link_idx_str(
const uint link_idx_length
);
void spider_store_tables_static_link_id(
TABLE *table,
const char *static_link_id,
const uint static_link_id_length
);
void spider_store_tables_priority(
TABLE *table,
longlong priority
@ -233,6 +256,50 @@ void spider_store_link_chk_server_id(
uint32 server_id
);
void spider_store_binlog_pos_failed_link_idx(
TABLE *table,
int failed_link_idx
);
void spider_store_binlog_pos_source_link_idx(
TABLE *table,
int source_link_idx
);
void spider_store_binlog_pos_binlog_file(
TABLE *table,
const char *file_name,
int file_name_length,
const char *position,
int position_length,
CHARSET_INFO *binlog_pos_cs
);
void spider_store_binlog_pos_gtid(
TABLE *table,
const char *gtid,
int gtid_length,
CHARSET_INFO *binlog_pos_cs
);
void spider_store_table_sts_info(
TABLE *table,
ulonglong *data_file_length,
ulonglong *max_data_file_length,
ulonglong *index_file_length,
ha_rows *records,
ulong *mean_rec_length,
time_t *check_time,
time_t *create_time,
time_t *update_time
);
void spider_store_table_crd_info(
TABLE *table,
uint *seq,
longlong *cardinality
);
int spider_insert_xa(
TABLE *table,
XID *xid,
@ -250,6 +317,32 @@ int spider_insert_tables(
SPIDER_SHARE *share
);
int spider_insert_sys_table(
TABLE *table
);
int spider_insert_or_update_table_sts(
TABLE *table,
const char *name,
uint name_length,
ulonglong *data_file_length,
ulonglong *max_data_file_length,
ulonglong *index_file_length,
ha_rows *records,
ulong *mean_rec_length,
time_t *check_time,
time_t *create_time,
time_t *update_time
);
int spider_insert_or_update_table_crd(
TABLE *table,
const char *name,
uint name_length,
longlong *cardinality,
uint number_of_keys
);
int spider_log_tables_link_failed(
TABLE *table,
char *name,
@ -309,6 +402,18 @@ int spider_delete_tables(
int *old_link_count
);
int spider_delete_table_sts(
TABLE *table,
const char *name,
uint name_length
);
int spider_delete_table_crd(
TABLE *table,
const char *name,
uint name_length
);
int spider_get_sys_xid(
TABLE *table,
XID *xid,
@ -345,6 +450,12 @@ int spider_get_sys_tables_connect_info(
MEM_ROOT *mem_root
);
int spider_get_sys_tables_monitoring_binlog_pos_at_failing(
TABLE *table,
long *monitoring_binlog_pos_at_failing,
MEM_ROOT *mem_root
);
int spider_get_sys_tables_link_status(
TABLE *table,
SPIDER_SHARE *share,
@ -352,12 +463,43 @@ int spider_get_sys_tables_link_status(
MEM_ROOT *mem_root
);
int spider_get_sys_tables_link_status(
TABLE *table,
long *link_status,
MEM_ROOT *mem_root
);
int spider_get_sys_tables_link_idx(
TABLE *table,
int *link_idx,
MEM_ROOT *mem_root
);
int spider_get_sys_tables_static_link_id(
TABLE *table,
char **static_link_id,
uint *static_link_id_length,
MEM_ROOT *mem_root
);
void spider_get_sys_table_sts_info(
TABLE *table,
ulonglong *data_file_length,
ulonglong *max_data_file_length,
ulonglong *index_file_length,
ha_rows *records,
ulong *mean_rec_length,
time_t *check_time,
time_t *create_time,
time_t *update_time
);
void spider_get_sys_table_crd_info(
TABLE *table,
longlong *cardinality,
uint number_of_keys
);
int spider_sys_update_tables_link_status(
THD *thd,
char *name,
@ -409,6 +551,68 @@ int spider_get_link_statuses(
MEM_ROOT *mem_root
);
int spider_sys_insert_or_update_table_sts(
THD *thd,
const char *name,
uint name_length,
ulonglong *data_file_length,
ulonglong *max_data_file_length,
ulonglong *index_file_length,
ha_rows *records,
ulong *mean_rec_length,
time_t *check_time,
time_t *create_time,
time_t *update_time,
bool need_lock
);
int spider_sys_insert_or_update_table_crd(
THD *thd,
const char *name,
uint name_length,
longlong *cardinality,
uint number_of_keys,
bool need_lock
);
int spider_sys_delete_table_sts(
THD *thd,
const char *name,
uint name_length,
bool need_lock
);
int spider_sys_delete_table_crd(
THD *thd,
const char *name,
uint name_length,
bool need_lock
);
int spider_sys_get_table_sts(
THD *thd,
const char *name,
uint name_length,
ulonglong *data_file_length,
ulonglong *max_data_file_length,
ulonglong *index_file_length,
ha_rows *records,
ulong *mean_rec_length,
time_t *check_time,
time_t *create_time,
time_t *update_time,
bool need_lock
);
int spider_sys_get_table_crd(
THD *thd,
const char *name,
uint name_length,
longlong *cardinality,
uint number_of_keys,
bool need_lock
);
int spider_sys_replace(
TABLE *table,
bool *modified_non_trans_table

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* 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 */
uchar *spider_tbl_get_key(
SPIDER_SHARE *share,
@ -389,11 +389,20 @@ void spider_free_tmp_dbton_handler(
TABLE_LIST *spider_get_parent_table_list(
ha_spider *spider
);
List<Index_hint> *spider_get_index_hints(
ha_spider *spider
);
st_select_lex *spider_get_select_lex(
ha_spider *spider
);
void spider_get_select_limit_from_select_lex(
st_select_lex *select_lex,
longlong *select_limit,
longlong *offset_limit
);
void spider_get_select_limit(
ha_spider *spider,
st_select_lex **select_lex,
@ -421,6 +430,10 @@ bool spider_check_direct_order_limit(
ha_spider *spider
);
int spider_set_direct_limit_offset(
ha_spider* spider
);
bool spider_check_index_merge(
TABLE *table,
st_select_lex *select_lex
@ -454,3 +467,55 @@ int spider_discover_table_structure(
HA_CREATE_INFO *info
);
#endif
#ifndef WITHOUT_SPIDER_BG_SEARCH
int spider_create_spider_object_for_share(
SPIDER_TRX *trx,
SPIDER_SHARE *share,
ha_spider **spider
);
void spider_free_spider_object_for_share(
ha_spider **spider
);
int spider_create_sts_threads(
SPIDER_THREAD *spider_thread
);
void spider_free_sts_threads(
SPIDER_THREAD *spider_thread
);
int spider_create_crd_threads(
SPIDER_THREAD *spider_thread
);
void spider_free_crd_threads(
SPIDER_THREAD *spider_thread
);
void *spider_table_bg_sts_action(
void *arg
);
void *spider_table_bg_crd_action(
void *arg
);
void spider_table_add_share_to_sts_thread(
SPIDER_SHARE *share
);
void spider_table_add_share_to_crd_thread(
SPIDER_SHARE *share
);
void spider_table_remove_share_from_sts_thread(
SPIDER_SHARE *share
);
void spider_table_remove_share_from_crd_thread(
SPIDER_SHARE *share
);
#endif

View file

@ -1,4 +1,4 @@
/* 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 MYSQL_SERVER 1
#include <my_global.h>
@ -504,6 +504,7 @@ int spider_create_trx_alter_table(
char **tmp_tgt_ssl_keys;
char **tmp_tgt_default_files;
char **tmp_tgt_default_groups;
char **tmp_static_link_ids;
uint *tmp_server_names_lengths;
uint *tmp_tgt_table_names_lengths;
uint *tmp_tgt_dbs_lengths;
@ -519,8 +520,10 @@ int spider_create_trx_alter_table(
uint *tmp_tgt_ssl_keys_lengths;
uint *tmp_tgt_default_files_lengths;
uint *tmp_tgt_default_groups_lengths;
uint *tmp_static_link_ids_lengths;
long *tmp_tgt_ports;
long *tmp_tgt_ssl_vscs;
long *tmp_monitoring_binlog_pos_at_failing;
long *tmp_link_statuses;
char *tmp_server_names_char;
char *tmp_tgt_table_names_char;
@ -537,6 +540,7 @@ int spider_create_trx_alter_table(
char *tmp_tgt_ssl_keys_char;
char *tmp_tgt_default_files_char;
char *tmp_tgt_default_groups_char;
char *tmp_static_link_ids_char;
uint old_elements;
DBUG_ENTER("spider_create_trx_alter_table");
@ -562,6 +566,7 @@ int spider_create_trx_alter_table(
&tmp_tgt_ssl_keys, sizeof(char *) * share->all_link_count,
&tmp_tgt_default_files, sizeof(char *) * share->all_link_count,
&tmp_tgt_default_groups, sizeof(char *) * share->all_link_count,
&tmp_static_link_ids, sizeof(char *) * share->all_link_count,
&tmp_server_names_lengths, sizeof(uint) * share->all_link_count,
&tmp_tgt_table_names_lengths, sizeof(uint) * share->all_link_count,
@ -578,9 +583,12 @@ int spider_create_trx_alter_table(
&tmp_tgt_ssl_keys_lengths, sizeof(uint) * share->all_link_count,
&tmp_tgt_default_files_lengths, sizeof(uint) * share->all_link_count,
&tmp_tgt_default_groups_lengths, sizeof(uint) * share->all_link_count,
&tmp_static_link_ids_lengths, sizeof(uint) * share->all_link_count,
&tmp_tgt_ports, sizeof(long) * share->all_link_count,
&tmp_tgt_ssl_vscs, sizeof(long) * share->all_link_count,
&tmp_monitoring_binlog_pos_at_failing,
sizeof(long) * share->all_link_count,
&tmp_link_statuses, sizeof(long) * share->all_link_count,
&tmp_server_names_char, sizeof(char) *
@ -613,6 +621,8 @@ int spider_create_trx_alter_table(
(share_alter->tmp_tgt_default_files_charlen + 1),
&tmp_tgt_default_groups_char, sizeof(char) *
(share_alter->tmp_tgt_default_groups_charlen + 1),
&tmp_static_link_ids_char, sizeof(char) *
(share_alter->tmp_static_link_ids_charlen + 1),
NullS))
) {
error_num = HA_ERR_OUT_OF_MEM;
@ -646,9 +656,12 @@ int spider_create_trx_alter_table(
alter_table->tmp_tgt_ssl_keys = tmp_tgt_ssl_keys;
alter_table->tmp_tgt_default_files = tmp_tgt_default_files;
alter_table->tmp_tgt_default_groups = tmp_tgt_default_groups;
alter_table->tmp_static_link_ids = tmp_static_link_ids;
alter_table->tmp_tgt_ports = tmp_tgt_ports;
alter_table->tmp_tgt_ssl_vscs = tmp_tgt_ssl_vscs;
alter_table->tmp_monitoring_binlog_pos_at_failing =
tmp_monitoring_binlog_pos_at_failing;
alter_table->tmp_link_statuses = tmp_link_statuses;
alter_table->tmp_server_names_lengths = tmp_server_names_lengths;
@ -666,6 +679,7 @@ int spider_create_trx_alter_table(
alter_table->tmp_tgt_ssl_keys_lengths = tmp_tgt_ssl_keys_lengths;
alter_table->tmp_tgt_default_files_lengths = tmp_tgt_default_files_lengths;
alter_table->tmp_tgt_default_groups_lengths = tmp_tgt_default_groups_lengths;
alter_table->tmp_static_link_ids_lengths = tmp_static_link_ids_lengths;
for(roop_count = 0; roop_count < (int) share->all_link_count; roop_count++)
{
@ -764,12 +778,25 @@ int spider_create_trx_alter_table(
sizeof(char) * share_alter->tmp_tgt_default_groups_lengths[roop_count]);
tmp_tgt_default_groups_char +=
share_alter->tmp_tgt_default_groups_lengths[roop_count] + 1;
if (share_alter->tmp_static_link_ids[roop_count])
{
tmp_static_link_ids[roop_count] = tmp_static_link_ids_char;
memcpy(tmp_static_link_ids_char,
share_alter->tmp_static_link_ids[roop_count],
sizeof(char) * share_alter->tmp_static_link_ids_lengths[roop_count]);
tmp_static_link_ids_char +=
share_alter->tmp_static_link_ids_lengths[roop_count] + 1;
}
}
memcpy(tmp_tgt_ports, share_alter->tmp_tgt_ports,
sizeof(long) * share->all_link_count);
memcpy(tmp_tgt_ssl_vscs, share_alter->tmp_tgt_ssl_vscs,
sizeof(long) * share->all_link_count);
memcpy(tmp_monitoring_binlog_pos_at_failing,
share_alter->tmp_monitoring_binlog_pos_at_failing,
sizeof(long) * share->all_link_count);
memcpy(tmp_link_statuses, share_alter->tmp_link_statuses,
sizeof(long) * share->all_link_count);
@ -805,6 +832,9 @@ int spider_create_trx_alter_table(
memcpy(tmp_tgt_default_groups_lengths,
share_alter->tmp_tgt_default_groups_lengths,
sizeof(uint) * share->all_link_count);
memcpy(tmp_static_link_ids_lengths,
share_alter->tmp_static_link_ids_lengths,
sizeof(uint) * share->all_link_count);
alter_table->tmp_server_names_length =
share_alter->tmp_server_names_length;
@ -836,10 +866,14 @@ int spider_create_trx_alter_table(
share_alter->tmp_tgt_default_files_length;
alter_table->tmp_tgt_default_groups_length =
share_alter->tmp_tgt_default_groups_length;
alter_table->tmp_static_link_ids_length =
share_alter->tmp_static_link_ids_length;
alter_table->tmp_tgt_ports_length =
share_alter->tmp_tgt_ports_length;
alter_table->tmp_tgt_ssl_vscs_length =
share_alter->tmp_tgt_ssl_vscs_length;
alter_table->tmp_monitoring_binlog_pos_at_failing_length =
share_alter->tmp_monitoring_binlog_pos_at_failing_length;
alter_table->tmp_link_statuses_length =
share_alter->tmp_link_statuses_length;
@ -1035,9 +1069,21 @@ bool spider_cmp_trx_alter_table(
cmp2->tmp_tgt_default_groups[roop_count])
)
) ||
(
cmp1->tmp_static_link_ids[roop_count] !=
cmp2->tmp_static_link_ids[roop_count] &&
(
!cmp1->tmp_static_link_ids[roop_count] ||
!cmp2->tmp_static_link_ids[roop_count] ||
strcmp(cmp1->tmp_static_link_ids[roop_count],
cmp2->tmp_static_link_ids[roop_count])
)
) ||
cmp1->tmp_tgt_ports[roop_count] != cmp2->tmp_tgt_ports[roop_count] ||
cmp1->tmp_tgt_ssl_vscs[roop_count] !=
cmp2->tmp_tgt_ssl_vscs[roop_count] ||
cmp1->tmp_monitoring_binlog_pos_at_failing[roop_count] !=
cmp2->tmp_monitoring_binlog_pos_at_failing[roop_count] ||
cmp1->tmp_link_statuses[roop_count] !=
cmp2->tmp_link_statuses[roop_count]
)
@ -1660,7 +1706,8 @@ int spider_xa_lock(
#ifdef SPIDER_XID_USES_xid_cache_iterate
if (xid_cache_insert(thd, xid_state))
{
error_num = my_errno;
error_num = (spider_stmt_da_sql_errno(thd) == ER_XAER_DUPID ?
ER_SPIDER_XA_LOCKED_NUM : HA_ERR_OUT_OF_MEM);
goto error;
}
#else
@ -1906,6 +1953,8 @@ int spider_internal_start_trx(
}
trx->trx_start = TRUE;
trx->trx_xa_prepared = FALSE;
trx->updated_in_this_trx = FALSE;
DBUG_PRINT("info",("spider trx->updated_in_this_trx=FALSE"));
}
DBUG_PRINT("info",("spider sync_autocommit = %d", sync_autocommit));
@ -1984,7 +2033,7 @@ int spider_internal_xa_commit(
TABLE *table_xa,
TABLE *table_xa_member
) {
int error_num, tmp_error_num;
int error_num = 0, tmp_error_num;
char xa_key[MAX_KEY_LENGTH];
SPIDER_CONN *conn;
uint force_commit = spider_param_force_commit(thd);
@ -1998,72 +2047,75 @@ int spider_internal_xa_commit(
bool table_xa_member_opened = FALSE;
DBUG_ENTER("spider_internal_xa_commit");
/*
select
status
from
mysql.spider_xa
where
format_id = xid->format_id and
gtrid_length = xid->gtrid_length and
data = xid->data
*/
if (
!(table_xa = spider_open_sys_table(
thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
TRUE, &open_tables_backup, TRUE, &error_num))
)
goto error_open_table;
table_xa_opened = TRUE;
spider_store_xa_pk(table_xa, &trx->xid);
if (
(error_num = spider_check_sys_table(table_xa, xa_key))
) {
if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE)
{
table_xa->file->print_error(error_num, MYF(0));
if (trx->updated_in_this_trx || spider_param_xa_register_mode(thd) == 0)
{
/*
select
status
from
mysql.spider_xa
where
format_id = xid->format_id and
gtrid_length = xid->gtrid_length and
data = xid->data
*/
if (
!(table_xa = spider_open_sys_table(
thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
TRUE, &open_tables_backup, TRUE, &error_num))
)
goto error_open_table;
table_xa_opened = TRUE;
spider_store_xa_pk(table_xa, &trx->xid);
if (
(error_num = spider_check_sys_table(table_xa, xa_key))
) {
if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE)
{
table_xa->file->print_error(error_num, MYF(0));
goto error;
}
my_message(ER_SPIDER_XA_NOT_EXISTS_NUM, ER_SPIDER_XA_NOT_EXISTS_STR,
MYF(0));
error_num = ER_SPIDER_XA_NOT_EXISTS_NUM;
goto error;
}
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
if (
force_commit != 2 &&
(error_num = spider_check_sys_xa_status(
table_xa,
SPIDER_SYS_XA_PREPARED_STR,
SPIDER_SYS_XA_COMMIT_STR,
NULL,
ER_SPIDER_XA_NOT_PREPARED_NUM,
&mem_root))
) {
free_root(&mem_root, MYF(0));
if (error_num == ER_SPIDER_XA_NOT_PREPARED_NUM)
my_message(error_num, ER_SPIDER_XA_NOT_PREPARED_STR, MYF(0));
goto error;
}
my_message(ER_SPIDER_XA_NOT_EXISTS_NUM, ER_SPIDER_XA_NOT_EXISTS_STR,
MYF(0));
error_num = ER_SPIDER_XA_NOT_EXISTS_NUM;
goto error;
}
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
if (
force_commit != 2 &&
(error_num = spider_check_sys_xa_status(
table_xa,
SPIDER_SYS_XA_PREPARED_STR,
SPIDER_SYS_XA_COMMIT_STR,
NULL,
ER_SPIDER_XA_NOT_PREPARED_NUM,
&mem_root))
) {
free_root(&mem_root, MYF(0));
if (error_num == ER_SPIDER_XA_NOT_PREPARED_NUM)
my_message(error_num, ER_SPIDER_XA_NOT_PREPARED_STR, MYF(0));
goto error;
}
free_root(&mem_root, MYF(0));
/*
update
mysql.spider_xa
set
status = 'COMMIT'
where
format_id = trx->xid.format_id and
gtrid_length = trx->xid.gtrid_length and
data = trx->xid.data
*/
if (
(error_num = spider_update_xa(
table_xa, &trx->xid, SPIDER_SYS_XA_COMMIT_STR))
)
goto error;
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
table_xa_opened = FALSE;
/*
update
mysql.spider_xa
set
status = 'COMMIT'
where
format_id = trx->xid.format_id and
gtrid_length = trx->xid.gtrid_length and
data = trx->xid.data
*/
if (
(error_num = spider_update_xa(
table_xa, &trx->xid, SPIDER_SYS_XA_COMMIT_STR))
)
goto error;
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
table_xa_opened = FALSE;
}
SPIDER_BACKUP_DASTATUS;
if ((conn = spider_tree_first(trx->join_trx_top)))
@ -2101,46 +2153,49 @@ int spider_internal_xa_commit(
if (error_num)
goto error_in_commit;
/*
delete from
mysql.spider_xa_member
where
format_id = xid->format_id and
gtrid_length = xid->gtrid_length and
data = xid->data
*/
if (
!(table_xa_member = spider_open_sys_table(
thd, SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR,
SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE,
&error_num))
)
goto error_open_table;
table_xa_member_opened = TRUE;
if ((error_num = spider_delete_xa_member(table_xa_member, &trx->xid)))
goto error;
spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE);
table_xa_member_opened = FALSE;
if (trx->updated_in_this_trx || spider_param_xa_register_mode(thd) == 0)
{
/*
delete from
mysql.spider_xa_member
where
format_id = xid->format_id and
gtrid_length = xid->gtrid_length and
data = xid->data
*/
if (
!(table_xa_member = spider_open_sys_table(
thd, SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR,
SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE,
&error_num))
)
goto error_open_table;
table_xa_member_opened = TRUE;
if ((error_num = spider_delete_xa_member(table_xa_member, &trx->xid)))
goto error;
spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE);
table_xa_member_opened = FALSE;
/*
delete from
mysql.spider_xa
where
format_id = xid->format_id and
gtrid_length = xid->gtrid_length and
data = xid->data
*/
if (
!(table_xa = spider_open_sys_table(
thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
TRUE, &open_tables_backup, TRUE, &error_num))
)
goto error_open_table;
table_xa_opened = TRUE;
if ((error_num = spider_delete_xa(table_xa, &trx->xid)))
goto error;
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
table_xa_opened = FALSE;
/*
delete from
mysql.spider_xa
where
format_id = xid->format_id and
gtrid_length = xid->gtrid_length and
data = xid->data
*/
if (
!(table_xa = spider_open_sys_table(
thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
TRUE, &open_tables_backup, TRUE, &error_num))
)
goto error_open_table;
table_xa_opened = TRUE;
if ((error_num = spider_delete_xa(table_xa, &trx->xid)))
goto error;
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
table_xa_opened = FALSE;
}
spider_xa_unlock(&trx->internal_xid_state);
trx->internal_xid_state.xa_state = XA_NOTR;
DBUG_RETURN(0);
@ -2177,8 +2232,13 @@ int spider_internal_xa_rollback(
bool table_xa_member_opened = FALSE;
DBUG_ENTER("spider_internal_xa_rollback");
if (trx->trx_xa_prepared)
{
if (
trx->trx_xa_prepared &&
(
trx->updated_in_this_trx ||
spider_param_xa_register_mode(thd) == 0
)
) {
/*
select
status
@ -2327,7 +2387,11 @@ int spider_internal_xa_rollback(
if (
trx->trx_xa_prepared &&
!server_lost
!server_lost &&
(
trx->updated_in_this_trx ||
spider_param_xa_register_mode(thd) == 0
)
) {
/*
delete from
@ -2404,35 +2468,38 @@ int spider_internal_xa_prepare(
bool table_xa_opened = FALSE;
bool table_xa_member_opened = FALSE;
DBUG_ENTER("spider_internal_xa_prepare");
/*
insert into mysql.spider_xa
(format_id, gtrid_length, bqual_length, data, status) values
(trx->xid.format_id, trx->xid.gtrid_length, trx->xid.bqual_length,
trx->xid.data, 'NOT YET')
*/
if (
!(table_xa = spider_open_sys_table(
thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
TRUE, &open_tables_backup, TRUE, &error_num))
)
goto error_open_table;
table_xa_opened = TRUE;
if (
(error_num = spider_insert_xa(
table_xa, &trx->xid, SPIDER_SYS_XA_NOT_YET_STR))
)
goto error;
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
table_xa_opened = FALSE;
if (trx->updated_in_this_trx || spider_param_xa_register_mode(thd) == 0)
{
/*
insert into mysql.spider_xa
(format_id, gtrid_length, bqual_length, data, status) values
(trx->xid.format_id, trx->xid.gtrid_length, trx->xid.bqual_length,
trx->xid.data, 'NOT YET')
*/
if (
!(table_xa = spider_open_sys_table(
thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
TRUE, &open_tables_backup, TRUE, &error_num))
)
goto error_open_table;
table_xa_opened = TRUE;
if (
(error_num = spider_insert_xa(
table_xa, &trx->xid, SPIDER_SYS_XA_NOT_YET_STR))
)
goto error;
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
table_xa_opened = FALSE;
if (
!(table_xa_member = spider_open_sys_table(
thd, SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR,
SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE,
&error_num))
)
goto error_open_table;
table_xa_member_opened = TRUE;
if (
!(table_xa_member = spider_open_sys_table(
thd, SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR,
SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE,
&error_num))
)
goto error_open_table;
table_xa_member_opened = TRUE;
}
SPIDER_BACKUP_DASTATUS;
if ((conn = spider_tree_first(trx->join_trx_top)))
{
@ -2458,26 +2525,29 @@ int spider_internal_xa_prepare(
}
conn->join_trx = 0;
} else {
/*
insert into mysql.spider_xa_member
(format_id, gtrid_length, bqual_length, data,
scheme, host, port, socket, username, password) values
(trx->xid.format_id, trx->xid.gtrid_length,
trx->xid.bqual_length, trx->xid.data,
conn->tgt_wrapper,
conn->tgt_host,
conn->tgt_port,
conn->tgt_socket,
conn->tgt_username,
conn->tgt_password)
*/
if (
(error_num = spider_insert_xa_member(
table_xa_member, &trx->xid, conn))
) {
SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM;
if (error_num)
goto error;
if (trx->updated_in_this_trx || spider_param_xa_register_mode(thd) == 0)
{
/*
insert into mysql.spider_xa_member
(format_id, gtrid_length, bqual_length, data,
scheme, host, port, socket, username, password) values
(trx->xid.format_id, trx->xid.gtrid_length,
trx->xid.bqual_length, trx->xid.data,
conn->tgt_wrapper,
conn->tgt_host,
conn->tgt_port,
conn->tgt_socket,
conn->tgt_username,
conn->tgt_password)
*/
if (
(error_num = spider_insert_xa_member(
table_xa_member, &trx->xid, conn))
) {
SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM;
if (error_num)
goto error;
}
}
if ((error_num = spider_db_xa_end(conn, &trx->xid)))
@ -2515,33 +2585,36 @@ int spider_internal_xa_prepare(
trx->join_trx_top = NULL;
*/
}
spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE);
table_xa_member_opened = FALSE;
if (trx->updated_in_this_trx || spider_param_xa_register_mode(thd) == 0)
{
spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE);
table_xa_member_opened = FALSE;
/*
update
mysql.spider_xa
set
status = 'PREPARED'
where
format_id = trx->xid.format_id and
gtrid_length = trx->xid.gtrid_length and
data = trx->xid.data
*/
if (
!(table_xa = spider_open_sys_table(
thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
TRUE, &open_tables_backup, TRUE, &error_num))
)
goto error_open_table;
table_xa_opened = TRUE;
if (
(error_num = spider_update_xa(
table_xa, &trx->xid, SPIDER_SYS_XA_PREPARED_STR))
)
goto error;
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
table_xa_opened = FALSE;
/*
update
mysql.spider_xa
set
status = 'PREPARED'
where
format_id = trx->xid.format_id and
gtrid_length = trx->xid.gtrid_length and
data = trx->xid.data
*/
if (
!(table_xa = spider_open_sys_table(
thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN,
TRUE, &open_tables_backup, TRUE, &error_num))
)
goto error_open_table;
table_xa_opened = TRUE;
if (
(error_num = spider_update_xa(
table_xa, &trx->xid, SPIDER_SYS_XA_PREPARED_STR))
)
goto error;
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
table_xa_opened = FALSE;
}
if (internal_xa)
trx->internal_xid_state.xa_state = XA_PREPARED;
DBUG_RETURN(0);
@ -2685,8 +2758,8 @@ int spider_initinal_xa_recover(
FALSE, open_tables_backup, TRUE, &error_num))
)
goto error_open_table;
init_read_record(read_record, thd, table_xa, NULL, NULL, TRUE, FALSE,
FALSE);
SPIDER_init_read_record(read_record, thd, table_xa, NULL, NULL, TRUE,
FALSE, FALSE);
}
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
while ((!(read_record->read_record())) && cnt < (int) len)
@ -3371,7 +3444,9 @@ int spider_commit(
}
}
trx->trx_start = FALSE;
trx->updated_in_this_trx = FALSE;
DBUG_PRINT("info",("spider trx->trx_start=FALSE"));
DBUG_PRINT("info",("spider trx->updated_in_this_trx=FALSE"));
}
spider_reuse_trx_ha(trx);
spider_free_trx_conn(trx, FALSE);
@ -3442,7 +3517,9 @@ int spider_rollback(
}
}
trx->trx_start = FALSE;
trx->updated_in_this_trx = FALSE;
DBUG_PRINT("info",("spider trx->trx_start=FALSE"));
DBUG_PRINT("info",("spider trx->updated_in_this_trx=FALSE"));
}
spider_reuse_trx_ha(trx);
spider_free_trx_conn(trx, FALSE);
@ -3713,21 +3790,14 @@ int spider_check_trx_and_get_conn(
{
TABLE *table = spider->get_table();
TABLE_SHARE *table_share = table->s;
#if defined(_MSC_VER) || defined(__SUNPRO_CC)
char *db, *table_name;
if (!(db = (char *)
spider_bulk_malloc(spider_current_trx, 57, MYF(MY_WME),
&db, table_share->db.length + 1,
&table_name, table_share->table_name.length + 1,
NullS))
) {
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
char *db = (char *) my_alloca(
table_share->db.length + 1 + table_share->table_name.length + 1);
if (!db)
{
my_error(HA_ERR_OUT_OF_MEM, MYF(0));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
#else
char db[table_share->db.length + 1],
table_name[table_share->table_name.length + 1];
#endif
char *table_name = db + table_share->db.length + 1;
memcpy(db, table_share->db.str, table_share->db.length);
db[table_share->db.length] = '\0';
memcpy(table_name, table_share->table_name.str,
@ -3735,10 +3805,12 @@ int spider_check_trx_and_get_conn(
table_name[table_share->table_name.length] = '\0';
my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM,
ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name);
#if defined(_MSC_VER) || defined(__SUNPRO_CC)
spider_free(trx, db, MYF(MY_WME));
#endif
my_afree(db);
DBUG_RETURN(ER_SPIDER_ALL_LINKS_FAILED_NUM);
} else if (search_link_idx == -2)
{
my_error(HA_ERR_OUT_OF_MEM, MYF(0));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
spider->search_link_idx = search_link_idx;
spider->search_link_query_id = thd->query_id;
@ -3804,6 +3876,7 @@ int spider_check_trx_and_get_conn(
trx,
trx->thd,
share,
roop_count,
(uint32) share->monitoring_sid[roop_count],
share->table_name,
share->table_name_length,
@ -3846,6 +3919,7 @@ int spider_check_trx_and_get_conn(
trx,
trx->thd,
share,
roop_count,
(uint32) share->monitoring_sid[roop_count],
share->table_name,
share->table_name_length,
@ -3872,21 +3946,14 @@ int spider_check_trx_and_get_conn(
{
TABLE *table = spider->get_table();
TABLE_SHARE *table_share = table->s;
#if defined(_MSC_VER) || defined(__SUNPRO_CC)
char *db, *table_name;
if (!(db = (char *)
spider_bulk_malloc(spider_current_trx, 57, MYF(MY_WME),
&db, table_share->db.length + 1,
&table_name, table_share->table_name.length + 1,
NullS))
) {
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
char *db = (char *) my_alloca(
table_share->db.length + 1 + table_share->table_name.length + 1);
if (!db)
{
my_error(HA_ERR_OUT_OF_MEM, MYF(0));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
#else
char db[table_share->db.length + 1],
table_name[table_share->table_name.length + 1];
#endif
char *table_name = db + table_share->db.length + 1;
memcpy(db, table_share->db.str, table_share->db.length);
db[table_share->db.length] = '\0';
memcpy(table_name, table_share->table_name.str,
@ -3894,9 +3961,7 @@ int spider_check_trx_and_get_conn(
table_name[table_share->table_name.length] = '\0';
my_printf_error(ER_SPIDER_LINK_MON_JUST_NG_NUM,
ER_SPIDER_LINK_MON_JUST_NG_STR, MYF(0), db, table_name);
#if defined(_MSC_VER) || defined(__SUNPRO_CC)
spider_free(trx, db, MYF(MY_WME));
#endif
my_afree(db);
DBUG_RETURN(ER_SPIDER_LINK_MON_JUST_NG_NUM);
}
} else {
@ -3950,6 +4015,7 @@ int spider_check_trx_and_get_conn(
trx,
trx->thd,
share,
roop_count,
(uint32) share->monitoring_sid[roop_count],
share->table_name,
share->table_name_length,
@ -3993,6 +4059,7 @@ int spider_check_trx_and_get_conn(
trx,
trx->thd,
share,
roop_count,
(uint32) share->monitoring_sid[roop_count],
share->table_name,
share->table_name_length,
@ -4018,21 +4085,14 @@ int spider_check_trx_and_get_conn(
{
TABLE *table = spider->get_table();
TABLE_SHARE *table_share = table->s;
#if defined(_MSC_VER) || defined(__SUNPRO_CC)
char *db, *table_name;
if (!(db = (char *)
spider_bulk_malloc(spider_current_trx, 57, MYF(MY_WME),
&db, table_share->db.length + 1,
&table_name, table_share->table_name.length + 1,
NullS))
) {
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
char *db = (char *) my_alloca(
table_share->db.length + 1 + table_share->table_name.length + 1);
if (!db)
{
my_error(HA_ERR_OUT_OF_MEM, MYF(0));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
#else
char db[table_share->db.length + 1],
table_name[table_share->table_name.length + 1];
#endif
char *table_name = db + table_share->db.length + 1;
memcpy(db, table_share->db.str, table_share->db.length);
db[table_share->db.length] = '\0';
memcpy(table_name, table_share->table_name.str,
@ -4040,9 +4100,7 @@ int spider_check_trx_and_get_conn(
table_name[table_share->table_name.length] = '\0';
my_printf_error(ER_SPIDER_LINK_MON_JUST_NG_NUM,
ER_SPIDER_LINK_MON_JUST_NG_STR, MYF(0), db, table_name);
#if defined(_MSC_VER) || defined(__SUNPRO_CC)
spider_free(trx, db, MYF(MY_WME));
#endif
my_afree(db);
DBUG_RETURN(ER_SPIDER_LINK_MON_JUST_NG_NUM);
}
}
@ -4057,7 +4115,7 @@ THD *spider_create_tmp_thd()
{
THD *thd;
DBUG_ENTER("spider_create_tmp_thd");
if (!(thd = new THD(0)))
if (!(thd = SPIDER_new_THD((my_thread_id) 0)))
DBUG_RETURN(NULL);
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
thd->killed = NOT_KILLED;
@ -4068,6 +4126,10 @@ THD *spider_create_tmp_thd()
thd->locked_tables = FALSE;
#endif
thd->proc_info = "";
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100200
#else
thd->thread_id = thd->variables.pseudo_thread_id = 0;
#endif
thd->thread_stack = (char*) &thd;
if (thd->store_globals())
DBUG_RETURN(NULL);

View file

@ -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_free_trx_conn(
SPIDER_TRX *trx,

View file

@ -11,10 +11,11 @@
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>
#include "spd_environ.h"
#include "mysql.h"
#include "spd_udf.h"

View file

@ -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 */
long long spider_direct_sql_body(
UDF_INIT *initid,