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
39703a1b
Commit
39703a1b
authored
Nov 23, 2009
by
Mikael Ronstrom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WL#5138, fixed review comments
parent
0e613ab8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
25 deletions
+15
-25
sql/event_scheduler.cc
sql/event_scheduler.cc
+1
-9
sql/log_event.cc
sql/log_event.cc
+0
-6
sql/mysql_priv.h
sql/mysql_priv.h
+11
-0
sql/mysqld.cc
sql/mysqld.cc
+3
-0
sql/sp_head.cc
sql/sp_head.cc
+0
-2
sql/sql_parse.cc
sql/sql_parse.cc
+0
-8
No files found.
sql/event_scheduler.cc
View file @
39703a1b
...
...
@@ -133,10 +133,8 @@ post_init_event_thread(THD *thd)
pthread_mutex_lock
(
&
LOCK_thread_count
);
threads
.
append
(
thd
);
thread_count
++
;
pthread_mutex_unlock
(
&
LOCK_thread_count
);
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
inc_thread_running
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
return
FALSE
;
}
...
...
@@ -158,9 +156,7 @@ deinit_event_thread(THD *thd)
DBUG_PRINT
(
"exit"
,
(
"Event thread finishing"
));
pthread_mutex_lock
(
&
LOCK_thread_count
);
thread_count
--
;
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
dec_thread_running
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
delete
thd
;
pthread_cond_broadcast
(
&
COND_thread_count
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
...
...
@@ -421,9 +417,7 @@ Event_scheduler::start()
net_end
(
&
new_thd
->
net
);
pthread_mutex_lock
(
&
LOCK_thread_count
);
thread_count
--
;
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
dec_thread_running
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
delete
new_thd
;
pthread_cond_broadcast
(
&
COND_thread_count
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
...
...
@@ -556,9 +550,7 @@ error:
net_end
(
&
new_thd
->
net
);
pthread_mutex_lock
(
&
LOCK_thread_count
);
thread_count
--
;
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
dec_thread_running
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
delete
new_thd
;
pthread_cond_broadcast
(
&
COND_thread_count
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
...
...
sql/log_event.cc
View file @
39703a1b
...
...
@@ -3056,9 +3056,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
{
thd
->
set_time
((
time_t
)
when
);
thd
->
set_query
((
char
*
)
query_arg
,
q_len_arg
);
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
thd
->
query_id
=
next_query_id
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
thd
->
variables
.
pseudo_thread_id
=
thread_id
;
// for temp tables
DBUG_PRINT
(
"query"
,(
"%s"
,
thd
->
query
()));
...
...
@@ -4581,9 +4579,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
if
(
rpl_filter
->
db_ok
(
thd
->
db
))
{
thd
->
set_time
((
time_t
)
when
);
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
thd
->
query_id
=
next_query_id
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
thd
->
warning_info
->
opt_clear_warning_info
(
thd
->
query_id
);
TABLE_LIST
tables
;
...
...
@@ -8072,9 +8068,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
DBUG_ASSERT
(
rli
->
sql_thd
==
thd
);
/* Step the query id to mark what columns that are actually used. */
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
thd
->
query_id
=
next_query_id
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
if
(
!
(
memory
=
my_multi_malloc
(
MYF
(
MY_WME
),
&
table_list
,
(
uint
)
sizeof
(
RPL_TABLE_LIST
),
...
...
sql/mysql_priv.h
View file @
39703a1b
...
...
@@ -90,19 +90,24 @@ typedef int64 query_id_t;
extern
query_id_t
global_query_id
;
extern
int32
thread_running
;
extern
my_atomic_rwlock_t
global_query_id_lock
;
extern
my_atomic_rwlock_t
thread_running_lock
;
/* increment query_id and return it. */
inline
query_id_t
next_query_id
()
{
query_id_t
id
;
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
id
=
my_atomic_add64
(
&
global_query_id
,
1
);
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
return
(
id
+
1
);
}
inline
query_id_t
get_query_id
()
{
query_id_t
id
;
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
id
=
my_atomic_load64
(
&
global_query_id
);
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
return
id
;
}
...
...
@@ -110,7 +115,9 @@ inline int32
inc_thread_running
()
{
int32
num_thread_running
;
my_atomic_rwlock_wrlock
(
&
thread_running_lock
);
num_thread_running
=
my_atomic_add32
(
&
thread_running
,
1
);
my_atomic_rwlock_wrunlock
(
&
thread_running_lock
);
return
(
num_thread_running
+
1
);
}
...
...
@@ -118,7 +125,9 @@ inline int32
dec_thread_running
()
{
int32
num_thread_running
;
my_atomic_rwlock_wrlock
(
&
thread_running_lock
);
num_thread_running
=
my_atomic_add32
(
&
thread_running
,
-
1
);
my_atomic_rwlock_wrunlock
(
&
thread_running_lock
);
return
(
num_thread_running
-
1
);
}
...
...
@@ -126,7 +135,9 @@ inline int32
get_thread_running
()
{
int32
num_thread_running
;
my_atomic_rwlock_wrlock
(
&
thread_running_lock
);
num_thread_running
=
my_atomic_load32
(
&
thread_running
);
my_atomic_rwlock_wrunlock
(
&
thread_running_lock
);
return
num_thread_running
;
}
...
...
sql/mysqld.cc
View file @
39703a1b
...
...
@@ -549,6 +549,7 @@ ulong query_cache_size=0;
ulong
refresh_version
;
/* Increments on each reload */
query_id_t
global_query_id
;
my_atomic_rwlock_t
global_query_id_lock
;
my_atomic_rwlock_t
thread_running_lock
;
ulong
aborted_threads
,
aborted_connects
;
ulong
delayed_insert_timeout
,
delayed_insert_limit
,
delayed_queue_size
;
ulong
delayed_insert_threads
,
delayed_insert_writes
,
delayed_rows_in_use
;
...
...
@@ -1383,6 +1384,7 @@ void clean_up(bool print_message)
/* Tell main we are ready */
logger
.
cleanup_end
();
my_atomic_rwlock_destroy
(
&
global_query_id_lock
);
my_atomic_rwlock_destroy
(
&
thread_running_lock
);
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
DBUG_PRINT
(
"quit"
,
(
"got thread count lock"
));
ready_to_exit
=
1
;
...
...
@@ -7799,6 +7801,7 @@ static int mysql_init_variables(void)
refresh_version
=
1L
;
/* Increments on each reload */
global_query_id
=
thread_id
=
1L
;
my_atomic_rwlock_init
(
&
global_query_id_lock
);
my_atomic_rwlock_init
(
&
thread_running_lock
);
strmov
(
server_version
,
MYSQL_SERVER_VERSION
);
myisam_recover_options_str
=
sql_mode_str
=
"OFF"
;
myisam_stats_method_str
=
"nulls_unequal"
;
...
...
sql/sp_head.cc
View file @
39703a1b
...
...
@@ -2736,9 +2736,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
*/
thd
->
lex
=
m_lex
;
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
thd
->
query_id
=
next_query_id
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
if
(
thd
->
prelocked_mode
==
NON_PRELOCKED
)
{
...
...
sql/sql_parse.cc
View file @
39703a1b
...
...
@@ -495,9 +495,7 @@ static void handle_bootstrap_impl(THD *thd)
We don't need to obtain LOCK_thread_count here because in bootstrap
mode we have only one thread.
*/
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
thd
->
query_id
=
next_query_id
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
thd
->
set_time
();
mysql_parse
(
thd
,
thd
->
query
(),
length
,
&
found_semicolon
);
close_thread_tables
(
thd
);
// Free tables
...
...
@@ -991,7 +989,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd
->
enable_slow_log
=
TRUE
;
thd
->
lex
->
sql_command
=
SQLCOM_END
;
/* to avoid confusing VIEW detectors */
thd
->
set_time
();
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
{
query_id_t
query_id
;
switch
(
command
)
{
...
...
@@ -1014,7 +1011,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd
->
query_id
=
query_id
;
}
inc_thread_running
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
/**
Clear the set of flags that are expected to be cleared at the
...
...
@@ -1284,9 +1280,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
Count each statement from the client.
*/
statistic_increment
(
thd
->
status_var
.
questions
,
&
LOCK_status
);
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
thd
->
query_id
=
next_query_id
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
thd
->
set_time
();
/* Reset the query start time. */
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
mysql_parse
(
thd
,
beginning_of_next_stmt
,
length
,
&
end_of_stmt
);
...
...
@@ -1604,9 +1598,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd_proc_info
(
thd
,
"cleaning up"
);
thd
->
set_query
(
NULL
,
0
);
thd
->
command
=
COM_SLEEP
;
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
dec_thread_running
();
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
thd_proc_info
(
thd
,
0
);
thd
->
packet
.
shrink
(
thd
->
variables
.
net_buffer_length
);
// Reclaim some memory
free_root
(
thd
->
mem_root
,
MYF
(
MY_KEEP_PREALLOC
));
...
...
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