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
391fddf6
Commit
391fddf6
authored
Sep 18, 2014
by
Kentoku SHIBA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge Spider 3.2.11
parent
c338772a
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
508 additions
and
109 deletions
+508
-109
storage/spider/CMakeLists.txt
storage/spider/CMakeLists.txt
+8
-6
storage/spider/ha_spider.cc
storage/spider/ha_spider.cc
+181
-49
storage/spider/ha_spider.h
storage/spider/ha_spider.h
+4
-0
storage/spider/spd_conn.cc
storage/spider/spd_conn.cc
+15
-8
storage/spider/spd_db_conn.cc
storage/spider/spd_db_conn.cc
+63
-5
storage/spider/spd_db_conn.h
storage/spider/spd_db_conn.h
+6
-0
storage/spider/spd_db_include.h
storage/spider/spd_db_include.h
+3
-2
storage/spider/spd_db_mysql.cc
storage/spider/spd_db_mysql.cc
+40
-6
storage/spider/spd_db_oracle.cc
storage/spider/spd_db_oracle.cc
+6
-0
storage/spider/spd_direct_sql.cc
storage/spider/spd_direct_sql.cc
+56
-19
storage/spider/spd_include.h
storage/spider/spd_include.h
+7
-2
storage/spider/spd_malloc.cc
storage/spider/spd_malloc.cc
+2
-1
storage/spider/spd_table.cc
storage/spider/spd_table.cc
+117
-11
No files found.
storage/spider/CMakeLists.txt
View file @
391fddf6
...
...
@@ -33,9 +33,7 @@ IF(EXISTS ${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake)
MYSQL_STORAGE_ENGINE
(
SPIDER
)
ELSE
()
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/storage/spider/hs_client
${
ORACLE_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/storage/spider/hs_client
)
INSTALL
(
FILES
${
CMAKE_SOURCE_DIR
}
/storage/spider/scripts/install_spider.sql
...
...
@@ -46,7 +44,11 @@ ELSE()
ENDIF
()
IF
(
ORACLE_INCLUDE_DIR AND ORACLE_OCI_LIBRARY
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT"
)
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT"
)
TARGET_LINK_LIBRARIES
(
spider
${
ORACLE_OCI_LIBRARY
}
)
SET
(
SPIDER_WITH_ORACLE_OCI OFF CACHE BOOL
"Spider is compiled with Oracle OCI library."
)
IF
(
SPIDER_WITH_ORACLE_OCI
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT"
)
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT"
)
INCLUDE_DIRECTORIES
(
${
ORACLE_INCLUDE_DIR
}
)
TARGET_LINK_LIBRARIES
(
spider
${
ORACLE_OCI_LIBRARY
}
)
ENDIF
()
ENDIF
()
storage/spider/ha_spider.cc
View file @
391fddf6
This diff is collapsed.
Click to expand it.
storage/spider/ha_spider.h
View file @
391fddf6
...
...
@@ -658,6 +658,10 @@ public:
#endif
const
key_map
*
keys_to_use_for_scanning
();
ha_rows
estimate_rows_upper_bound
();
void
print_error
(
int
error
,
myf
errflag
);
bool
get_error_message
(
int
error
,
String
*
buf
...
...
storage/spider/spd_conn.cc
View file @
391fddf6
...
...
@@ -2505,14 +2505,21 @@ void *spider_bg_conn_action(
)
{
if
(
thd
->
is_error
())
{
SPIDER_BG_DIRECT_SQL
*
bg_direct_sql
=
(
SPIDER_BG_DIRECT_SQL
*
)
direct_sql
->
parent
;
pthread_mutex_lock
(
direct_sql
->
bg_mutex
);
bg_direct_sql
->
bg_error
=
spider_stmt_da_sql_errno
(
thd
);
strmov
((
char
*
)
bg_direct_sql
->
bg_error_msg
,
spider_stmt_da_message
(
thd
));
pthread_mutex_unlock
(
direct_sql
->
bg_mutex
);
is_error
=
TRUE
;
if
(
direct_sql
->
error_rw_mode
&&
spider_db_conn_is_network_error
(
error_num
)
)
{
thd
->
clear_error
();
}
else
{
SPIDER_BG_DIRECT_SQL
*
bg_direct_sql
=
(
SPIDER_BG_DIRECT_SQL
*
)
direct_sql
->
parent
;
pthread_mutex_lock
(
direct_sql
->
bg_mutex
);
bg_direct_sql
->
bg_error
=
spider_stmt_da_sql_errno
(
thd
);
strmov
((
char
*
)
bg_direct_sql
->
bg_error_msg
,
spider_stmt_da_message
(
thd
));
pthread_mutex_unlock
(
direct_sql
->
bg_mutex
);
is_error
=
TRUE
;
}
}
}
if
(
direct_sql
->
modified_non_trans_table
)
...
...
storage/spider/spd_db_conn.cc
View file @
391fddf6
...
...
@@ -26,6 +26,7 @@
#include "sql_analyse.h"
#include "sql_base.h"
#include "tztime.h"
#include "errmsg.h"
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
#include "sql_select.h"
#endif
...
...
@@ -637,8 +638,11 @@ int spider_db_errorno(
if
(
conn
->
server_lost
)
{
*
conn
->
need_mon
=
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM
;
my_message
(
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM
,
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR
,
MYF
(
0
));
if
(
!
current_thd
->
is_error
())
{
my_message
(
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM
,
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR
,
MYF
(
0
));
}
if
(
!
conn
->
mta_conn_mutex_unlock_later
)
{
SPIDER_CLEAR_FILE_POS
(
&
conn
->
mta_conn_mutex_file_pos
);
...
...
@@ -3199,7 +3203,8 @@ void spider_db_free_one_result_for_start_next(
result
=
(
SPIDER_RESULT
*
)
result_list
->
current
;
if
(
!
result
->
result
&&
!
result
->
first_position
!
result
->
first_position
&&
!
result
->
tmp_tbl_use_position
)
result_list
->
current
=
result
->
prev
;
}
...
...
@@ -3263,6 +3268,35 @@ void spider_db_free_one_result(
position
[
roop_count
].
row
=
NULL
;
}
}
if
(
result_list
->
quick_mode
==
3
)
{
if
(
!
result
->
first_pos_use_position
)
{
spider_free
(
spider_current_trx
,
position
,
MYF
(
0
));
result
->
first_position
=
NULL
;
}
if
(
result
->
result
)
{
result
->
result
->
free_result
();
delete
result
->
result
;
result
->
result
=
NULL
;
}
if
(
!
result
->
tmp_tbl_use_position
)
{
if
(
result
->
result_tmp_tbl
)
{
if
(
result
->
result_tmp_tbl_inited
)
{
result
->
result_tmp_tbl
->
file
->
ha_rnd_end
();
result
->
result_tmp_tbl_inited
=
0
;
}
spider_rm_sys_tmp_table_for_result
(
result
->
result_tmp_tbl_thd
,
result
->
result_tmp_tbl
,
&
result
->
result_tmp_tbl_prm
);
result
->
result_tmp_tbl
=
NULL
;
result
->
result_tmp_tbl_thd
=
NULL
;
}
}
}
}
}
DBUG_VOID_RETURN
;
...
...
@@ -3472,6 +3506,8 @@ int spider_db_free_result(
result
->
record_num
=
0
;
DBUG_PRINT
(
"info"
,(
"spider result->finish_flg = FALSE"
));
result
->
finish_flg
=
FALSE
;
result
->
first_pos_use_position
=
FALSE
;
result
->
tmp_tbl_use_position
=
FALSE
;
result
->
use_position
=
FALSE
;
result
=
(
SPIDER_RESULT
*
)
result
->
next
;
}
...
...
@@ -3872,8 +3908,10 @@ int spider_db_store_result(
DBUG_PRINT
(
"info"
,
(
"spider conn[%p]->quick_target=NULL"
,
conn
));
conn
->
quick_target
=
NULL
;
spider
->
quick_targets
[
link_idx
]
=
NULL
;
}
else
if
(
result_list
->
limit_num
==
roop_count
)
{
}
else
if
(
result_list
->
quick_mode
==
3
||
result_list
->
limit_num
==
roop_count
)
{
current
->
result
->
free_result
();
if
(
!
current
->
result_tmp_tbl
)
{
...
...
@@ -4176,6 +4214,7 @@ int spider_db_seek_next(
spider_next_split_read_param
(
spider
);
if
(
result_list
->
quick_mode
==
0
||
result_list
->
quick_mode
==
3
||
!
result_list
->
current
->
result
)
{
result_list
->
limit_num
=
...
...
@@ -4839,6 +4878,7 @@ void spider_db_create_position(
tmp_pos
->
use_position
=
TRUE
;
tmp_pos
->
pos_mode
=
0
;
pos
->
pos_mode
=
0
;
current
->
first_pos_use_position
=
TRUE
;
}
else
{
TABLE
*
tmp_tbl
=
current
->
result_tmp_tbl
;
pos
->
row
=
NULL
;
...
...
@@ -4848,6 +4888,7 @@ void spider_db_create_position(
DBUG_PRINT
(
"info"
,(
"spider tmp_tbl->file->ref=%p"
,
tmp_tbl
->
file
->
ref
));
tmp_tbl
->
file
->
ref
=
(
uchar
*
)
&
pos
->
tmp_tbl_pos
;
tmp_tbl
->
file
->
position
(
tmp_tbl
->
record
[
0
]);
current
->
tmp_tbl_use_position
=
TRUE
;
}
}
current
->
use_position
=
TRUE
;
...
...
@@ -10256,3 +10297,20 @@ void spider_db_hs_request_buf_reset(
DBUG_VOID_RETURN
;
}
#endif
bool
spider_db_conn_is_network_error
(
int
error_num
)
{
DBUG_ENTER
(
"spider_db_conn_is_network_error"
);
if
(
error_num
==
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM
||
error_num
==
ER_CONNECT_TO_FOREIGN_DATA_SOURCE
||
(
error_num
>=
CR_MIN_ERROR
&&
error_num
<=
CR_MAX_ERROR
)
)
{
DBUG_RETURN
(
TRUE
);
}
DBUG_RETURN
(
FALSE
);
}
storage/spider/spd_db_conn.h
View file @
391fddf6
...
...
@@ -69,6 +69,8 @@
#define SPIDER_SQL_UPDATE_LEN (sizeof(SPIDER_SQL_UPDATE_STR) - 1)
#define SPIDER_SQL_DELETE_STR "delete "
#define SPIDER_SQL_DELETE_LEN (sizeof(SPIDER_SQL_DELETE_STR) - 1)
#define SPIDER_SQL_DISTINCT_STR "distinct "
#define SPIDER_SQL_DISTINCT_LEN (sizeof(SPIDER_SQL_DISTINCT_STR) - 1)
#define SPIDER_SQL_HIGH_PRIORITY_STR "high_priority "
#define SPIDER_SQL_HIGH_PRIORITY_LEN (sizeof(SPIDER_SQL_HIGH_PRIORITY_STR) - 1)
#define SPIDER_SQL_LOW_PRIORITY_STR "low_priority "
...
...
@@ -1049,3 +1051,7 @@ void spider_db_hs_request_buf_reset(
SPIDER_CONN
*
conn
);
#endif
bool
spider_db_conn_is_network_error
(
int
error_num
);
storage/spider/spd_db_include.h
View file @
391fddf6
...
...
@@ -493,7 +493,6 @@ public:
uint32
arg_length
,
uint32
step_alloc
);
#ifdef SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE
bool
append_for_single_quote
(
const
char
*
st
,
uint
len
...
...
@@ -504,7 +503,6 @@ public:
bool
append_for_single_quote
(
const
char
*
st
);
#endif
void
print
(
String
*
print
);
...
...
@@ -1566,6 +1564,8 @@ typedef struct st_spider_result
longlong
record_num
;
bool
finish_flg
;
bool
use_position
;
bool
first_pos_use_position
;
bool
tmp_tbl_use_position
;
uint
field_count
;
/* for quick mode */
TABLE
*
result_tmp_tbl
;
TMP_TABLE_PARAM
result_tmp_tbl_prm
;
...
...
@@ -1642,6 +1642,7 @@ typedef struct st_spider_result_list
spider_bulk_upd_start
bulk_update_start
;
bool
check_direct_order_limit
;
bool
direct_order_limit
;
bool
direct_distinct
;
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
bool
direct_aggregate
;
bool
snap_mrr_with_cnt
;
...
...
storage/spider/spd_db_mysql.cc
View file @
391fddf6
...
...
@@ -919,13 +919,13 @@ int spider_db_mysql_result::fetch_table_cardinality(
Field
*
field
;
DBUG_ENTER
(
"spider_db_mysql_result::fetch_table_cardinality"
);
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
memset
((
uchar
*
)
cardinality_upd
,
0
,
sizeof
(
uchar
)
*
bitmap_size
);
if
(
!
(
mysql_row
=
mysql_fetch_row
(
db_result
)))
{
DBUG_PRINT
(
"info"
,(
"spider fetch row is null"
));
/* no index */
DBUG_RETURN
(
0
);
}
memset
((
uchar
*
)
cardinality_upd
,
0
,
sizeof
(
uchar
)
*
bitmap_size
);
if
(
mode
==
1
)
{
uint
num_fields
=
this
->
num_fields
();
...
...
@@ -2096,6 +2096,7 @@ int spider_db_mysql::rollback(
int
error_num
;
DBUG_ENTER
(
"spider_db_mysql::rollback"
);
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
conn
->
mta_conn_mutex_unlock_later
=
TRUE
;
if
(
spider_db_query
(
conn
,
SPIDER_SQL_ROLLBACK_STR
,
...
...
@@ -2104,7 +2105,6 @@ int spider_db_mysql::rollback(
need_mon
)
)
{
is_error
=
conn
->
thd
->
is_error
();
conn
->
mta_conn_mutex_unlock_later
=
TRUE
;
error_num
=
spider_db_errorno
(
conn
);
if
(
error_num
==
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM
&&
...
...
@@ -4814,6 +4814,21 @@ int spider_mysql_share::discover_table_structure(
)
{
DBUG_RETURN
(
error_num
);
}
if
(
!
conn
->
disable_reconnect
)
{
ha_spider
tmp_spider
;
int
need_mon
=
0
;
uint
tmp_conn_link_idx
=
0
;
tmp_spider
.
trx
=
trx
;
tmp_spider
.
share
=
spider_share
;
tmp_spider
.
need_mons
=
&
need_mon
;
tmp_spider
.
conn_link_idx
=
&
tmp_conn_link_idx
;
if
((
error_num
=
spider_db_ping
(
&
tmp_spider
,
conn
,
0
)))
{
DBUG_PRINT
(
"info"
,(
"spider spider_db_ping error"
));
continue
;
}
}
pthread_mutex_lock
(
&
conn
->
mta_conn_mutex
);
SPIDER_SET_FILE_POS
(
&
conn
->
mta_conn_mutex_file_pos
);
conn
->
need_mon
=
&
need_mon
;
...
...
@@ -4879,6 +4894,11 @@ int spider_mysql_share::discover_table_structure(
conn
->
mta_conn_mutex_unlock_later
=
FALSE
;
SPIDER_CLEAR_FILE_POS
(
&
conn
->
mta_conn_mutex_file_pos
);
pthread_mutex_unlock
(
&
conn
->
mta_conn_mutex
);
my_printf_error
(
ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM
,
ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR
,
MYF
(
0
),
db_names_str
[
roop_count
].
ptr
(),
table_names_str
[
roop_count
].
ptr
());
error_num
=
ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM
;
continue
;
}
res
->
free_result
();
...
...
@@ -6238,6 +6258,12 @@ int spider_mysql_handler::append_select(
if
(
str
->
reserve
(
SPIDER_SQL_SELECT_LEN
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
str
->
q_append
(
SPIDER_SQL_SELECT_STR
,
SPIDER_SQL_SELECT_LEN
);
if
(
result_list
->
direct_distinct
)
{
if
(
str
->
reserve
(
SPIDER_SQL_DISTINCT_LEN
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
str
->
q_append
(
SPIDER_SQL_DISTINCT_STR
,
SPIDER_SQL_DISTINCT_LEN
);
}
if
(
result_list
->
lock_type
!=
F_WRLCK
&&
spider
->
lock_mode
<
1
)
{
/* no lock */
...
...
@@ -10328,6 +10354,14 @@ int spider_mysql_handler::show_table_status(
DBUG_RETURN
(
error_num
);
}
}
if
(
share
->
static_records_for_status
!=
-
1
)
{
share
->
records
=
(
ha_rows
)
share
->
static_records_for_status
;
}
if
(
share
->
static_mean_rec_length
!=
-
1
)
{
share
->
mean_rec_length
=
(
ulong
)
share
->
static_mean_rec_length
;
}
if
(
auto_increment_value
>
share
->
lgtm_tblhnd_share
->
auto_increment_value
)
{
share
->
lgtm_tblhnd_share
->
auto_increment_value
=
auto_increment_value
;
...
...
@@ -10462,8 +10496,8 @@ int spider_mysql_handler::show_index(
if
(
!
spider_bit_is_set
(
share
->
cardinality_upd
,
roop_count
))
{
DBUG_PRINT
(
"info"
,
(
"spider
init
column cardinality id=%d"
,
roop_count
));
*
tmp_cardinality
=
1
;
(
"spider
uninitialized
column cardinality id=%d"
,
roop_count
));
*
tmp_cardinality
=
-
1
;
}
}
if
(
res
)
...
...
@@ -10596,8 +10630,8 @@ int spider_mysql_handler::show_index(
if
(
!
spider_bit_is_set
(
share
->
cardinality_upd
,
roop_count
))
{
DBUG_PRINT
(
"info"
,
(
"spider
init
column cardinality id=%d"
,
roop_count
));
*
tmp_cardinality
=
1
;
(
"spider
uninitialized
column cardinality id=%d"
,
roop_count
));
*
tmp_cardinality
=
-
1
;
}
}
if
(
res
)
...
...
storage/spider/spd_db_oracle.cc
View file @
391fddf6
...
...
@@ -5935,6 +5935,12 @@ int spider_oracle_handler::append_select(
if
(
str
->
reserve
(
SPIDER_SQL_SELECT_LEN
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
str
->
q_append
(
SPIDER_SQL_SELECT_STR
,
SPIDER_SQL_SELECT_LEN
);
if
(
spider
->
result_list
.
direct_distinct
)
{
if
(
str
->
reserve
(
SPIDER_SQL_DISTINCT_LEN
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
str
->
q_append
(
SPIDER_SQL_DISTINCT_STR
,
SPIDER_SQL_DISTINCT_LEN
);
}
}
DBUG_RETURN
(
0
);
}
...
...
storage/spider/spd_direct_sql.cc
View file @
391fddf6
...
...
@@ -1045,6 +1045,7 @@ int spider_udf_parse_direct_sql_param(
#else
direct_sql
->
use_real_table
=
-
1
;
#endif
direct_sql
->
error_rw_mode
=
-
1
;
for
(
roop_count
=
0
;
roop_count
<
direct_sql
->
table_count
;
roop_count
++
)
direct_sql
->
iop
[
roop_count
]
=
-
1
;
...
...
@@ -1123,9 +1124,10 @@ int spider_udf_parse_direct_sql_param(
MYF
(
0
),
tmp_ptr
);
goto
error
;
case
4
:
SPIDER_PARAM_INT_WITH_MAX
(
"erwm"
,
error_rw_mode
,
0
,
1
);
SPIDER_PARAM_STR
(
"host"
,
tgt_host
);
SPIDER_PARAM_STR
(
"user"
,
tgt_username
);
SPIDER_PARAM_INT_WITH_MAX
(
"port"
,
tgt_port
,
0
,
65535
);
SPIDER_PARAM_STR
(
"user"
,
tgt_username
);
error_num
=
ER_SPIDER_INVALID_UDF_PARAM_NUM
;
my_printf_error
(
error_num
,
ER_SPIDER_INVALID_UDF_PARAM_STR
,
MYF
(
0
),
tmp_ptr
);
...
...
@@ -1178,6 +1180,7 @@ int spider_udf_parse_direct_sql_param(
goto
error
;
case
13
:
SPIDER_PARAM_STR
(
"default_group"
,
tgt_default_group
);
SPIDER_PARAM_INT_WITH_MAX
(
"error_rw_mode"
,
error_rw_mode
,
0
,
1
);
error_num
=
ER_SPIDER_INVALID_UDF_PARAM_NUM
;
my_printf_error
(
error_num
,
ER_SPIDER_INVALID_UDF_PARAM_STR
,
MYF
(
0
),
tmp_ptr
);
...
...
@@ -1400,6 +1403,8 @@ int spider_udf_set_direct_sql_param_default(
if
(
direct_sql
->
use_real_table
==
-
1
)
direct_sql
->
use_real_table
=
0
;
#endif
if
(
direct_sql
->
error_rw_mode
==
-
1
)
direct_sql
->
error_rw_mode
=
0
;
for
(
roop_count
=
0
;
roop_count
<
direct_sql
->
table_count
;
roop_count
++
)
{
if
(
direct_sql
->
iop
[
roop_count
]
==
-
1
)
...
...
@@ -1526,12 +1531,14 @@ long long spider_direct_sql_body(
uint
use_real_table
=
0
;
#endif
DBUG_ENTER
(
"spider_direct_sql_body"
);
SPIDER_BACKUP_DASTATUS
;
if
(
!
(
direct_sql
=
(
SPIDER_DIRECT_SQL
*
)
spider_bulk_malloc
(
spider_current_trx
,
34
,
MYF
(
MY_WME
|
MY_ZEROFILL
),
&
direct_sql
,
sizeof
(
SPIDER_DIRECT_SQL
),
&
sql
,
sizeof
(
char
)
*
args
->
lengths
[
0
],
NullS
))
)
{
error_num
=
HA_ERR_OUT_OF_MEM
;
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
...
...
@@ -1556,48 +1563,51 @@ long long spider_direct_sql_body(
#endif
if
(
!
(
trx
=
spider_get_trx
(
thd
,
TRUE
,
&
error_num
)))
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
if
(
error_num
==
HA_ERR_OUT_OF_MEM
)
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
direct_sql
->
trx
=
trx
;
if
(
args
->
args
[
1
])
{
if
(
spider_udf_direct_sql_create_table_list
(
if
(
(
error_num
=
spider_udf_direct_sql_create_table_list
(
direct_sql
,
args
->
args
[
1
],
args
->
lengths
[
1
]
))
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
)))
{
if
(
error_num
==
HA_ERR_OUT_OF_MEM
)
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
}
else
{
if
(
spider_udf_direct_sql_create_table_list
(
if
(
(
error_num
=
spider_udf_direct_sql_create_table_list
(
direct_sql
,
(
char
*
)
""
,
0
))
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
)))
{
if
(
error_num
==
HA_ERR_OUT_OF_MEM
)
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
}
if
(
args
->
args
[
2
])
{
if
(
spider_udf_parse_direct_sql_param
(
if
(
(
error_num
=
spider_udf_parse_direct_sql_param
(
trx
,
direct_sql
,
args
->
args
[
2
],
args
->
lengths
[
2
]
))
{
))
)
{
goto
error
;
}
}
else
{
if
(
spider_udf_parse_direct_sql_param
(
if
(
(
error_num
=
spider_udf_parse_direct_sql_param
(
trx
,
direct_sql
,
""
,
0
))
{
))
)
{
goto
error
;
}
}
...
...
@@ -1626,6 +1636,7 @@ long long spider_direct_sql_body(
if
(
!
use_real_table
)
{
#endif
error_num
=
ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM
;
my_printf_error
(
ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM
,
ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_STR
,
MYF
(
0
),
table_list
.
db
,
table_list
.
table_name
);
...
...
@@ -1651,20 +1662,24 @@ long long spider_direct_sql_body(
#endif
}
}
if
(
spider_udf_direct_sql_create_conn_key
(
direct_sql
))
if
(
(
error_num
=
spider_udf_direct_sql_create_conn_key
(
direct_sql
)
))
{
if
(
error_num
==
HA_ERR_OUT_OF_MEM
)
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
if
(
!
(
conn
=
spider_udf_direct_sql_get_conn
(
direct_sql
,
trx
,
&
error_num
)))
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
if
(
error_num
==
HA_ERR_OUT_OF_MEM
)
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
conn
->
error_mode
=
0
;
direct_sql
->
conn
=
conn
;
if
(
spider_db_udf_check_and_set_set_names
(
trx
))
if
(
(
error_num
=
spider_db_udf_check_and_set_set_names
(
trx
)
))
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
if
(
error_num
==
HA_ERR_OUT_OF_MEM
)
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
if
(
args
->
args
[
0
])
...
...
@@ -1678,21 +1693,24 @@ long long spider_direct_sql_body(
#ifndef WITHOUT_SPIDER_BG_SEARCH
if
(
bg
)
{
if
(
spider_udf_bg_direct_sql
(
direct_sql
))
if
(
(
error_num
=
spider_udf_bg_direct_sql
(
direct_sql
)
))
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
if
(
error_num
==
HA_ERR_OUT_OF_MEM
)
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
}
else
{
#endif
if
(
conn
->
bg_init
)
pthread_mutex_lock
(
&
conn
->
bg_conn_mutex
);
if
(
spider_db_udf_direct_sql
(
direct_sql
))
if
(
(
error_num
=
spider_db_udf_direct_sql
(
direct_sql
)
))
{
if
(
conn
->
bg_init
)
pthread_mutex_unlock
(
&
conn
->
bg_conn_mutex
);
if
(
direct_sql
->
modified_non_trans_table
)
thd
->
transaction
.
stmt
.
modified_non_trans_table
=
TRUE
;
if
(
error_num
==
HA_ERR_OUT_OF_MEM
)
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
),
HA_ERR_OUT_OF_MEM
);
goto
error
;
}
if
(
conn
->
bg_init
)
...
...
@@ -1712,7 +1730,17 @@ long long spider_direct_sql_body(
error:
if
(
direct_sql
)
{
if
(
direct_sql
->
error_rw_mode
&&
spider_db_conn_is_network_error
(
error_num
)
)
{
SPIDER_RESTORE_DASTATUS
;
spider_udf_free_direct_sql_alloc
(
direct_sql
,
bg
);
DBUG_RETURN
(
1
);
}
spider_udf_free_direct_sql_alloc
(
direct_sql
,
bg
);
}
*
error
=
1
;
DBUG_RETURN
(
0
);
}
...
...
@@ -1790,6 +1818,15 @@ void spider_direct_sql_deinit_body(
DBUG_ENTER
(
"spider_direct_sql_deinit_body"
);
if
(
bg_direct_sql
)
{
pthread_mutex_lock
(
&
bg_direct_sql
->
bg_mutex
);
while
(
bg_direct_sql
->
direct_sql
)
pthread_cond_wait
(
&
bg_direct_sql
->
bg_cond
,
&
bg_direct_sql
->
bg_mutex
);
pthread_mutex_unlock
(
&
bg_direct_sql
->
bg_mutex
);
if
(
bg_direct_sql
->
modified_non_trans_table
)
{
THD
*
thd
=
current_thd
;
thd
->
transaction
.
stmt
.
modified_non_trans_table
=
TRUE
;
}
pthread_cond_destroy
(
&
bg_direct_sql
->
bg_cond
);
pthread_mutex_destroy
(
&
bg_direct_sql
->
bg_mutex
);
spider_free
(
spider_current_trx
,
bg_direct_sql
,
MYF
(
0
));
...
...
storage/spider/spd_include.h
View file @
391fddf6
...
...
@@ -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.
4
"
#define SPIDER_DETAIL_VERSION "3.2.
11
"
#define SPIDER_HEX_VERSION 0x0302
#if MYSQL_VERSION_ID < 50500
...
...
@@ -138,7 +138,7 @@
#define SPIDER_TMP_SHARE_LONG_COUNT 15
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
#define SPIDER_MEM_CALC_LIST_NUM 24
6
#define SPIDER_MEM_CALC_LIST_NUM 24
7
#define SPIDER_BACKUP_DASTATUS \
bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE;
...
...
@@ -709,9 +709,13 @@ typedef struct st_spider_share
time_t
create_time
;
time_t
update_time
;
longlong
static_records_for_status
;
longlong
static_mean_rec_length
;
int
bitmap_size
;
spider_string
*
key_hint
;
CHARSET_INFO
*
access_charset
;
longlong
*
static_key_cardinality
;
longlong
*
cardinality
;
uchar
*
cardinality_upd
;
longlong
additional_table_flags
;
...
...
@@ -1039,6 +1043,7 @@ typedef struct st_spider_direct_sql
#else
int
use_real_table
;
#endif
int
error_rw_mode
;
char
*
server_name
;
char
*
tgt_default_db_name
;
...
...
storage/spider/spd_malloc.cc
View file @
391fddf6
...
...
@@ -22,6 +22,7 @@
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h"
#include "sql_analyse.h"
#endif
#include "spd_db_include.h"
#include "spd_include.h"
...
...
@@ -1251,7 +1252,7 @@ bool spider_string::append_for_single_quote(
#ifdef SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE
bool
res
=
str
.
append_for_single_quote
(
s
);
#else
bool
res
=
append_escaped
(
&
str
,
s
);
bool
res
=
append_escaped
(
&
str
,
(
String
*
)
s
);
#endif
SPIDER_STRING_CALC_MEM
;
DBUG_RETURN
(
res
);
...
...
storage/spider/spd_table.cc
View file @
391fddf6
This diff is collapsed.
Click to expand it.
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