Commit 0f870914 authored by Yuchen Pei's avatar Yuchen Pei

Merge branch '10.5' into 10.6

parents b70d8fbf cf816263
......@@ -8666,6 +8666,10 @@ ha_rows ha_spider::records_in_range(
dbton_id = share->sql_dbton_ids[search_link_idx];
dbton_hdl = dbton_handler[dbton_id];
crd_mode = dbton_hdl->crd_mode_exchange(crd_mode);
/* This assertion simply demonstrates that the
static_key_cardinality field is unused. It will be deprecated
(MDEV-28861) and removed (MDEV-31146). */
DBUG_ASSERT(share->static_key_cardinality[inx] == -1);
if (crd_mode == 1 || crd_mode == 2)
{
DBUG_PRINT("info", ("spider static_key_cardinality[%u]=%lld", inx,
......
#
# MDEV-28856 Spider: Implement more engine-defined options
#
for master_1
for child2
for child3
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
# testing monitoring_*
INSERT INTO mysql.spider_link_mon_servers
(db_name, table_name, link_id, sid, server) VALUES
('test', 't1', '0', 1, 'srv');
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_kind "2"';
/* 1 */ insert into t1 values (42);
ERROR HY000: Table 'test.t2' get a problem
/* 2 */ insert into t1 values (42);
ERROR HY000: All links of 'test.t1' are failed
create table t2 (c int);
/* 3 */ insert into t1 values (42);
ERROR HY000: All links of 'test.t1' are failed
drop table t1, t2;
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_bg_kind "2",
monitoring_bg_interval "500000"';
/* 4 */ insert into t1 values (42);
ERROR 42S02: Table 'test.t2' doesn't exist
drop table t1;
# testing query_cache_sync
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", query_cache_sync "3"';
create table t2 (c int);
/* 5 */ insert into t1 values (42);
select sql_cache * from t1;
c
42
select sql_no_cache * from t1;
c
42
drop table t1, t2;
# testing tgt_pk_names
create table t2 (c int);
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 6 */ insert ignore into t1 values (42), (42);
select * from t1;
c
42
42
drop table t1, t2;
create table t2 (c int, primary key (c));
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 7 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1022 Can't write; duplicate key in table 't1'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, primary key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 8 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1062 Duplicate entry '42' for key 'PRIMARY'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, primary key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
/* 9 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1022 Can't write; duplicate key in table 't1'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, unique key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
/* 9.1 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1062 Duplicate entry '42' for key 'PRIMARY'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, unique key (c));
create table t1 (c int, key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "f"';
/* 10 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1062 Duplicate entry '42' for key 'c'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, primary key (c));
create table t1 (c int, key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
/* 11 */ insert ignore into t1 values (42), (42);
Warnings:
Warning 1022 Can't write; duplicate key in table 't1'
select * from t1;
c
42
drop table t1, t2;
create table t2 (c int, d int, unique key (c), unique key (d));
create table t1 (c int, d int, key (c), key (d)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
/* 12 */ insert ignore into t1 values (42, 43), (43, 43);
Warnings:
Warning 1062 Duplicate entry '43' for key 'd'
select * from t1;
c d
42 43
drop table t1, t2;
# Testing index hint
create table t2 (c int, d int, primary key (c), key (d));
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c` int(11) NOT NULL,
`d` int(11) DEFAULT NULL,
PRIMARY KEY (`c`),
KEY `d` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
create table t1 (c int, d int, primary key (c), key (d)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f d"';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(11) NOT NULL,
`d` int(11) DEFAULT NULL,
PRIMARY KEY (`c`),
KEY `d` (`d`)
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f d"'
/* 13 */ insert into t1 values (42, 23), (37, 93);
select max(d) from t1;
max(d)
93
drop table t1, t2;
create table t2 (c int, d int, e int, primary key (c), key (d), unique key (e));
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c` int(11) NOT NULL,
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
PRIMARY KEY (`c`),
UNIQUE KEY `e` (`e`),
KEY `d` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
create table t1 (c int, d int, e int, primary key (c), key (d), unique key (e)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f PRIMARY", idx001 "u d", idx002 "ig e"';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(11) NOT NULL,
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
PRIMARY KEY (`c`),
UNIQUE KEY `e` (`e`),
KEY `d` (`d`)
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f PRIMARY", idx001 "u d", idx002 "ig e"'
/* 14 */ insert into t1 values (42, 23, 89), (37, 93, 47);
select max(d) from t1;
max(d)
93
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3
#
# end of test mdev_28856
#
......@@ -14,6 +14,7 @@ create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", "srv" "srv",TABL
ERROR HY000: The connect info '"srv" "srv",TABLE "t2"' is invalid
create table t1 (c int) ENGINE=Spider CONNECTION='WRAPPER "mysql", srv \'srv\',TABLE "t2", password "say \\"hello\\ world!\\""';
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3
......@@ -10,6 +10,7 @@ CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE
SELECT TRIM(BOTH ' ' FROM c) FROM ts ORDER BY c;
TRIM(BOTH ' ' FROM c)
drop table t, ts;
drop server srv;
for master_1
for child2
for child3
......@@ -16,6 +16,7 @@ ERROR HY000: An infinite loop is detected when opening table test.t0
select * from t2;
ERROR HY000: An infinite loop is detected when opening table test.t0
drop table t0, t1, t2;
drop server srv_self_reference_multi;
for master_1
for child2
for child3
--echo #
--echo # MDEV-28856 Spider: Implement more engine-defined options
--echo #
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
# This test covers some table params under consideration for inclusion
# in the engine-defined options to be implemented in MDEV-28856.
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
--echo # testing monitoring_*
INSERT INTO mysql.spider_link_mon_servers
(db_name, table_name, link_id, sid, server) VALUES
('test', 't1', '0', 1, 'srv');
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_kind "2"';
--error 12511
/* 1 */ insert into t1 values (42);
--error 12514
/* 2 */ insert into t1 values (42);
create table t2 (c int);
# Even though the table is available now, we still get "all links
# failed" error
--error 12514
/* 3 */ insert into t1 values (42);
drop table t1, t2;
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", monitoring_bg_kind "2",
monitoring_bg_interval "500000"';
# The monitoring thread was killed before it could ping the remote
# table, so the error is not 12511 or 12514
--error ER_NO_SUCH_TABLE
/* 4 */ insert into t1 values (42);
drop table t1;
--echo # testing query_cache_sync
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", query_cache_sync "3"';
create table t2 (c int);
/* 5 */ insert into t1 values (42);
select sql_cache * from t1;
select sql_no_cache * from t1;
drop table t1, t2;
--echo # testing tgt_pk_names
# can insert duplicates...
create table t2 (c int);
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 6 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# pk_names not used because no key declared in t1, 1022
create table t2 (c int, primary key (c));
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 7 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# pk_name is the default "PRIMARY", 1062
create table t2 (c int, primary key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
/* 8 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# key name c does not match PRIMARY, 1022
create table t2 (c int, primary key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
/* 9 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# local primary key name c matches remote unique key name c, 1062 but
# warning says PRIMARY instead of c, because key->name is PRIMARY
# instead of c
create table t2 (c int, unique key (c));
create table t1 (c int, primary key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "c"';
/* 9.1 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# key name f does not match t2 key name, but it is not used any way
# because there's no primary key, 1062
create table t2 (c int, unique key (c));
create table t1 (c int, key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "f"';
/* 10 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# key name blah does not match t2 error key name PRIMARY, and the
# non-primary key-route does not return PRIMARY, 1022
create table t2 (c int, primary key (c));
create table t1 (c int, key (c)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
/* 11 */ insert ignore into t1 values (42), (42);
select * from t1;
drop table t1, t2;
# key name blah does not match t2 key name, but still 1062, because we
# go through the non-primary key route
create table t2 (c int, d int, unique key (c), unique key (d));
create table t1 (c int, d int, key (c), key (d)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", pk_name "blah"';
/* 12 */ insert ignore into t1 values (42, 43), (43, 43);
select * from t1;
drop table t1, t2;
--echo # Testing index hint
create table t2 (c int, d int, primary key (c), key (d));
show create table t2;
create table t1 (c int, d int, primary key (c), key (d)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f d"';
show create table t1;
/* 13 */ insert into t1 values (42, 23), (37, 93);
select max(d) from t1;
drop table t1, t2;
# multiple indices
create table t2 (c int, d int, e int, primary key (c), key (d), unique key (e));
show create table t2;
create table t1 (c int, d int, e int, primary key (c), key (d), unique key (e)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx000 "f PRIMARY", idx001 "u d", idx002 "ig e"';
show create table t1;
/* 14 */ insert into t1 values (42, 23, 89), (37, 93, 47);
select max(d) from t1;
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
--echo #
--echo # end of test mdev_28856
--echo #
......@@ -23,6 +23,7 @@ create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", "srv" "srv",TABL
create table t1 (c int) ENGINE=Spider CONNECTION='WRAPPER "mysql", srv \'srv\',TABLE "t2", password "say \\"hello\\ world!\\""';
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
......
......@@ -15,6 +15,7 @@ CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE
SELECT TRIM(BOTH ' ' FROM c) FROM ts ORDER BY c;
drop table t, ts;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
......
......@@ -21,6 +21,7 @@ select * from t1;
--error 12719
select * from t2;
drop table t0, t1, t2;
eval drop server $srv;
--disable_query_log
--disable_result_log
......
......@@ -2208,6 +2208,11 @@ void spider_conn_set_timeout_from_direct_sql(
DBUG_VOID_RETURN;
}
/**
Insert a connection to a binary tree ordered by priority
Starting from `top', find the correct spot for `conn' and insert it.
*/
void spider_tree_insert(
SPIDER_CONN *top,
SPIDER_CONN *conn
......@@ -2245,6 +2250,7 @@ void spider_tree_insert(
DBUG_VOID_RETURN;
}
/* Returns the connection with the smallest priority in a tree */
SPIDER_CONN *spider_tree_first(
SPIDER_CONN *top
) {
......@@ -2260,6 +2266,7 @@ SPIDER_CONN *spider_tree_first(
DBUG_RETURN(current);
}
/* Returns the connection with the biggest priority in a tree */
SPIDER_CONN *spider_tree_last(
SPIDER_CONN *top
) {
......@@ -2275,6 +2282,12 @@ SPIDER_CONN *spider_tree_last(
DBUG_RETURN(current);
}
/*
Returns the next connection
Find the connection in the tree with the smallest priority that is
bigger than that of the current connection.
*/
SPIDER_CONN *spider_tree_next(
SPIDER_CONN *current
) {
......
......@@ -74,21 +74,20 @@ int spider_udf_set_copy_tables_param_default(
DBUG_RETURN(0);
}
#define SPIDER_PARAM_STR_LEN(name) name ## _length
#define SPIDER_PARAM_STR(title_name, param_name) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!copy_tables->param_name) \
{ \
#define SPIDER_PARAM_LEN(name) name ## _length
#define SPIDER_PARAM_STR(title_name, param_name) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!copy_tables->param_name) \
{ \
if ((copy_tables->param_name = spider_create_string(parse.start_value, \
value_length))) \
copy_tables->SPIDER_PARAM_STR_LEN(param_name) = \
strlen(copy_tables->param_name); \
else { \
error_num= parse.fail(true); \
goto error; \
} \
copy_tables->SPIDER_PARAM_LEN(param_name) = strlen(copy_tables->param_name); \
else { \
error_num= parse.fail(true); \
goto error; \
} \
DBUG_PRINT("info",("spider " title_name "=%s", copy_tables->param_name)); \
} \
break; \
......
......@@ -58,12 +58,6 @@ extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE];
#define SPIDER_SQL_COALESCE_LEN (sizeof(SPIDER_SQL_COALESCE_STR) - 1)
#define SPIDER_SQL_HEX_STR "0x"
#define SPIDER_SQL_HEX_LEN (sizeof(SPIDER_SQL_HEX_STR) - 1)
#define SPIDER_SQL_SQL_FORCE_IDX_STR " force index("
#define SPIDER_SQL_SQL_FORCE_IDX_LEN (sizeof(SPIDER_SQL_SQL_FORCE_IDX_STR) - 1)
#define SPIDER_SQL_SQL_USE_IDX_STR " use index("
#define SPIDER_SQL_SQL_USE_IDX_LEN (sizeof(SPIDER_SQL_SQL_USE_IDX_STR) - 1)
#define SPIDER_SQL_SQL_IGNORE_IDX_STR " ignore index("
#define SPIDER_SQL_SQL_IGNORE_IDX_LEN (sizeof(SPIDER_SQL_SQL_IGNORE_IDX_STR) - 1)
#define SPIDER_SQL_SET_NAMES_STR "set names "
#define SPIDER_SQL_SET_NAMES_LEN sizeof(SPIDER_SQL_SET_NAMES_STR) - 1
......@@ -1624,34 +1618,37 @@ int spider_db_append_key_hint(
if (hint_str_len >= 2 &&
(hint_str[0] == 'f' || hint_str[0] == 'F') && hint_str[1] == ' '
) {
if (str->reserve(hint_str_len - 2 +
SPIDER_SQL_SQL_FORCE_IDX_LEN + SPIDER_SQL_CLOSE_PAREN_LEN))
if (str->reserve(
hint_str_len - 2 + SPIDER_SQL_INDEX_FORCE_LEN +
SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_CLOSE_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
hint_str += 2;
str->q_append(SPIDER_SQL_SQL_FORCE_IDX_STR, SPIDER_SQL_SQL_FORCE_IDX_LEN);
str->q_append(SPIDER_SQL_INDEX_FORCE_STR, SPIDER_SQL_INDEX_FORCE_LEN);
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
str->q_append(hint_str, hint_str_len - 2);
str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
} else if (hint_str_len >= 2 &&
(hint_str[0] == 'u' || hint_str[0] == 'U') && hint_str[1] == ' '
) {
if (str->reserve(hint_str_len - 2 +
SPIDER_SQL_SQL_USE_IDX_LEN + SPIDER_SQL_CLOSE_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
if (str->reserve(
hint_str_len - 2 + SPIDER_SQL_INDEX_USE_LEN +
SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_CLOSE_PAREN_LEN))
hint_str += 2;
str->q_append(SPIDER_SQL_SQL_USE_IDX_STR, SPIDER_SQL_SQL_USE_IDX_LEN);
str->q_append(SPIDER_SQL_INDEX_USE_STR, SPIDER_SQL_INDEX_USE_LEN);
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
str->q_append(hint_str, hint_str_len - 2);
str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
} else if (hint_str_len >= 3 &&
(hint_str[0] == 'i' || hint_str[0] == 'I') &&
(hint_str[1] == 'g' || hint_str[1] == 'G') && hint_str[2] == ' '
) {
if (str->reserve(hint_str_len - 3 +
SPIDER_SQL_SQL_IGNORE_IDX_LEN + SPIDER_SQL_CLOSE_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
if (str->reserve(
hint_str_len - 3 + SPIDER_SQL_INDEX_IGNORE_LEN +
SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_CLOSE_PAREN_LEN))
hint_str += 3;
str->q_append(
SPIDER_SQL_SQL_IGNORE_IDX_STR, SPIDER_SQL_SQL_IGNORE_IDX_LEN);
str->q_append(hint_str, hint_str_len - 3);
str->q_append(SPIDER_SQL_INDEX_IGNORE_STR, SPIDER_SQL_INDEX_IGNORE_LEN);
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
str->q_append(hint_str, hint_str_len - 2);
str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
} else if (str->reserve(hint_str_len + SPIDER_SQL_SPACE_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
......
......@@ -1075,20 +1075,20 @@ int spider_udf_direct_sql_get_server(
DBUG_RETURN(error_num);
}
#define SPIDER_PARAM_STR_LEN(name) name ## _length
#define SPIDER_PARAM_STR(title_name, param_name) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!direct_sql->param_name) \
{ \
#define SPIDER_PARAM_LEN(name) name ## _length
#define SPIDER_PARAM_STR(title_name, param_name) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!direct_sql->param_name) \
{ \
if ((direct_sql->param_name = spider_create_string(parse.start_value, \
value_length))) \
direct_sql->SPIDER_PARAM_STR_LEN(param_name) = strlen(direct_sql->param_name); \
else { \
error_num= parse.fail(true); \
goto error; \
} \
direct_sql->SPIDER_PARAM_LEN(param_name) = strlen(direct_sql->param_name); \
else { \
error_num= parse.fail(true); \
goto error; \
} \
DBUG_PRINT("info",("spider " title_name "=%s", direct_sql->param_name)); \
} \
break; \
......
......@@ -502,9 +502,18 @@ typedef struct st_spider_conn
THD *thd;
void *another_ha_first;
void *another_ha_last;
/* Exactly one of p_small and p_big is not null */
/* The parent node in the binary tree ordered by priority with a
smaller or equal priority */
st_spider_conn *p_small;
/* The parent node in the binary tree ordered by priority with a
bigger priority */
st_spider_conn *p_big;
/* The child node in the binary tree ordered by priority with a
smaller priority */
st_spider_conn *c_small;
/* The child node in the binary tree ordered by priority with a
bigger or equal priority */
st_spider_conn *c_big;
longlong priority;
bool server_lost;
......
......@@ -1690,42 +1690,42 @@ static int spider_set_ll_value(
DBUG_RETURN(error_num);
}
#define SPIDER_PARAM_STR_LEN(name) name ## _length
#define SPIDER_PARAM_STR(title_name, param_name) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!share->param_name) \
{ \
if ((share->param_name = spider_create_string(parse.start_value, \
value_length))) \
share->SPIDER_PARAM_STR_LEN(param_name) = strlen(share->param_name); \
else { \
error_num= parse.fail(true); \
goto error; \
} \
#define SPIDER_PARAM_LEN(name) name ## _length
#define SPIDER_PARAM_LENS(name) name ## _lengths
#define SPIDER_PARAM_CHARLEN(name) name ## _charlen
#define SPIDER_PARAM_STR(title_name, param_name) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!share->param_name) \
{ \
if ((share->param_name = spider_create_string(parse.start_value, \
value_length))) \
share->SPIDER_PARAM_LEN(param_name) = strlen(share->param_name); \
else { \
error_num= parse.fail(true); \
goto error; \
} \
DBUG_PRINT("info",("spider " title_name "=%s", share->param_name)); \
} \
break; \
}
#define SPIDER_PARAM_STR_LENS(name) name ## _lengths
#define SPIDER_PARAM_STR_CHARLEN(name) name ## _charlen
#define SPIDER_PARAM_STR_LIST(title_name, param_name) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info", ("spider " title_name " start")); \
if (!share->param_name) \
{ \
share->SPIDER_PARAM_STR_CHARLEN(param_name)= value_length; \
if ((error_num= spider_create_string_list( \
&share->param_name, \
&share->SPIDER_PARAM_STR_LENS(param_name), \
&share->SPIDER_PARAM_STR_LEN(param_name), \
parse.start_value, \
share->SPIDER_PARAM_STR_CHARLEN(param_name)))) \
goto error; \
} \
break; \
#define SPIDER_PARAM_STR_LIST(title_name, param_name) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info", ("spider " title_name " start")); \
if (!share->param_name) \
{ \
share->SPIDER_PARAM_CHARLEN(param_name)= value_length; \
if ((error_num= spider_create_string_list( \
&share->param_name, \
&share->SPIDER_PARAM_LENS(param_name), \
&share->SPIDER_PARAM_LEN(param_name), \
parse.start_value, \
share->SPIDER_PARAM_CHARLEN(param_name)))) \
goto error; \
} \
break; \
}
#define SPIDER_PARAM_HINT(title_name, param_name, check_length, max_size, append_method) \
if (!strncasecmp(parse.start_title, title_name, check_length)) \
......@@ -1782,41 +1782,39 @@ static int spider_set_ll_value(
} \
break; \
}
#define SPIDER_PARAM_LONG_LEN(name) name ## _length
#define SPIDER_PARAM_LONG_LIST_WITH_MAX(title_name, param_name, \
min_val, max_val) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!share->param_name) \
{ \
if ((error_num = spider_create_long_list( \
&share->param_name, \
&share->SPIDER_PARAM_LONG_LEN(param_name), \
parse.start_value, \
value_length, \
min_val, max_val))) \
goto error; \
} \
break; \
#define SPIDER_PARAM_LONG_LIST_WITH_MAX(title_name, param_name, \
min_val, max_val) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!share->param_name) \
{ \
if ((error_num = spider_create_long_list( \
&share->param_name, \
&share->SPIDER_PARAM_LEN(param_name), \
parse.start_value, \
value_length, \
min_val, max_val))) \
goto error; \
} \
break; \
}
#define SPIDER_PARAM_LONGLONG_LEN(name) name ## _length
#define SPIDER_PARAM_LONGLONG_LIST_WITH_MAX(title_name, param_name, \
min_val, max_val) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!share->param_name) \
{ \
if ((error_num = spider_create_longlong_list( \
&share->param_name, \
&share->SPIDER_PARAM_LONGLONG_LEN(param_name), \
parse.start_value, \
value_length, \
min_val, max_val))) \
goto error; \
} \
break; \
min_val, max_val) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
{ \
DBUG_PRINT("info",("spider " title_name " start")); \
if (!share->param_name) \
{ \
if ((error_num = spider_create_longlong_list( \
&share->param_name, \
&share->SPIDER_PARAM_LEN(param_name), \
parse.start_value, \
value_length, \
min_val, max_val))) \
goto error; \
} \
break; \
}
#define SPIDER_PARAM_INT_WITH_MAX(title_name, param_name, min_val, max_val) \
if (!strncasecmp(parse.start_title, title_name, title_length)) \
......@@ -1874,6 +1872,10 @@ static int spider_set_ll_value(
break; \
}
/**
Assign -1 to some `SPIDER_SHARE' numeric fields, to indicate they
have not been specified by the user yet.
*/
static void spider_minus_1(SPIDER_SHARE *share, TABLE_SHARE *table_share)
{
#ifndef WITHOUT_SPIDER_BG_SEARCH
......@@ -2241,6 +2243,7 @@ int spider_parse_connect_info(
connect_string = NULL;
}
/* Get the correct connect info for the current level. */
int error_num_1 = spider_get_connect_info(i, part_elem, sub_elem,
table_share, connect_string);
if (error_num_1 == 1)
......@@ -3351,7 +3354,7 @@ int spider_parse_connect_info(
{
if (
spider_dbton[roop_count2].wrapper &&
!strcmp(share->tgt_wrappers[roop_count],
!strcasecmp(share->tgt_wrappers[roop_count],
spider_dbton[roop_count2].wrapper)
) {
break;
......@@ -4247,7 +4250,7 @@ int spider_create_conn_keys(
spider_dbton[roop_count2].wrapper : "NULL"));
if (
spider_dbton[roop_count2].wrapper &&
!strcmp(share->tgt_wrappers[roop_count],
!strcasecmp(share->tgt_wrappers[roop_count],
spider_dbton[roop_count2].wrapper)
) {
spider_set_bit(share->dbton_bitmap, roop_count2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment