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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
33fc4f51
Commit
33fc4f51
authored
Mar 25, 2014
by
Kentoku SHIBA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add sendsql to error log
parent
9ef11967
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
32 deletions
+111
-32
storage/spider/spd_db_mysql.cc
storage/spider/spd_db_mysql.cc
+82
-31
storage/spider/spd_include.h
storage/spider/spd_include.h
+1
-1
storage/spider/spd_param.cc
storage/spider/spd_param.cc
+27
-0
storage/spider/spd_param.h
storage/spider/spd_param.h
+1
-0
No files found.
storage/spider/spd_db_mysql.cc
View file @
33fc4f51
...
...
@@ -1523,16 +1523,19 @@ int spider_db_mysql::exec_query(
int
quick_mode
)
{
int
error_num
;
uint
log_result_errors
=
spider_param_log_result_errors
();
DBUG_ENTER
(
"spider_db_mysql::exec_query"
);
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
if
(
spider_param_general_log
())
{
const
char
*
tgt_str
=
conn
->
tgt_host
;
uint32
tgt_len
=
conn
->
tgt_host_length
;
spider_string
tmp_query_str
(
length
+
conn
->
tgt_wrapper_length
+
tgt_len
+
(
SPIDER_SQL_SPACE_LEN
*
2
));
spider_string
tmp_query_str
;
tmp_query_str
.
init_calc_mem
(
230
);
tmp_query_str
.
length
(
0
);
if
(
tmp_query_str
.
reserve
(
length
+
conn
->
tgt_wrapper_length
+
tgt_len
+
(
SPIDER_SQL_SPACE_LEN
*
2
)))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
tmp_query_str
.
q_append
(
conn
->
tgt_wrapper
,
conn
->
tgt_wrapper_length
);
tmp_query_str
.
q_append
(
SPIDER_SQL_SPACE_STR
,
SPIDER_SQL_SPACE_LEN
);
tmp_query_str
.
q_append
(
tgt_str
,
tgt_len
);
...
...
@@ -1542,7 +1545,54 @@ int spider_db_mysql::exec_query(
tmp_query_str
.
length
());
}
error_num
=
mysql_real_query
(
db_conn
,
query
,
length
);
if
(
spider_param_log_result_errors
()
>=
2
&&
db_conn
->
warning_count
>
0
)
if
(
(
error_num
&&
log_result_errors
>=
1
)
||
(
log_result_errors
>=
2
&&
db_conn
->
warning_count
>
0
)
||
(
log_result_errors
>=
4
)
)
{
THD
*
thd
=
current_thd
;
uint
log_result_error_with_sql
=
spider_param_log_result_error_with_sql
();
if
(
log_result_error_with_sql
)
{
time_t
cur_time
=
(
time_t
)
time
((
time_t
*
)
0
);
struct
tm
lt
;
struct
tm
*
l_time
=
localtime_r
(
&
cur_time
,
&
lt
);
spider_string
tmp_query_str
;
tmp_query_str
.
init_calc_mem
(
243
);
uint
query_length
=
thd
->
query_length
();
if
((
log_result_error_with_sql
&
2
)
&&
query_length
)
{
Security_context
*
security_ctx
=
thd
->
security_ctx
;
tmp_query_str
.
length
(
0
);
if
(
tmp_query_str
.
reserve
(
query_length
+
1
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
tmp_query_str
.
q_append
(
thd
->
query
(),
query_length
);
fprintf
(
stderr
,
"%04d%02d%02d %02d:%02d:%02d [RECV SPIDER SQL] "
"from [%s][%s] to %ld: "
"sql: %s
\n
"
,
l_time
->
tm_year
+
1900
,
l_time
->
tm_mon
+
1
,
l_time
->
tm_mday
,
l_time
->
tm_hour
,
l_time
->
tm_min
,
l_time
->
tm_sec
,
security_ctx
->
user
?
security_ctx
->
user
:
"system user"
,
security_ctx
->
host_or_ip
,
thd
->
thread_id
,
tmp_query_str
.
c_ptr_safe
());
}
if
(
log_result_error_with_sql
&
1
)
{
tmp_query_str
.
length
(
0
);
if
(
tmp_query_str
.
reserve
(
length
+
1
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
tmp_query_str
.
q_append
(
query
,
length
);
fprintf
(
stderr
,
"%04d%02d%02d %02d:%02d:%02d [SEND SPIDER SQL] "
"from %ld to [%s] %ld: "
"sql: %s
\n
"
,
l_time
->
tm_year
+
1900
,
l_time
->
tm_mon
+
1
,
l_time
->
tm_mday
,
l_time
->
tm_hour
,
l_time
->
tm_min
,
l_time
->
tm_sec
,
thd
->
thread_id
,
conn
->
tgt_host
,
db_conn
->
thread_id
,
tmp_query_str
.
c_ptr_safe
());
}
}
if
(
log_result_errors
>=
2
&&
db_conn
->
warning_count
>
0
)
{
time_t
cur_time
=
(
time_t
)
time
((
time_t
*
)
0
);
struct
tm
lt
;
...
...
@@ -1552,12 +1602,12 @@ int spider_db_mysql::exec_query(
"affected_rows: %llu id: %llu status: %u warning_count: %u
\n
"
,
l_time
->
tm_year
+
1900
,
l_time
->
tm_mon
+
1
,
l_time
->
tm_mday
,
l_time
->
tm_hour
,
l_time
->
tm_min
,
l_time
->
tm_sec
,
conn
->
tgt_host
,
db_conn
->
thread_id
,
current_
thd
->
thread_id
,
conn
->
tgt_host
,
db_conn
->
thread_id
,
thd
->
thread_id
,
db_conn
->
affected_rows
,
db_conn
->
insert_id
,
db_conn
->
server_status
,
db_conn
->
warning_count
);
if
(
spider_param_log_result_errors
()
>=
3
)
print_warnings
(
l_time
);
}
else
if
(
spider_param_log_result_errors
()
>=
4
)
}
else
if
(
log_result_errors
>=
4
)
{
time_t
cur_time
=
(
time_t
)
time
((
time_t
*
)
0
);
struct
tm
lt
;
...
...
@@ -1567,10 +1617,11 @@ int spider_db_mysql::exec_query(
"affected_rows: %llu id: %llu status: %u warning_count: %u
\n
"
,
l_time
->
tm_year
+
1900
,
l_time
->
tm_mon
+
1
,
l_time
->
tm_mday
,
l_time
->
tm_hour
,
l_time
->
tm_min
,
l_time
->
tm_sec
,
conn
->
tgt_host
,
db_conn
->
thread_id
,
current_
thd
->
thread_id
,
conn
->
tgt_host
,
db_conn
->
thread_id
,
thd
->
thread_id
,
db_conn
->
affected_rows
,
db_conn
->
insert_id
,
db_conn
->
server_status
,
db_conn
->
warning_count
);
}
}
DBUG_RETURN
(
error_num
);
}
...
...
storage/spider/spd_include.h
View file @
33fc4f51
...
...
@@ -121,7 +121,7 @@
#define SPIDER_TMP_SHARE_LONG_COUNT 15
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
#define SPIDER_MEM_CALC_LIST_NUM 24
3
#define SPIDER_MEM_CALC_LIST_NUM 24
4
#define SPIDER_BACKUP_DASTATUS \
bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE;
...
...
storage/spider/spd_param.cc
View file @
33fc4f51
...
...
@@ -2827,6 +2827,32 @@ uint spider_param_log_result_errors()
DBUG_RETURN
(
spider_log_result_errors
);
}
static
uint
spider_log_result_error_with_sql
;
/*
0: no log
1: log spider sql at logging result errors
2: log user sql at logging result errors
3: log both sql at logging result errors
*/
static
MYSQL_SYSVAR_UINT
(
log_result_error_with_sql
,
spider_log_result_error_with_sql
,
PLUGIN_VAR_RQCMDARG
,
"Log sql at logging result errors"
,
NULL
,
NULL
,
0
,
0
,
3
,
0
);
uint
spider_param_log_result_error_with_sql
()
{
DBUG_ENTER
(
"spider_param_log_result_error_with_sql"
);
DBUG_RETURN
(
spider_log_result_error_with_sql
);
}
static
char
*
spider_version
=
(
char
*
)
SPIDER_DETAIL_VERSION
;
static
MYSQL_SYSVAR_STR
(
version
,
...
...
@@ -2988,6 +3014,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
#endif
MYSQL_SYSVAR
(
general_log
),
MYSQL_SYSVAR
(
log_result_errors
),
MYSQL_SYSVAR
(
log_result_error_with_sql
),
MYSQL_SYSVAR
(
version
),
MYSQL_SYSVAR
(
internal_xa_id_type
),
NULL
...
...
storage/spider/spd_param.h
View file @
33fc4f51
...
...
@@ -370,6 +370,7 @@ int spider_param_udf_ds_use_real_table(
#endif
my_bool
spider_param_general_log
();
uint
spider_param_log_result_errors
();
uint
spider_param_log_result_error_with_sql
();
uint
spider_param_internal_xa_id_type
(
THD
*
thd
);
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