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
41043bb3
Commit
41043bb3
authored
Feb 22, 2005
by
jimw@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
ef4261d3
a50be4d4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
131 additions
and
38 deletions
+131
-38
extra/perror.c
extra/perror.c
+7
-6
mysql-test/r/multi_statement.result
mysql-test/r/multi_statement.result
+17
-0
mysql-test/t/multi_statement-master.opt
mysql-test/t/multi_statement-master.opt
+2
-0
mysql-test/t/multi_statement.test
mysql-test/t/multi_statement.test
+15
-0
sql/mysqld.cc
sql/mysqld.cc
+23
-2
sql/sql_acl.cc
sql/sql_acl.cc
+4
-2
sql/sql_parse.cc
sql/sql_parse.cc
+63
-28
No files found.
extra/perror.c
View file @
41043bb3
...
...
@@ -245,16 +245,17 @@ int main(int argc,char *argv[])
msg
=
strerror
(
code
);
/*
Don't print message for not existing error messages or for
unknown
errors. We test for 'Uknown Errors' just as an
extra safety for Netware
We don't print the OS error message if it is the same as the
unknown
_error message we retrieved above, or it starts with
'Unknown Error' (without regard to case).
*/
if
(
msg
&&
strcmp
(
msg
,
"Unknown Error"
)
&&
if
(
msg
&&
my_strnncoll
(
&
my_charset_latin1
,
msg
,
13
,
"Unknown Error"
,
13
)
&&
(
!
unknown_error
||
strcmp
(
msg
,
unknown_error
)))
{
found
=
1
;
if
(
verbose
)
printf
(
"
E
rror code %3d: %s
\n
"
,
code
,
msg
);
printf
(
"
OS e
rror code %3d: %s
\n
"
,
code
,
msg
);
else
puts
(
msg
);
}
...
...
@@ -269,7 +270,7 @@ int main(int argc,char *argv[])
else
{
if
(
verbose
)
printf
(
"MySQL error
: %3d =
%s
\n
"
,
code
,
msg
);
printf
(
"MySQL error
code %3d:
%s
\n
"
,
code
,
msg
);
else
puts
(
msg
);
}
...
...
mysql-test/r/multi_statement.result
View file @
41043bb3
...
...
@@ -31,3 +31,20 @@ select 5'abcd'
select 'finish';
finish
finish
flush status;
create table t1 (i int);
insert into t1 values (1);
select * from t1 where i = 1;
insert into t1 values (2),(3),(4);
select * from t1 where i = 2;
select * from t1 where i = 3||||
i
1
i
2
i
3
show status like 'Slow_queries'||||
Variable_name Value
Slow_queries 2
drop table t1||||
mysql-test/t/multi_statement-master.opt
0 → 100644
View file @
41043bb3
--log-slow-queries=slow.log
--log-queries-not-using-indexes
mysql-test/t/multi_statement.test
View file @
41043bb3
...
...
@@ -14,3 +14,18 @@ select "abcd'";'abcd'select "'abcd";'abcd'
select
5
'abcd'
delimiter
;
'abcd'
select
'finish'
;
# Bug #8475: Make sure every statement that is a slow query in
# a multi-statement query gets logged as a slow query.
flush
status
;
delimiter
||||
;
create
table
t1
(
i
int
);
insert
into
t1
values
(
1
);
select
*
from
t1
where
i
=
1
;
insert
into
t1
values
(
2
),(
3
),(
4
);
select
*
from
t1
where
i
=
2
;
select
*
from
t1
where
i
=
3
||||
show
status
like
'Slow_queries'
||||
drop
table
t1
||||
delimiter
;
||||
sql/mysqld.cc
View file @
41043bb3
...
...
@@ -316,12 +316,14 @@ my_bool opt_old_style_user_limits= 0;
volatile
bool
mqh_used
=
0
;
my_bool
sp_automatic_privileges
=
1
;
#ifdef HAVE_INITGROUPS
static
bool
calling_initgroups
=
FALSE
;
/* Used in SIGSEGV handler. */
#endif
uint
mysqld_port
,
test_flags
,
select_errors
,
dropping_tables
,
ha_open_options
;
uint
delay_key_write_options
,
protocol_version
;
uint
lower_case_table_names
;
uint
tc_heuristic_recover
=
0
;
uint
volatile
thread_count
,
thread_running
,
kill_cached_threads
,
wake_thread
;
ulong
back_log
,
connect_timeout
,
concurrency
;
ulong
server_id
,
thd_startup_options
;
ulong
table_cache_size
,
thread_stack
,
thread_stack_min
,
what_to_log
;
...
...
@@ -1166,7 +1168,15 @@ static void set_user(const char *user, struct passwd *user_info)
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
DBUG_ASSERT
(
user_info
);
#ifdef HAVE_INITGROUPS
initgroups
((
char
*
)
user
,
user_info
->
pw_gid
);
/*
We can get a SIGSEGV when calling initgroups() on some systems when NSS
is configured to use LDAP and the server is statically linked. We set
calling_initgroups as a flag to the SIGSEGV handler that is then used to
output a specific message to help the user resolve this problem.
*/
calling_initgroups
=
TRUE
;
initgroups
((
char
*
)
user
,
user_info
->
pw_gid
);
calling_initgroups
=
FALSE
;
#endif
if
(
setgid
(
user_info
->
pw_gid
)
==
-
1
)
{
...
...
@@ -1921,6 +1931,17 @@ information that should help you find out what is causing the crash.\n");
fflush
(
stderr
);
#endif
/* HAVE_STACKTRACE */
#ifdef HAVE_INITGROUPS
if
(
calling_initgroups
)
fprintf
(
stderr
,
"
\n
\
This crash occured while the server was calling initgroups(). This is
\n
\
often due to the use of a mysqld that is statically linked against glibc
\n
\
and configured to use LDAP in /etc/nsswitch.conf. You will need to either
\n
\
upgrade to a version of glibc that does not have this problem (2.3.4 or
\n
\
later when used with nscd), disable LDAP in your nsswitch.conf, or use a
\n
\
mysqld that is not statically linked.
\n
"
);
#endif
if
(
test_flags
&
TEST_CORE_ON_SIGNAL
)
{
fprintf
(
stderr
,
"Writing a core file
\n
"
);
...
...
sql/sql_acl.cc
View file @
41043bb3
...
...
@@ -212,7 +212,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
if
(
strcmp
(
host
.
db
,
tmp_name
)
!=
0
)
sql_print_warning
(
"'host' entry '%s|%s' had database in mixed "
"case that has been forced to lowercase because "
"lower_case_table_names is set."
,
"lower_case_table_names is set. It will not be "
"possible to remove this privilege using REVOKE."
,
host
.
host
.
hostname
,
host
.
db
);
}
host
.
access
=
get_access
(
table
,
2
);
...
...
@@ -437,7 +438,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
{
sql_print_warning
(
"'db' entry '%s %s@%s' had database in mixed "
"case that has been forced to lowercase because "
"lower_case_table_names is set."
,
"lower_case_table_names is set. It will not be "
"possible to remove this privilege using REVOKE."
,
db
.
db
,
db
.
user
,
db
.
host
.
hostname
,
db
.
host
.
hostname
);
}
}
...
...
sql/sql_parse.cc
View file @
41043bb3
...
...
@@ -60,6 +60,7 @@
extern
"C"
int
gethostname
(
char
*
name
,
int
namelen
);
#endif
static
void
time_out_user_resource_limits
(
THD
*
thd
,
USER_CONN
*
uc
);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
static
int
check_for_max_user_connections
(
THD
*
thd
,
USER_CONN
*
uc
);
#endif
...
...
@@ -70,6 +71,7 @@ static void remove_escape(char *name);
static
void
refresh_status
(
void
);
static
bool
append_file_to_dir
(
THD
*
thd
,
const
char
**
filename_ptr
,
const
char
*
table_name
);
static
void
log_slow_query
(
THD
*
thd
);
const
char
*
any_db
=
"*any*"
;
// Special symbol for check_access
...
...
@@ -486,6 +488,7 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc)
error
=
1
;
goto
end
;
}
time_out_user_resource_limits
(
thd
,
uc
);
if
(
uc
->
user_resources
.
user_conn
&&
uc
->
user_resources
.
user_conn
<
uc
->
connections
)
{
...
...
@@ -604,36 +607,56 @@ bool is_update_query(enum enum_sql_command command)
}
/*
Check if maximum queries per hour limit has been reached
returns 0 if OK.
Reset per-hour user resource limits when it has been more than
an hour since they were last checked
In theory we would need a mutex in the USER_CONN structure for this to
be 100 % safe, but as the worst scenario is that we would miss counting
a couple of queries, this isn't critical.
*/
SYNOPSIS:
time_out_user_resource_limits()
thd Thread handler
uc User connection details
NOTE:
This assumes that the LOCK_user_conn mutex has been acquired, so it is
safe to test and modify members of the USER_CONN structure.
*/
static
bool
check_mqh
(
THD
*
thd
,
uint
check_command
)
static
void
time_out_user_resource_limits
(
THD
*
thd
,
USER_CONN
*
uc
)
{
#ifdef NO_EMBEDDED_ACCESS_CHECKS
return
(
0
);
#else
bool
error
=
0
;
bool
error
=
0
;
time_t
check_time
=
thd
->
start_time
?
thd
->
start_time
:
time
(
NULL
);
USER_CONN
*
uc
=
thd
->
user_connect
;
DBUG_ENTER
(
"check_mqh"
);
DBUG_ASSERT
(
uc
!=
0
);
DBUG_ENTER
(
"time_out_user_resource_limits"
);
/* If more than a hour since last check, reset resource checking */
if
(
check_time
-
uc
->
intime
>=
3600
)
{
(
void
)
pthread_mutex_lock
(
&
LOCK_user_conn
);
uc
->
questions
=
1
;
uc
->
updates
=
0
;
uc
->
conn_per_hour
=
0
;
uc
->
intime
=
check_time
;
(
void
)
pthread_mutex_unlock
(
&
LOCK_user_conn
);
}
DBUG_VOID_RETURN
;
}
/*
Check if maximum queries per hour limit has been reached
returns 0 if OK.
*/
static
bool
check_mqh
(
THD
*
thd
,
uint
check_command
)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
bool
error
=
0
;
time_t
check_time
=
thd
->
start_time
?
thd
->
start_time
:
time
(
NULL
);
USER_CONN
*
uc
=
thd
->
user_connect
;
DBUG_ENTER
(
"check_mqh"
);
DBUG_ASSERT
(
uc
!=
0
);
(
void
)
pthread_mutex_lock
(
&
LOCK_user_conn
);
time_out_user_resource_limits
(
thd
,
uc
);
/* Check that we have not done too many questions / hour */
if
(
uc
->
user_resources
.
questions
&&
uc
->
questions
++
>=
uc
->
user_resources
.
questions
)
...
...
@@ -656,7 +679,10 @@ static bool check_mqh(THD *thd, uint check_command)
}
}
end:
(
void
)
pthread_mutex_unlock
(
&
LOCK_user_conn
);
DBUG_RETURN
(
error
);
#else
return
(
0
);
#endif
/* NO_EMBEDDED_ACCESS_CHECKS */
}
...
...
@@ -1630,6 +1656,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#endif
ulong
length
=
(
ulong
)(
packet_end
-
packet
);
log_slow_query
(
thd
);
/* Remove garbage at start of query */
while
(
my_isspace
(
thd
->
charset
(),
*
packet
)
&&
length
>
0
)
{
...
...
@@ -1640,6 +1668,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd
->
query_length
=
length
;
thd
->
query
=
packet
;
thd
->
query_id
=
next_query_id
();
thd
->
set_time
();
/* Reset the query start time. */
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
#ifndef EMBEDDED_LIBRARY
...
...
@@ -1968,6 +1997,24 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if
(
thd
->
net
.
report_error
)
net_send_error
(
thd
);
log_slow_query
(
thd
);
thd
->
proc_info
=
"cleaning up"
;
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
// For process list
thd
->
proc_info
=
0
;
thd
->
command
=
COM_SLEEP
;
thd
->
query
=
0
;
thd
->
query_length
=
0
;
thread_running
--
;
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
thd
->
packet
.
shrink
(
thd
->
variables
.
net_buffer_length
);
// Reclaim some memory
free_root
(
thd
->
mem_root
,
MYF
(
MY_KEEP_PREALLOC
));
DBUG_RETURN
(
error
);
}
static
void
log_slow_query
(
THD
*
thd
)
{
time_t
start_of_query
=
thd
->
start_time
;
thd
->
end_time
();
// Set start time
...
...
@@ -1986,18 +2033,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
mysql_slow_log
.
write
(
thd
,
thd
->
query
,
thd
->
query_length
,
start_of_query
);
}
}
thd
->
proc_info
=
"cleaning up"
;
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
// For process list
thd
->
proc_info
=
0
;
thd
->
command
=
COM_SLEEP
;
thd
->
query
=
0
;
thd
->
query_length
=
0
;
thread_running
--
;
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
thd
->
packet
.
shrink
(
thd
->
variables
.
net_buffer_length
);
// Reclaim some memory
free_root
(
thd
->
mem_root
,
MYF
(
MY_KEEP_PREALLOC
));
DBUG_RETURN
(
error
);
}
...
...
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