Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
3e206a51
Commit
3e206a51
authored
Dec 13, 2015
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'kentoku/10.0' into 10.0
parents
6b4cc43f
14eea2f8
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
1462 additions
and
286 deletions
+1462
-286
storage/spider/ha_spider.cc
storage/spider/ha_spider.cc
+150
-1
storage/spider/ha_spider.h
storage/spider/ha_spider.h
+2
-1
storage/spider/spd_conn.cc
storage/spider/spd_conn.cc
+47
-2
storage/spider/spd_conn.h
storage/spider/spd_conn.h
+6
-0
storage/spider/spd_copy_tables.cc
storage/spider/spd_copy_tables.cc
+38
-35
storage/spider/spd_db_conn.cc
storage/spider/spd_db_conn.cc
+161
-16
storage/spider/spd_db_conn.h
storage/spider/spd_db_conn.h
+33
-4
storage/spider/spd_db_handlersocket.cc
storage/spider/spd_db_handlersocket.cc
+146
-9
storage/spider/spd_db_include.h
storage/spider/spd_db_include.h
+8
-0
storage/spider/spd_db_mysql.cc
storage/spider/spd_db_mysql.cc
+176
-23
storage/spider/spd_db_oracle.cc
storage/spider/spd_db_oracle.cc
+157
-19
storage/spider/spd_direct_sql.cc
storage/spider/spd_direct_sql.cc
+12
-1
storage/spider/spd_err.h
storage/spider/spd_err.h
+2
-0
storage/spider/spd_include.h
storage/spider/spd_include.h
+32
-4
storage/spider/spd_malloc.cc
storage/spider/spd_malloc.cc
+14
-0
storage/spider/spd_param.cc
storage/spider/spd_param.cc
+25
-1
storage/spider/spd_param.h
storage/spider/spd_param.h
+2
-1
storage/spider/spd_ping_table.cc
storage/spider/spd_ping_table.cc
+106
-21
storage/spider/spd_ping_table.h
storage/spider/spd_ping_table.h
+1
-0
storage/spider/spd_sys_table.cc
storage/spider/spd_sys_table.cc
+23
-1
storage/spider/spd_table.cc
storage/spider/spd_table.cc
+215
-146
storage/spider/spd_table.h
storage/spider/spd_table.h
+7
-0
storage/spider/spd_trx.cc
storage/spider/spd_trx.cc
+99
-1
No files found.
storage/spider/ha_spider.cc
View file @
3e206a51
This diff is collapsed.
Click to expand it.
storage/spider/ha_spider.h
View file @
3e206a51
/* Copyright (C) 2008-201
4
Kentoku Shiba
/* Copyright (C) 2008-201
5
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
...
...
@@ -738,6 +738,7 @@ public:
void
set_ft_discard_bitmap
();
void
set_searched_bitmap
();
void
set_clone_searched_bitmap
();
void
set_searched_bitmap_from_item_list
();
void
set_select_column_mode
();
#ifdef WITH_PARTITION_STORAGE_ENGINE
void
check_select_column
(
bool
rnd
);
...
...
storage/spider/spd_conn.cc
View file @
3e206a51
/* Copyright (C) 2008-201
4
Kentoku Shiba
/* Copyright (C) 2008-201
5
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
...
...
@@ -662,6 +662,7 @@ SPIDER_CONN *spider_create_conn(
spider_conn_queue_connect
(
share
,
conn
,
link_idx
);
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
;
...
...
@@ -1085,6 +1086,17 @@ SPIDER_CONN *spider_get_conn(
}
conn
->
link_idx
=
base_link_idx
;
if
(
conn
->
queued_connect
)
spider_conn_queue_connect_rewrite
(
share
,
conn
,
link_idx
);
if
(
conn
->
queued_ping
)
{
if
(
spider
)
spider_conn_queue_ping_rewrite
(
spider
,
conn
,
base_link_idx
);
else
conn
->
queued_ping
=
FALSE
;
}
DBUG_PRINT
(
"info"
,(
"spider conn=%p"
,
conn
));
DBUG_RETURN
(
conn
);
...
...
@@ -1195,8 +1207,10 @@ void spider_conn_queue_connect(
DBUG_ENTER
(
"spider_conn_queue_connect"
);
DBUG_PRINT
(
"info"
,
(
"spider conn=%p"
,
conn
));
conn
->
queued_connect
=
TRUE
;
/*
conn->queued_connect_share = share;
conn->queued_connect_link_idx = link_idx;
*/
DBUG_VOID_RETURN
;
}
...
...
@@ -1225,6 +1239,18 @@ void spider_conn_queue_ping(
DBUG_VOID_RETURN
;
}
void
spider_conn_queue_ping_rewrite
(
ha_spider
*
spider
,
SPIDER_CONN
*
conn
,
int
link_idx
)
{
DBUG_ENTER
(
"spider_conn_queue_ping_rewrite"
);
DBUG_PRINT
(
"info"
,
(
"spider conn=%p"
,
conn
));
conn
->
queued_ping_spider
=
spider
;
conn
->
queued_ping_link_idx
=
link_idx
;
DBUG_VOID_RETURN
;
}
void
spider_conn_queue_trx_isolation
(
SPIDER_CONN
*
conn
,
int
trx_isolation
...
...
@@ -1285,6 +1311,7 @@ void spider_conn_queue_start_transaction(
)
{
DBUG_ENTER
(
"spider_conn_queue_start_transaction"
);
DBUG_PRINT
(
"info"
,
(
"spider conn=%p"
,
conn
));
DBUG_ASSERT
(
!
conn
->
trx_start
);
conn
->
queued_trx_start
=
TRUE
;
conn
->
trx_start
=
TRUE
;
DBUG_VOID_RETURN
;
...
...
@@ -1325,7 +1352,11 @@ void spider_conn_clear_queue_at_commit(
)
{
DBUG_ENTER
(
"spider_conn_clear_queue_at_commit"
);
DBUG_PRINT
(
"info"
,
(
"spider conn=%p"
,
conn
));
conn
->
queued_trx_start
=
FALSE
;
if
(
conn
->
queued_trx_start
)
{
conn
->
queued_trx_start
=
FALSE
;
conn
->
trx_start
=
FALSE
;
}
conn
->
queued_xa_start
=
FALSE
;
DBUG_VOID_RETURN
;
}
...
...
@@ -2280,6 +2311,13 @@ void *spider_bg_conn_action(
thd
->
clear_error
();
pthread_cond_wait
(
&
conn
->
bg_conn_cond
,
&
conn
->
bg_conn_mutex
);
DBUG_PRINT
(
"info"
,(
"spider bg roop start"
));
#ifndef DBUG_OFF
DBUG_PRINT
(
"info"
,(
"spider conn->thd=%p"
,
conn
->
thd
));
if
(
conn
->
thd
)
{
DBUG_PRINT
(
"info"
,(
"spider query_id=%lld"
,
conn
->
thd
->
query_id
));
}
#endif
if
(
conn
->
bg_caller_sync_wait
)
{
pthread_mutex_lock
(
&
conn
->
bg_conn_sync_mutex
);
...
...
@@ -2925,6 +2963,7 @@ void *spider_bg_sts_action(
0,
share->monitoring_kind[spider.search_link_idx],
share->monitoring_limit[spider.search_link_idx],
share->monitoring_flag[spider.search_link_idx],
TRUE
);
lex_end(thd->lex);
...
...
@@ -2934,6 +2973,7 @@ void *spider_bg_sts_action(
}
if
(
spider
.
search_link_idx
!=
-
1
&&
conns
[
spider
.
search_link_idx
])
{
DBUG_ASSERT
(
!
conns
[
spider
.
search_link_idx
]
->
thd
);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if
(
spider_get_sts
(
share
,
spider
.
search_link_idx
,
share
->
bg_sts_try_time
,
&
spider
,
...
...
@@ -2965,6 +3005,7 @@ void *spider_bg_sts_action(
0,
share->monitoring_kind[spider.search_link_idx],
share->monitoring_limit[spider.search_link_idx],
share->monitoring_flag[spider.search_link_idx],
TRUE
);
lex_end(thd->lex);
...
...
@@ -3317,6 +3358,7 @@ void *spider_bg_crd_action(
0,
share->monitoring_kind[spider.search_link_idx],
share->monitoring_limit[spider.search_link_idx],
share->monitoring_flag[spider.search_link_idx],
TRUE
);
lex_end(thd->lex);
...
...
@@ -3326,6 +3368,7 @@ void *spider_bg_crd_action(
}
if
(
spider
.
search_link_idx
!=
-
1
&&
conns
[
spider
.
search_link_idx
])
{
DBUG_ASSERT
(
!
conns
[
spider
.
search_link_idx
]
->
thd
);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if
(
spider_get_crd
(
share
,
spider
.
search_link_idx
,
share
->
bg_crd_try_time
,
&
spider
,
&
table
,
...
...
@@ -3357,6 +3400,7 @@ void *spider_bg_crd_action(
0,
share->monitoring_kind[spider.search_link_idx],
share->monitoring_limit[spider.search_link_idx],
share->monitoring_flag[spider.search_link_idx],
TRUE
);
lex_end(thd->lex);
...
...
@@ -3714,6 +3758,7 @@ void *spider_bg_mon_action(
0
,
share
->
monitoring_bg_kind
[
link_idx
],
share
->
monitoring_limit
[
link_idx
],
share
->
monitoring_bg_flag
[
link_idx
],
TRUE
);
lex_end
(
thd
->
lex
);
...
...
storage/spider/spd_conn.h
View file @
3e206a51
...
...
@@ -100,6 +100,12 @@ void spider_conn_queue_ping(
int
link_idx
);
void
spider_conn_queue_ping_rewrite
(
ha_spider
*
spider
,
SPIDER_CONN
*
conn
,
int
link_idx
);
void
spider_conn_queue_trx_isolation
(
SPIDER_CONN
*
conn
,
int
trx_isolation
...
...
storage/spider/spd_copy_tables.cc
View file @
3e206a51
...
...
@@ -1032,36 +1032,47 @@ long long spider_copy_tables_body(
else
copy_tables
->
access_charset
=
system_charset_info
;
src_tbl_conn
=
copy_tables
->
table_conn
[
0
];
select_ct
=
src_tbl_conn
->
copy_table
;
src_tbl_conn
->
share
->
access_charset
=
copy_tables
->
access_charset
;
select_ct
->
set_sql_charset
(
copy_tables
->
access_charset
);
if
(
select_ct
->
append_select_str
()
||
select_ct
->
append_table_columns
(
table_share
)
)
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
bulk_insert_rows
=
spider_param_udf_ct_bulk_insert_rows
(
copy_tables
->
bulk_insert_rows
);
for
(
src_tbl_conn
=
copy_tables
->
table_conn
[
0
];
src_tbl_conn
;
src_tbl_conn
=
src_tbl_conn
->
next
)
{
select_ct
=
src_tbl_conn
->
copy_table
;
src_tbl_conn
->
share
->
access_charset
=
copy_tables
->
access_charset
;
select_ct
->
set_sql_charset
(
copy_tables
->
access_charset
);
if
(
select_ct
->
append_select_str
()
||
select_ct
->
append_table_columns
(
table_share
)
)
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
if
(
select_ct
->
append_from_str
()
||
select_ct
->
append_table_name
(
0
)
)
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
if
(
select_ct
->
append_from_str
()
||
select_ct
->
append_table_name
(
0
)
)
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
select_ct
->
set_sql_pos
();
select_ct
->
set_sql_pos
();
bulk_insert_rows
=
spider_param_udf_ct_bulk_insert_rows
(
copy_tables
->
bulk_insert_rows
);
if
(
select_ct
->
append_key_order_str
(
key_info
,
0
,
FALSE
)
||
select_ct
->
append_limit
(
0
,
bulk_insert_rows
)
)
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
if
(
select_ct
->
append_key_order_str
(
key_info
,
0
,
FALSE
)
||
select_ct
->
append_limit
(
0
,
bulk_insert_rows
)
)
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
if
(
copy_tables
->
use_transaction
&&
select_ct
->
append_select_lock_str
(
SPIDER_LOCK_MODE_SHARED
)
)
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
}
for
(
dst_tbl_conn
=
copy_tables
->
table_conn
[
1
];
dst_tbl_conn
;
...
...
@@ -1188,14 +1199,6 @@ long long spider_copy_tables_body(
table_conn
->
spider
=
tmp_spider
;
}
if
(
copy_tables
->
use_transaction
&&
select_ct
->
append_select_lock_str
(
SPIDER_LOCK_MODE_SHARED
)
)
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
if
((
error_num
=
spider_db_udf_copy_tables
(
copy_tables
,
spider
,
table
,
bulk_insert_rows
)))
goto
error_db_udf_copy_tables
;
...
...
storage/spider/spd_db_conn.cc
View file @
3e206a51
This diff is collapsed.
Click to expand it.
storage/spider/spd_db_conn.h
View file @
3e206a51
/* Copyright (C) 2008-201
4
Kentoku Shiba
/* Copyright (C) 2008-201
5
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
...
...
@@ -93,7 +93,7 @@
#define SPIDER_SQL_LIMIT_LEN (sizeof(SPIDER_SQL_LIMIT_STR) - 1)
#define SPIDER_SQL_INTO_STR "into "
#define SPIDER_SQL_INTO_LEN (sizeof(SPIDER_SQL_INTO_STR) - 1)
#define SPIDER_SQL_VALUES_STR "
)
values"
#define SPIDER_SQL_VALUES_STR "values"
#define SPIDER_SQL_VALUES_LEN (sizeof(SPIDER_SQL_VALUES_STR) - 1)
#define SPIDER_SQL_SHARED_LOCK_STR " lock in share mode"
#define SPIDER_SQL_SHARED_LOCK_LEN (sizeof(SPIDER_SQL_SHARED_LOCK_STR) - 1)
...
...
@@ -197,6 +197,25 @@
#define SPIDER_SQL_MINUS_STR " - "
#define SPIDER_SQL_MINUS_LEN (sizeof(SPIDER_SQL_MINUS_STR) - 1)
#define SPIDER_SQL_YEAR_STR "year"
#define SPIDER_SQL_YEAR_LEN (sizeof(SPIDER_SQL_YEAR_STR) - 1)
#define SPIDER_SQL_QUARTER_STR "quarter"
#define SPIDER_SQL_QUARTER_LEN (sizeof(SPIDER_SQL_QUARTER_STR) - 1)
#define SPIDER_SQL_MONTH_STR "month"
#define SPIDER_SQL_MONTH_LEN (sizeof(SPIDER_SQL_MONTH_STR) - 1)
#define SPIDER_SQL_WEEK_STR "week"
#define SPIDER_SQL_WEEK_LEN (sizeof(SPIDER_SQL_WEEK_STR) - 1)
#define SPIDER_SQL_DAY_STR "day"
#define SPIDER_SQL_DAY_LEN (sizeof(SPIDER_SQL_DAY_STR) - 1)
#define SPIDER_SQL_HOUR_STR "hour"
#define SPIDER_SQL_HOUR_LEN (sizeof(SPIDER_SQL_HOUR_STR) - 1)
#define SPIDER_SQL_MINUTE_STR "minute"
#define SPIDER_SQL_MINUTE_LEN (sizeof(SPIDER_SQL_MINUTE_STR) - 1)
#define SPIDER_SQL_SECOND_STR "second"
#define SPIDER_SQL_SECOND_LEN (sizeof(SPIDER_SQL_SECOND_STR) - 1)
#define SPIDER_SQL_MICROSECOND_STR "microsecond"
#define SPIDER_SQL_MICROSECOND_LEN (sizeof(SPIDER_SQL_MICROSECOND_STR) - 1)
#define SPIDER_SQL_SHOW_RECORDS_STR "select count(*) from "
#define SPIDER_SQL_SHOW_RECORDS_LEN sizeof(SPIDER_SQL_SHOW_RECORDS_STR) - 1
#define SPIDER_SQL_SHOW_INDEX_STR "show index from "
...
...
@@ -234,8 +253,9 @@
#define SPIDER_SQL_INT_LEN 20
#define SPIDER_SQL_HANDLER_CID_LEN 6
#define SPIDER_SQL_HANDLER_CID_FORMAT "t%05u"
#define SPIDER_UDF_PING_TABLE_PING_ONLY (1 << 0)
#define SPIDER_UDF_PING_TABLE_USE_WHERE (1 << 1)
#define SPIDER_UDF_PING_TABLE_PING_ONLY (1 << 0)
#define SPIDER_UDF_PING_TABLE_USE_WHERE (1 << 1)
#define SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES (1 << 2)
int
spider_db_connect
(
const
SPIDER_SHARE
*
share
,
...
...
@@ -887,6 +907,15 @@ int spider_db_open_item_cache(
uint
dbton_id
);
int
spider_db_open_item_insert_value
(
Item_insert_value
*
item_insert_value
,
ha_spider
*
spider
,
spider_string
*
str
,
const
char
*
alias
,
uint
alias_length
,
uint
dbton_id
);
int
spider_db_append_condition
(
ha_spider
*
spider
,
const
char
*
alias
,
...
...
storage/spider/spd_db_handlersocket.cc
View file @
3e206a51
...
...
@@ -2786,7 +2786,11 @@ int spider_db_handlersocket_util::open_item_func(
{
if
(
!
strncasecmp
(
"rand"
,
func_name
,
func_name_length
)
&&
#ifdef SPIDER_Item_args_arg_count_IS_PROTECTED
!
item_func
->
argument_count
()
#else
!
item_func
->
arg_count
#endif
)
{
if
(
str
)
str
->
length
(
str
->
length
()
-
SPIDER_SQL_OPEN_PAREN_LEN
);
...
...
@@ -2946,13 +2950,99 @@ int spider_db_handlersocket_util::open_item_func(
last_str_length
=
SPIDER_SQL_AS_TIME_LEN
;
break
;
}
}
else
if
(
func_name_length
==
13
&&
!
strncasecmp
(
"utc_timestamp"
,
func_name
,
func_name_length
)
)
{
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
));
}
else
if
(
func_name_length
==
13
)
{
if
(
!
strncasecmp
(
"utc_timestamp"
,
func_name
,
func_name_length
))
{
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
));
}
else
if
(
!
strncasecmp
(
"timestampdiff"
,
func_name
,
func_name_length
))
{
#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC
Item_func_timestamp_diff
*
item_func_timestamp_diff
=
(
Item_func_timestamp_diff
*
)
item_func
;
if
(
str
)
{
const
char
*
interval_str
;
uint
interval_len
;
switch
(
item_func_timestamp_diff
->
int_type
)
{
case
INTERVAL_YEAR
:
interval_str
=
SPIDER_SQL_YEAR_STR
;
interval_len
=
SPIDER_SQL_YEAR_LEN
;
break
;
case
INTERVAL_QUARTER
:
interval_str
=
SPIDER_SQL_QUARTER_STR
;
interval_len
=
SPIDER_SQL_QUARTER_LEN
;
break
;
case
INTERVAL_MONTH
:
interval_str
=
SPIDER_SQL_MONTH_STR
;
interval_len
=
SPIDER_SQL_MONTH_LEN
;
break
;
case
INTERVAL_WEEK
:
interval_str
=
SPIDER_SQL_WEEK_STR
;
interval_len
=
SPIDER_SQL_WEEK_LEN
;
break
;
case
INTERVAL_DAY
:
interval_str
=
SPIDER_SQL_DAY_STR
;
interval_len
=
SPIDER_SQL_DAY_LEN
;
break
;
case
INTERVAL_HOUR
:
interval_str
=
SPIDER_SQL_HOUR_STR
;
interval_len
=
SPIDER_SQL_HOUR_LEN
;
break
;
case
INTERVAL_MINUTE
:
interval_str
=
SPIDER_SQL_MINUTE_STR
;
interval_len
=
SPIDER_SQL_MINUTE_LEN
;
break
;
case
INTERVAL_SECOND
:
interval_str
=
SPIDER_SQL_SECOND_STR
;
interval_len
=
SPIDER_SQL_SECOND_LEN
;
break
;
case
INTERVAL_MICROSECOND
:
interval_str
=
SPIDER_SQL_MICROSECOND_STR
;
interval_len
=
SPIDER_SQL_MICROSECOND_LEN
;
break
;
default:
interval_str
=
""
;
interval_len
=
0
;
break
;
}
str
->
length
(
str
->
length
()
-
SPIDER_SQL_OPEN_PAREN_LEN
);
if
(
str
->
reserve
(
func_name_length
+
SPIDER_SQL_OPEN_PAREN_LEN
+
interval_len
+
SPIDER_SQL_COMMA_LEN
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
str
->
q_append
(
func_name
,
func_name_length
);
str
->
q_append
(
SPIDER_SQL_OPEN_PAREN_STR
,
SPIDER_SQL_OPEN_PAREN_LEN
);
str
->
q_append
(
interval_str
,
interval_len
);
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
)))
DBUG_RETURN
(
error_num
);
if
(
str
)
{
if
(
str
->
reserve
(
SPIDER_SQL_COMMA_LEN
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
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
)))
DBUG_RETURN
(
error_num
);
if
(
str
)
{
if
(
str
->
reserve
(
SPIDER_SQL_CLOSE_PAREN_LEN
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
str
->
q_append
(
SPIDER_SQL_CLOSE_PAREN_STR
,
SPIDER_SQL_CLOSE_PAREN_LEN
);
}
DBUG_RETURN
(
0
);
#else
DBUG_RETURN
(
ER_SPIDER_COND_SKIP_NUM
);
#endif
}
}
else
if
(
func_name_length
==
14
)
{
if
(
!
strncasecmp
(
"cast_as_binary"
,
func_name
,
func_name_length
))
...
...
@@ -3142,6 +3232,54 @@ int spider_db_handlersocket_util::open_item_func(
}
break
;
case
Item_func
:
:
NOT_FUNC
:
DBUG_PRINT
(
"info"
,(
"spider NOT_FUNC"
));
if
(
item_list
[
0
]
->
type
()
==
Item
::
COND_ITEM
)
{
DBUG_PRINT
(
"info"
,(
"spider item_list[0] is COND_ITEM"
));
Item_cond
*
item_cond
=
(
Item_cond
*
)
item_list
[
0
];
if
(
item_cond
->
functype
()
==
Item_func
::
COND_AND_FUNC
)
{
DBUG_PRINT
(
"info"
,(
"spider item_cond is COND_AND_FUNC"
));
List_iterator_fast
<
Item
>
lif
(
*
(
item_cond
->
argument_list
()));
bool
has_expr_cache_item
=
FALSE
;
bool
has_isnotnull_func
=
FALSE
;
bool
has_other_item
=
FALSE
;
while
((
item
=
lif
++
))
{
if
(
item
->
type
()
==
Item
::
EXPR_CACHE_ITEM
)
{
DBUG_PRINT
(
"info"
,(
"spider EXPR_CACHE_ITEM"
));
has_expr_cache_item
=
TRUE
;
}
else
if
(
item
->
type
()
==
Item
::
FUNC_ITEM
&&
((
Item_func
*
)
item
)
->
functype
()
==
Item_func
::
ISNOTNULL_FUNC
)
{
DBUG_PRINT
(
"info"
,(
"spider ISNOTNULL_FUNC"
));
has_isnotnull_func
=
TRUE
;
}
else
{
DBUG_PRINT
(
"info"
,(
"spider has other item"
));
DBUG_PRINT
(
"info"
,(
"spider COND type=%d"
,
item
->
type
()));
has_other_item
=
TRUE
;
}
}
if
(
has_expr_cache_item
&&
has_isnotnull_func
&&
!
has_other_item
)
{
DBUG_PRINT
(
"info"
,(
"spider NOT EXISTS skip"
));
DBUG_RETURN
(
ER_SPIDER_COND_SKIP_NUM
);
}
}
}
if
(
str
)
{
func_name
=
(
char
*
)
item_func
->
func_name
();
func_name_length
=
strlen
(
func_name
);
if
(
str
->
reserve
(
func_name_length
+
SPIDER_SQL_SPACE_LEN
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
str
->
q_append
(
func_name
,
func_name_length
);
str
->
q_append
(
SPIDER_SQL_SPACE_STR
,
SPIDER_SQL_SPACE_LEN
);
}
break
;
case
Item_func
:
:
NEG_FUNC
:
if
(
str
)
{
...
...
@@ -3494,8 +3632,7 @@ int spider_db_handlersocket_util::append_escaped_util(
)
{
DBUG_ENTER
(
"spider_db_handlersocket_util::append_escaped_util"
);
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
if
(
to
->
append_for_single_quote
(
from
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
to
->
append_escape_string
(
from
->
ptr
(),
from
->
length
());
DBUG_RETURN
(
0
);
}
...
...
storage/spider/spd_db_include.h
View file @
3e206a51
...
...
@@ -25,6 +25,7 @@
#define SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE
#define SPIDER_HAS_SHOW_SIMPLE_FUNC
#define SPIDER_HAS_JT_HASH_INDEX_MERGE
#define SPIDER_HAS_EXPR_CACHE_ITEM
#else
#define SPIDER_NEED_CHECK_CONDITION_AT_CHECKING_DIRECT_ORDER_LIMIT
#endif
...
...
@@ -41,6 +42,9 @@
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100014
#define SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100100
#define SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR
#endif
#endif
#if defined(MARIADB_BASE_VERSION)
...
...
@@ -501,6 +505,10 @@ public:
uint32
arg_length
,
uint32
step_alloc
);
void
append_escape_string
(
const
char
*
st
,
uint
len
);
bool
append_for_single_quote
(
const
char
*
st
,
uint
len
...
...
storage/spider/spd_db_mysql.cc
View file @
3e206a51
This diff is collapsed.
Click to expand it.
storage/spider/spd_db_oracle.cc
View file @
3e206a51
This diff is collapsed.
Click to expand it.
storage/spider/spd_direct_sql.cc
View file @
3e206a51
/* Copyright (C) 2009-201
4
Kentoku Shiba
/* Copyright (C) 2009-201
5
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
...
...
@@ -557,6 +557,7 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
if
((
*
error_num
=
spider_db_udf_direct_sql_connect
(
direct_sql
,
conn
)))
goto
error
;
conn
->
ping_time
=
(
time_t
)
time
((
time_t
*
)
0
);
conn
->
connect_error_time
=
conn
->
ping_time
;
DBUG_RETURN
(
conn
);
...
...
@@ -761,6 +762,16 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn(
#endif
}
if
(
conn
->
queued_connect
)
{
if
((
*
error_num
=
spider_db_udf_direct_sql_connect
(
direct_sql
,
conn
)))
goto
error
;
conn
->
queued_connect
=
FALSE
;
}
if
(
conn
->
queued_ping
)
conn
->
queued_ping
=
FALSE
;
DBUG_PRINT
(
"info"
,(
"spider conn=%p"
,
conn
));
DBUG_PRINT
(
"info"
,(
"spider conn->conn_kind=%u"
,
conn
->
conn_kind
));
DBUG_RETURN
(
conn
);
...
...
storage/spider/spd_err.h
View file @
3e206a51
...
...
@@ -63,6 +63,8 @@
#define ER_SPIDER_REQUEST_KEY_STR "Request key not found"
#define ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM 12524
#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_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"
...
...
storage/spider/spd_include.h
View file @
3e206a51
...
...
@@ -13,7 +13,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define SPIDER_DETAIL_VERSION "3.2.
21
"
#define SPIDER_DETAIL_VERSION "3.2.
37
"
#define SPIDER_HEX_VERSION 0x0302
#if MYSQL_VERSION_ID < 50500
...
...
@@ -117,6 +117,18 @@
#define SPIDER_TEST(A) test(A)
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100100
#define SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
#define SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON
#define SPIDER_XID_USES_xid_cache_iterate
#else
#define SPIDER_XID_STATE_HAS_in_thd
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100108
#define SPIDER_Item_args_arg_count_IS_PROTECTED
#endif
#if MYSQL_VERSION_ID >= 50500
#define SPIDER_HAS_HASH_VALUE_TYPE
#endif
...
...
@@ -141,7 +153,7 @@
#define SPIDER_TMP_SHARE_CHAR_PTR_COUNT 19
#define SPIDER_TMP_SHARE_UINT_COUNT 17
#define SPIDER_TMP_SHARE_LONG_COUNT 1
6
#define SPIDER_TMP_SHARE_LONG_COUNT 1
8
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
#define SPIDER_MEM_CALC_LIST_NUM 247
...
...
@@ -436,6 +448,13 @@ typedef struct st_spider_conn
int
bulk_access_error_num
;
st_spider_conn
*
bulk_access_next
;
#endif
bool
connect_error_with_message
;
char
connect_error_msg
[
MYSQL_ERRMSG_SIZE
];
int
connect_error
;
THD
*
connect_error_thd
;
query_id_t
connect_error_query_id
;
time_t
connect_error_time
;
}
SPIDER_CONN
;
typedef
struct
st_spider_lgtm_tblhnd_share
...
...
@@ -656,6 +675,7 @@ typedef struct st_spider_share
volatile
bool
init_error
;
volatile
time_t
init_error_time
;
volatile
bool
link_status_init
;
uchar
*
table_mon_mutex_bitmap
;
volatile
bool
sts_init
;
volatile
time_t
sts_get_time
;
#ifndef WITHOUT_SPIDER_BG_SEARCH
...
...
@@ -844,8 +864,10 @@ typedef struct st_spider_share
long
*
tgt_ssl_vscs
;
long
*
link_statuses
;
#ifndef WITHOUT_SPIDER_BG_SEARCH
long
*
monitoring_bg_flag
;
long
*
monitoring_bg_kind
;
#endif
long
*
monitoring_flag
;
long
*
monitoring_kind
;
#ifndef WITHOUT_SPIDER_BG_SEARCH
longlong
*
monitoring_bg_interval
;
...
...
@@ -948,8 +970,10 @@ typedef struct st_spider_share
uint
tgt_ssl_vscs_length
;
uint
link_statuses_length
;
#ifndef WITHOUT_SPIDER_BG_SEARCH
uint
monitoring_bg_flag_length
;
uint
monitoring_bg_kind_length
;
#endif
uint
monitoring_flag_length
;
uint
monitoring_kind_length
;
#ifndef WITHOUT_SPIDER_BG_SEARCH
uint
monitoring_bg_interval_length
;
...
...
@@ -1239,8 +1263,12 @@ typedef struct st_spider_int_hld
typedef
struct
st_spider_item_hld
{
uint
tgt_num
;
Item
*
item
;
uint
tgt_num
;
Item
*
item
;
#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR
bool
init_mem_root
;
MEM_ROOT
mem_root
;
#endif
st_spider_item_hld
*
next
;
}
SPIDER_ITEM_HLD
;
...
...
storage/spider/spd_malloc.cc
View file @
3e206a51
...
...
@@ -1222,6 +1222,20 @@ bool spider_string::append(
DBUG_RETURN
(
res
);
}
void
spider_string
::
append_escape_string
(
const
char
*
st
,
uint
len
)
{
DBUG_ENTER
(
"spider_string::append_escape_string"
);
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
DBUG_ASSERT
(
mem_calc_inited
);
DBUG_ASSERT
((
!
current_alloc_mem
&&
!
str
.
is_alloced
())
||
current_alloc_mem
==
str
.
alloced_length
());
str
.
length
(
str
.
length
()
+
escape_string_for_mysql
(
str
.
charset
(),
(
char
*
)
str
.
ptr
()
+
str
.
length
(),
0
,
st
,
len
));
DBUG_VOID_RETURN
;
}
bool
spider_string
::
append_for_single_quote
(
const
char
*
st
,
uint
len
...
...
storage/spider/spd_param.cc
View file @
3e206a51
/* Copyright (C) 2008-201
4
Kentoku Shiba
/* Copyright (C) 2008-201
5
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
...
...
@@ -178,6 +178,29 @@ my_bool spider_param_connect_mutex()
DBUG_RETURN
(
spider_connect_mutex
);
}
static
uint
spider_connect_error_interval
;
/*
0-: interval
*/
static
MYSQL_SYSVAR_UINT
(
connect_error_interval
,
spider_connect_error_interval
,
PLUGIN_VAR_RQCMDARG
,
"Return same error code until interval passes if connection is failed"
,
NULL
,
NULL
,
1
,
0
,
4294967295U
,
0
);
uint
spider_param_connect_error_interval
()
{
DBUG_ENTER
(
"spider_param_connect_error_interval"
);
DBUG_RETURN
(
spider_connect_error_interval
);
}
static
uint
spider_table_init_error_interval
;
/*
0-: interval
...
...
@@ -3120,6 +3143,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR
(
dry_access
),
MYSQL_SYSVAR
(
delete_all_rows_type
),
MYSQL_SYSVAR
(
bka_table_name_type
),
MYSQL_SYSVAR
(
connect_error_interval
),
NULL
};
...
...
storage/spider/spd_param.h
View file @
3e206a51
/* Copyright (C) 2008-201
4
Kentoku Shiba
/* Copyright (C) 2008-201
5
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
...
...
@@ -15,6 +15,7 @@
my_bool
spider_param_support_xa
();
my_bool
spider_param_connect_mutex
();
uint
spider_param_connect_error_interval
();
uint
spider_param_table_init_error_interval
();
int
spider_param_use_table_charset
(
int
use_table_charset
...
...
storage/spider/spd_ping_table.cc
View file @
3e206a51
/* Copyright (C) 2009-201
4
Kentoku Shiba
/* Copyright (C) 2009-201
5
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
...
...
@@ -626,6 +626,17 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn(
*
error_num
=
ER_CONNECT_TO_FOREIGN_DATA_SOURCE
;
goto
error
;
}
#ifndef DBUG_OFF
if
(
trx
==
spider_global_trx
)
{
DBUG_ASSERT
(
!
conn
->
thd
);
}
DBUG_PRINT
(
"info"
,(
"spider conn->thd=%p"
,
conn
->
thd
));
if
(
conn
->
thd
)
{
DBUG_PRINT
(
"info"
,(
"spider query_id=%lld"
,
conn
->
thd
->
query_id
));
}
#endif
conn
->
error_mode
=
0
;
#ifndef WITHOUT_SPIDER_BG_SEARCH
if
(
trx
==
spider_global_trx
)
...
...
@@ -992,37 +1003,56 @@ long long spider_ping_table_body(
limit
))
)
{
DBUG_PRINT
(
"info"
,(
"spider table_mon_list->mon_status == SPIDER_LINK_MON_NG:%s"
,
table_mon_list
->
mon_status
==
SPIDER_LINK_MON_NG
?
"TRUE"
:
"FALSE"
));
DBUG_PRINT
(
"info"
,(
"spider error_num=%d"
,
error_num
));
DBUG_PRINT
(
"info"
,(
"spider tmp_error_num=%d"
,
tmp_error_num
));
if
(
tmp_error_num
==
HA_ERR_OUT_OF_MEM
)
goto
error_with_free_table_mon_list
;
else
if
(
tmp_error_num
)
thd
->
clear_error
();
fault_count
++
;
error_num
=
0
;
if
(
fault_count
>
full_mon_count
/
2
)
if
(
tmp_error_num
!=
ER_CON_COUNT_ERROR
)
{
mon_table_result
->
result_status
=
SPIDER_LINK_MON_NG
;
DBUG_PRINT
(
"info"
,(
"spider mon_table_result->result_status=SPIDER_LINK_MON_NG 2"
));
if
(
table_mon_list
->
mon_status
!=
SPIDER_LINK_MON_NG
)
{
pthread_mutex_lock
(
&
table_mon_list
->
update_status_mutex
);
fault_count
++
;
error_num
=
0
;
if
(
!
(
flags
&
SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES
)
&&
fault_count
>
full_mon_count
/
2
)
{
mon_table_result
->
result_status
=
SPIDER_LINK_MON_NG
;
DBUG_PRINT
(
"info"
,(
"spider mon_table_result->result_status=SPIDER_LINK_MON_NG 2"
));
if
(
table_mon_list
->
mon_status
!=
SPIDER_LINK_MON_NG
)
{
table_mon_list
->
mon_status
=
SPIDER_LINK_MON_NG
;
table_mon_list
->
share
->
link_statuses
[
0
]
=
SPIDER_LINK_STATUS_NG
;
spider_sys_update_tables_link_status
(
trx
->
thd
,
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
SPIDER_LINK_STATUS_NG
,
TRUE
);
spider_sys_log_tables_link_failed
(
trx
->
thd
,
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
TRUE
);
/*
pthread_mutex_lock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_lock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
if
(
table_mon_list
->
mon_status
!=
SPIDER_LINK_MON_NG
)
{
table_mon_list
->
mon_status
=
SPIDER_LINK_MON_NG
;
table_mon_list
->
share
->
link_statuses
[
0
]
=
SPIDER_LINK_STATUS_NG
;
spider_update_link_status_for_share
(
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
SPIDER_LINK_STATUS_NG
);
spider_sys_update_tables_link_status
(
trx
->
thd
,
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
SPIDER_LINK_STATUS_NG
,
TRUE
);
spider_sys_log_tables_link_failed
(
trx
->
thd
,
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
TRUE
);
}
/*
pthread_mutex_unlock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_unlock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
}
pthread_mutex_unlock
(
&
table_mon_list
->
update_status_mutex
)
;
goto
end
;
}
goto
end
;
}
}
else
{
success_count
++
;
if
(
success_count
>
full_mon_count
/
2
)
{
if
(
!
(
flags
&
SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES
)
&&
success_count
>
full_mon_count
/
2
)
{
mon_table_result
->
result_status
=
SPIDER_LINK_MON_OK
;
DBUG_PRINT
(
"info"
,(
"spider mon_table_result->result_status=SPIDER_LINK_MON_OK 1"
));
goto
end
;
...
...
@@ -1048,7 +1078,42 @@ long long spider_ping_table_body(
table_mon
->
server_id
==
first_sid
||
current_mon_count
>
full_mon_count
)
{
if
(
success_count
+
fault_count
>
full_mon_count
/
2
)
if
(
(
flags
&
SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES
)
&&
fault_count
>
full_mon_count
/
2
)
{
mon_table_result
->
result_status
=
SPIDER_LINK_MON_NG
;
DBUG_PRINT
(
"info"
,(
"spider mon_table_result->result_status=SPIDER_LINK_MON_NG 3"
));
if
(
table_mon_list
->
mon_status
!=
SPIDER_LINK_MON_NG
)
{
/*
pthread_mutex_lock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_lock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
if
(
table_mon_list
->
mon_status
!=
SPIDER_LINK_MON_NG
)
{
table_mon_list
->
mon_status
=
SPIDER_LINK_MON_NG
;
table_mon_list
->
share
->
link_statuses
[
0
]
=
SPIDER_LINK_STATUS_NG
;
spider_update_link_status_for_share
(
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
SPIDER_LINK_STATUS_NG
);
spider_sys_update_tables_link_status
(
trx
->
thd
,
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
SPIDER_LINK_STATUS_NG
,
TRUE
);
spider_sys_log_tables_link_failed
(
trx
->
thd
,
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
TRUE
);
}
/*
pthread_mutex_unlock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_unlock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
}
}
else
if
(
(
flags
&
SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES
)
&&
success_count
>
full_mon_count
/
2
)
{
mon_table_result
->
result_status
=
SPIDER_LINK_MON_OK
;
DBUG_PRINT
(
"info"
,(
"spider mon_table_result->result_status=SPIDER_LINK_MON_OK 2"
));
}
else
if
(
success_count
+
fault_count
>
full_mon_count
/
2
)
{
mon_table_result
->
result_status
=
SPIDER_LINK_MON_DRAW
;
DBUG_PRINT
(
"info"
,(
...
...
@@ -1074,18 +1139,26 @@ long long spider_ping_table_body(
mon_table_result
->
result_status
==
SPIDER_LINK_MON_NG
&&
table_mon_list
->
mon_status
!=
SPIDER_LINK_MON_NG
)
{
/*
pthread_mutex_lock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_lock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
if
(
table_mon_list
->
mon_status
!=
SPIDER_LINK_MON_NG
)
{
table_mon_list
->
mon_status
=
SPIDER_LINK_MON_NG
;
table_mon_list
->
share
->
link_statuses
[
0
]
=
SPIDER_LINK_STATUS_NG
;
spider_update_link_status_for_share
(
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
SPIDER_LINK_STATUS_NG
);
spider_sys_update_tables_link_status
(
trx
->
thd
,
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
SPIDER_LINK_STATUS_NG
,
TRUE
);
spider_sys_log_tables_link_failed
(
trx
->
thd
,
conv_name
.
c_ptr
(),
conv_name_length
,
link_idx
,
TRUE
);
}
/*
pthread_mutex_unlock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_unlock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
}
table_mon_list
->
last_receptor_result
=
mon_table_result
->
result_status
;
...
...
@@ -1245,6 +1318,7 @@ int spider_ping_table_mon_from_table(
uint
where_clause_length
,
long
monitoring_kind
,
longlong
monitoring_limit
,
long
monitoring_flag
,
bool
need_lock
)
{
int
error_num
=
0
,
current_mon_count
,
flags
;
...
...
@@ -1312,6 +1386,9 @@ int spider_ping_table_mon_from_table(
else
flags
=
0
;
if
(
monitoring_flag
&
1
)
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
)))
...
...
@@ -1321,7 +1398,9 @@ int spider_ping_table_mon_from_table(
{
DBUG_PRINT
(
"info"
,
(
"spider share->link_statuses[%d]=SPIDER_LINK_STATUS_NG"
,
link_idx
));
pthread_mutex_lock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
share
->
link_statuses
[
link_idx
]
=
SPIDER_LINK_STATUS_NG
;
pthread_mutex_unlock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
error_num
=
ER_SPIDER_LINK_MON_NG_NUM
;
my_printf_error
(
error_num
,
ER_SPIDER_LINK_MON_NG_STR
,
MYF
(
0
),
...
...
@@ -1386,7 +1465,10 @@ int spider_ping_table_mon_from_table(
mon_table_result
.
result_status
==
SPIDER_LINK_MON_NG
&&
table_mon_list
->
mon_status
!=
SPIDER_LINK_MON_NG
)
{
/*
pthread_mutex_lock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_lock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
if
(
table_mon_list
->
mon_status
!=
SPIDER_LINK_MON_NG
)
{
table_mon_list
->
mon_status
=
SPIDER_LINK_MON_NG
;
...
...
@@ -1400,7 +1482,10 @@ int spider_ping_table_mon_from_table(
spider_sys_log_tables_link_failed
(
thd
,
conv_name
,
conv_name_length
,
link_idx
,
need_lock
);
}
/*
pthread_mutex_unlock(&table_mon_list->update_status_mutex);
*/
pthread_mutex_unlock
(
&
spider_udf_table_mon_mutexes
[
table_mon_list
->
mutex_hash
]);
}
table_mon_list
->
last_caller_result
=
mon_table_result
.
result_status
;
if
(
mon_table_result
.
result_status
==
SPIDER_LINK_MON_OK
)
...
...
storage/spider/spd_ping_table.h
View file @
3e206a51
...
...
@@ -98,5 +98,6 @@ int spider_ping_table_mon_from_table(
uint
where_clause_length
,
long
monitoring_kind
,
longlong
monitoring_limit
,
long
monitoring_flag
,
bool
need_lock
);
storage/spider/spd_sys_table.cc
View file @
3e206a51
/* Copyright (C) 2008-201
4
Kentoku Shiba
/* Copyright (C) 2008-201
5
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
...
...
@@ -2280,7 +2280,9 @@ int spider_get_link_statuses(
if
(
(
error_num
==
HA_ERR_KEY_NOT_FOUND
||
error_num
==
HA_ERR_END_OF_FILE
)
)
{
/*
table->file->print_error(error_num, MYF(0));
*/
DBUG_RETURN
(
error_num
);
}
}
else
if
((
error_num
=
...
...
@@ -2390,8 +2392,13 @@ TABLE *spider_mk_sys_tmp_table(
goto
error_alloc_field
;
field
->
init
(
table
);
#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
if
(
!
(
i_field
=
new
(
thd
->
mem_root
)
Item_field
(
thd
,
(
Field
*
)
field
)))
goto
error_alloc_item_field
;
#else
if
(
!
(
i_field
=
new
Item_field
((
Field
*
)
field
)))
goto
error_alloc_item_field
;
#endif
if
(
i_list
.
push_back
(
i_field
))
goto
error_push_item
;
...
...
@@ -2443,8 +2450,13 @@ TABLE *spider_mk_sys_tmp_table_for_result(
goto
error_alloc_field1
;
field1
->
init
(
table
);
#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
if
(
!
(
i_field1
=
new
(
thd
->
mem_root
)
Item_field
(
thd
,
(
Field
*
)
field1
)))
goto
error_alloc_item_field1
;
#else
if
(
!
(
i_field1
=
new
Item_field
((
Field
*
)
field1
)))
goto
error_alloc_item_field1
;
#endif
if
(
i_list
.
push_back
(
i_field1
))
goto
error_push_item1
;
...
...
@@ -2454,8 +2466,13 @@ TABLE *spider_mk_sys_tmp_table_for_result(
goto
error_alloc_field2
;
field2
->
init
(
table
);
#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
if
(
!
(
i_field2
=
new
(
thd
->
mem_root
)
Item_field
(
thd
,
(
Field
*
)
field2
)))
goto
error_alloc_item_field2
;
#else
if
(
!
(
i_field2
=
new
Item_field
((
Field
*
)
field2
)))
goto
error_alloc_item_field2
;
#endif
if
(
i_list
.
push_back
(
i_field2
))
goto
error_push_item2
;
...
...
@@ -2465,8 +2482,13 @@ TABLE *spider_mk_sys_tmp_table_for_result(
goto
error_alloc_field3
;
field3
->
init
(
table
);
#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
if
(
!
(
i_field3
=
new
(
thd
->
mem_root
)
Item_field
(
thd
,
(
Field
*
)
field3
)))
goto
error_alloc_item_field3
;
#else
if
(
!
(
i_field3
=
new
Item_field
((
Field
*
)
field3
)))
goto
error_alloc_item_field3
;
#endif
if
(
i_list
.
push_back
(
i_field3
))
goto
error_push_item3
;
...
...
storage/spider/spd_table.cc
View file @
3e206a51
This diff is collapsed.
Click to expand it.
storage/spider/spd_table.h
View file @
3e206a51
...
...
@@ -204,6 +204,13 @@ int spider_free_share(
SPIDER_SHARE
*
share
);
void
spider_update_link_status_for_share
(
const
char
*
table_name
,
uint
table_name_length
,
int
link_idx
,
long
link_status
);
#ifdef WITH_PARTITION_STORAGE_ENGINE
SPIDER_PARTITION_SHARE
*
spider_get_pt_share
(
SPIDER_SHARE
*
share
,
...
...
storage/spider/spd_trx.cc
View file @
3e206a51
/* Copyright (C) 2008-201
4
Kentoku Shiba
/* Copyright (C) 2008-201
5
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
...
...
@@ -38,11 +38,14 @@
#include "spd_ping_table.h"
#include "spd_malloc.h"
#ifdef SPIDER_XID_USES_xid_cache_iterate
#else
#ifdef XID_CACHE_IS_SPLITTED
extern
uint
*
spd_db_att_xid_cache_split_num
;
#endif
extern
pthread_mutex_t
*
spd_db_att_LOCK_xid_cache
;
extern
HASH
*
spd_db_att_xid_cache
;
#endif
extern
struct
charset_info_st
*
spd_charset_utf8_bin
;
extern
handlerton
*
spider_hton_ptr
;
...
...
@@ -1641,14 +1644,24 @@ int spider_xa_lock(
int
error_num
;
const
char
*
old_proc_info
;
DBUG_ENTER
(
"spider_xa_lock"
);
#ifdef SPIDER_XID_USES_xid_cache_iterate
#else
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
my_hash_value_type
hash_value
=
my_calc_hash
(
spd_db_att_xid_cache
,
(
uchar
*
)
xid_state
->
xid
.
key
(),
xid_state
->
xid
.
key_length
());
#ifdef XID_CACHE_IS_SPLITTED
uint
idx
=
hash_value
%
*
spd_db_att_xid_cache_split_num
;
#endif
#endif
#endif
old_proc_info
=
thd_proc_info
(
thd
,
"Locking xid by Spider"
);
#ifdef SPIDER_XID_USES_xid_cache_iterate
if
(
xid_cache_insert
(
thd
,
xid_state
))
{
error_num
=
my_errno
;
goto
error
;
}
#else
#ifdef XID_CACHE_IS_SPLITTED
pthread_mutex_lock
(
&
spd_db_att_LOCK_xid_cache
[
idx
]);
#else
...
...
@@ -1689,15 +1702,19 @@ int spider_xa_lock(
pthread_mutex_unlock
(
&
spd_db_att_LOCK_xid_cache
[
idx
]);
#else
pthread_mutex_unlock
(
spd_db_att_LOCK_xid_cache
);
#endif
#endif
thd_proc_info
(
thd
,
old_proc_info
);
DBUG_RETURN
(
0
);
error:
#ifdef SPIDER_XID_USES_xid_cache_iterate
#else
#ifdef XID_CACHE_IS_SPLITTED
pthread_mutex_unlock
(
&
spd_db_att_LOCK_xid_cache
[
idx
]);
#else
pthread_mutex_unlock
(
spd_db_att_LOCK_xid_cache
);
#endif
#endif
thd_proc_info
(
thd
,
old_proc_info
);
DBUG_RETURN
(
error_num
);
...
...
@@ -1709,14 +1726,20 @@ int spider_xa_unlock(
THD
*
thd
=
current_thd
;
const
char
*
old_proc_info
;
DBUG_ENTER
(
"spider_xa_unlock"
);
#ifdef SPIDER_XID_USES_xid_cache_iterate
#else
#if defined(SPIDER_HAS_HASH_VALUE_TYPE) && defined(HASH_UPDATE_WITH_HASH_VALUE)
my_hash_value_type
hash_value
=
my_calc_hash
(
spd_db_att_xid_cache
,
(
uchar
*
)
xid_state
->
xid
.
key
(),
xid_state
->
xid
.
key_length
());
#ifdef XID_CACHE_IS_SPLITTED
uint
idx
=
hash_value
%
*
spd_db_att_xid_cache_split_num
;
#endif
#endif
#endif
old_proc_info
=
thd_proc_info
(
thd
,
"Unlocking xid by Spider"
);
#ifdef SPIDER_XID_USES_xid_cache_iterate
xid_cache_delete
(
thd
,
xid_state
);
#else
#ifdef XID_CACHE_IS_SPLITTED
pthread_mutex_lock
(
&
spd_db_att_LOCK_xid_cache
[
idx
]);
#else
...
...
@@ -1737,6 +1760,7 @@ int spider_xa_unlock(
pthread_mutex_unlock
(
&
spd_db_att_LOCK_xid_cache
[
idx
]);
#else
pthread_mutex_unlock
(
spd_db_att_LOCK_xid_cache
);
#endif
#endif
thd_proc_info
(
thd
,
old_proc_info
);
DBUG_RETURN
(
0
);
...
...
@@ -1857,7 +1881,9 @@ int spider_internal_start_trx(
trx
->
internal_xid_state
.
xa_state
=
XA_ACTIVE
;
trx
->
internal_xid_state
.
xid
.
set
(
&
trx
->
xid
);
#ifdef SPIDER_XID_STATE_HAS_in_thd
trx
->
internal_xid_state
.
in_thd
=
1
;
#endif
if
((
error_num
=
spider_xa_lock
(
&
trx
->
internal_xid_state
)))
{
if
(
error_num
==
ER_SPIDER_XA_LOCKED_NUM
)
...
...
@@ -3729,6 +3755,7 @@ int spider_check_trx_and_get_conn(
spider
->
hs_w_conns
[
roop_count
]
=
NULL
;
#endif
}
bool
search_link_idx_is_checked
=
FALSE
;
for
(
roop_count
=
spider_conn_link_idx_next
(
share
->
link_statuses
,
spider
->
conn_link_idx
,
-
1
,
share
->
link_count
,
...
...
@@ -3740,6 +3767,8 @@ int spider_check_trx_and_get_conn(
)
{
uint
tgt_conn_kind
=
(
use_conn_kind
?
spider
->
conn_kind
[
roop_count
]
:
SPIDER_CONN_KIND_MYSQL
);
if
(
roop_count
==
spider
->
search_link_idx
)
search_link_idx_is_checked
=
TRUE
;
if
(
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(
...
...
@@ -3780,6 +3809,7 @@ int spider_check_trx_and_get_conn(
0
,
share
->
monitoring_kind
[
roop_count
],
share
->
monitoring_limit
[
roop_count
],
share
->
monitoring_flag
[
roop_count
],
TRUE
);
}
...
...
@@ -3821,6 +3851,7 @@ int spider_check_trx_and_get_conn(
0
,
share
->
monitoring_kind
[
roop_count
],
share
->
monitoring_limit
[
roop_count
],
share
->
monitoring_flag
[
roop_count
],
TRUE
);
}
...
...
@@ -3834,9 +3865,41 @@ int spider_check_trx_and_get_conn(
#endif
#endif
}
if
(
!
search_link_idx_is_checked
)
{
TABLE
*
table
=
spider
->
get_table
();
TABLE_SHARE
*
table_share
=
table
->
s
;
#ifdef _MSC_VER
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
);
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
}
#else
char
db
[
table_share
->
db
.
length
+
1
],
table_name
[
table_share
->
table_name
.
length
+
1
];
#endif
memcpy
(
db
,
table_share
->
db
.
str
,
table_share
->
db
.
length
);
db
[
table_share
->
db
.
length
]
=
'\0'
;
memcpy
(
table_name
,
table_share
->
table_name
.
str
,
table_share
->
table_name
.
length
);
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
);
#ifdef _MSC_VER
spider_free
(
trx
,
db
,
MYF
(
MY_WME
));
#endif
DBUG_RETURN
(
ER_SPIDER_LINK_MON_JUST_NG_NUM
);
}
}
else
{
DBUG_PRINT
(
"info"
,(
"spider link_status = %ld"
,
share
->
link_statuses
[
spider
->
conn_link_idx
[
spider
->
search_link_idx
]]));
bool
search_link_idx_is_checked
=
FALSE
;
for
(
roop_count
=
spider_conn_link_idx_next
(
share
->
link_statuses
,
spider
->
conn_link_idx
,
-
1
,
share
->
link_count
,
...
...
@@ -3846,6 +3909,8 @@ int spider_check_trx_and_get_conn(
spider
->
conn_link_idx
,
roop_count
,
share
->
link_count
,
SPIDER_LINK_STATUS_RECOVERY
)
)
{
if
(
roop_count
==
spider
->
search_link_idx
)
search_link_idx_is_checked
=
TRUE
;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if
(
!
use_conn_kind
||
...
...
@@ -3890,6 +3955,7 @@ int spider_check_trx_and_get_conn(
0
,
share
->
monitoring_kind
[
roop_count
],
share
->
monitoring_limit
[
roop_count
],
share
->
monitoring_flag
[
roop_count
],
TRUE
);
}
...
...
@@ -3932,6 +3998,7 @@ int spider_check_trx_and_get_conn(
0
,
share
->
monitoring_kind
[
roop_count
],
share
->
monitoring_limit
[
roop_count
],
share
->
monitoring_flag
[
roop_count
],
TRUE
);
}
...
...
@@ -3944,6 +4011,37 @@ int spider_check_trx_and_get_conn(
#endif
#endif
}
if
(
!
search_link_idx_is_checked
)
{
TABLE
*
table
=
spider
->
get_table
();
TABLE_SHARE
*
table_share
=
table
->
s
;
#ifdef _MSC_VER
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
);
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
}
#else
char
db
[
table_share
->
db
.
length
+
1
],
table_name
[
table_share
->
table_name
.
length
+
1
];
#endif
memcpy
(
db
,
table_share
->
db
.
str
,
table_share
->
db
.
length
);
db
[
table_share
->
db
.
length
]
=
'\0'
;
memcpy
(
table_name
,
table_share
->
table_name
.
str
,
table_share
->
table_name
.
length
);
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
);
#ifdef _MSC_VER
spider_free
(
trx
,
db
,
MYF
(
MY_WME
));
#endif
DBUG_RETURN
(
ER_SPIDER_LINK_MON_JUST_NG_NUM
);
}
}
spider
->
set_first_link_idx
();
DBUG_RETURN
(
spider_create_trx_ha
(
trx
,
spider
,
trx_ha
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment