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
24c01089
Commit
24c01089
authored
Feb 09, 2006
by
andrey@lmy004
Browse files
Options
Browse Files
Download
Plain Diff
Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into lmy004.:/work/mysql-5.1-events_i_s
parents
f8f8af97
67985360
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
197 additions
and
76 deletions
+197
-76
mysql-test/r/events.result
mysql-test/r/events.result
+67
-9
mysql-test/t/events.test
mysql-test/t/events.test
+66
-43
sql/event.cc
sql/event.cc
+57
-12
sql/event_priv.h
sql/event_priv.h
+3
-0
sql/event_timed.cc
sql/event_timed.cc
+2
-12
sql/sql_parse.cc
sql/sql_parse.cc
+2
-0
No files found.
mysql-test/r/events.result
View file @
24c01089
...
@@ -15,20 +15,11 @@ create event event2 on schedule every 2 second starts now() ends date_add(now(),
...
@@ -15,20 +15,11 @@ create event event2 on schedule every 2 second starts now() ends date_add(now(),
drop event event2;
drop event event2;
create event e_43 on schedule every 1 second do set @a = 5;
create event e_43 on schedule every 1 second do set @a = 5;
set global event_scheduler = 1;
set global event_scheduler = 1;
select sleep(2);
sleep(2)
0
alter event e_43 do alter event e_43 do set @a = 4;
alter event e_43 do alter event e_43 do set @a = 4;
select sleep(3);
sleep(3)
0
select db, name, body, status, interval_field, interval_value from mysql.event;
select db, name, body, status, interval_field, interval_value from mysql.event;
db name body status interval_field interval_value
db name body status interval_field interval_value
events_test e_43 set @a = 4 ENABLED SECOND 1
events_test e_43 set @a = 4 ENABLED SECOND 1
drop event e_43;
drop event e_43;
select sleep(1);
sleep(1)
0
set global event_scheduler = 0;
set global event_scheduler = 0;
create table t_event3 (a int, b float);
create table t_event3 (a int, b float);
drop event if exists event3;
drop event if exists event3;
...
@@ -121,6 +112,7 @@ drop event two_event;
...
@@ -121,6 +112,7 @@ drop event two_event;
drop event three_event;
drop event three_event;
drop user ev_test@localhost;
drop user ev_test@localhost;
drop event one_event;
drop event one_event;
"Sleep a bit so the server closes the second connection"
create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5;
create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5;
select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event;
select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event;
db name body definer convert_tz(execute_at, 'UTC', 'SYSTEM') on_completion
db name body definer convert_tz(execute_at, 'UTC', 'SYSTEM') on_completion
...
@@ -137,4 +129,70 @@ set event_scheduler=0;
...
@@ -137,4 +129,70 @@ set event_scheduler=0;
ERROR HY000: Variable 'event_scheduler' is a GLOBAL variable and should be set with SET GLOBAL
ERROR HY000: Variable 'event_scheduler' is a GLOBAL variable and should be set with SET GLOBAL
set global event_scheduler=2;
set global event_scheduler=2;
ERROR 42000: Variable 'event_scheduler' can't be set to the value of '2'
ERROR 42000: Variable 'event_scheduler' can't be set to the value of '2'
"DISABLE the scheduler. Testing that it does not work when the variable is 0"
set global event_scheduler=0;
select definer, name, db from mysql.event;
definer name db
select get_lock("test_lock1", 20);
get_lock("test_lock1", 20)
1
create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20);
"Should return 1 row"
select definer, name, db from mysql.event;
definer name db
root@localhost закачка events_test
"Should be only 1 process"
show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
select release_lock("test_lock1");
release_lock("test_lock1")
1
drop event закачка;
"Should have 0 events"
select count(*) from mysql.event;
count(*)
0
"ENABLE the scheduler and get a lock"
set global event_scheduler=1;
select get_lock("test_lock2", 20);
get_lock("test_lock2", 20)
1
"Create an event which tries to acquire a mutex. The event locks on the mutex"
create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20);
"Let some time pass to the event starts"
"Should have only 3 processes: the scheduler, our conn and the locked event"
show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
# event_scheduler NULL Connect # Sleeping NULL
# root events_test Connect # User lock select get_lock("test_lock2", 20)
"Release the mutex, the event worker should finish."
select release_lock("test_lock2");
release_lock("test_lock2")
1
drop event закачка;
set global event_scheduler=1;
select get_lock("test_lock2_1", 20);
get_lock("test_lock2_1", 20)
1
create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20);
"Should see 2 processes, one locked on get_lock("
"Shutting down the scheduler, it should wait for the running event"
set global event_scheduler=0;
"Should have only 3 processes: the scheduler, our conn and the locked event"
show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
# event_scheduler NULL Connect # Sleeping NULL
# root events_test Connect # User lock select get_lock("test_lock2_1", 20)
"Release the lock so the child process should finish. Hence the scheduler also"
select release_lock("test_lock2_1");
release_lock("test_lock2_1")
1
"Should have only our process now:"
show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
drop event закачка21;
drop database events_test;
drop database events_test;
mysql-test/t/events.test
View file @
24c01089
...
@@ -17,12 +17,12 @@ drop event event2;
...
@@ -17,12 +17,12 @@ drop event event2;
create
event
e_43
on
schedule
every
1
second
do
set
@
a
=
5
;
create
event
e_43
on
schedule
every
1
second
do
set
@
a
=
5
;
set
global
event_scheduler
=
1
;
set
global
event_scheduler
=
1
;
select
sleep
(
2
);
--
sleep
2
alter
event
e_43
do
alter
event
e_43
do
set
@
a
=
4
;
alter
event
e_43
do
alter
event
e_43
do
set
@
a
=
4
;
select
sleep
(
3
);
--
sleep
2
select
db
,
name
,
body
,
status
,
interval_field
,
interval_value
from
mysql
.
event
;
select
db
,
name
,
body
,
status
,
interval_field
,
interval_value
from
mysql
.
event
;
drop
event
e_43
;
drop
event
e_43
;
select
sleep
(
1
);
--
sleep
1
set
global
event_scheduler
=
0
;
set
global
event_scheduler
=
0
;
create
table
t_event3
(
a
int
,
b
float
);
create
table
t_event3
(
a
int
,
b
float
);
...
@@ -107,8 +107,8 @@ drop event one_event;
...
@@ -107,8 +107,8 @@ drop event one_event;
##INFORMATION_SCHEMA.EVENTS test end
##INFORMATION_SCHEMA.EVENTS test end
#
#
--
echo
"Sleep a bit so the server closes the second connection"
--
sleep
2
create
event
e_26
on
schedule
at
'2017-01-01 00:00:00'
disable
do
set
@
a
=
5
;
create
event
e_26
on
schedule
at
'2017-01-01 00:00:00'
disable
do
set
@
a
=
5
;
select
db
,
name
,
body
,
definer
,
convert_tz
(
execute_at
,
'UTC'
,
'SYSTEM'
),
on_completion
from
mysql
.
event
;
select
db
,
name
,
body
,
definer
,
convert_tz
(
execute_at
,
'UTC'
,
'SYSTEM'
),
on_completion
from
mysql
.
event
;
...
@@ -129,23 +129,38 @@ set event_scheduler=0;
...
@@ -129,23 +129,38 @@ set event_scheduler=0;
--
error
1231
--
error
1231
set
global
event_scheduler
=
2
;
set
global
event_scheduler
=
2
;
#set global event_scheduler=0;
--
echo
"DISABLE the scheduler. Testing that it does not work when the variable is 0"
#select count(*) from mysql.event;
set
global
event_scheduler
=
0
;
#select get_lock("test_lock1", 20);
select
definer
,
name
,
db
from
mysql
.
event
;
#create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20);
select
get_lock
(
"test_lock1"
,
20
);
#select count(*) from mysql.event;
create
event
закачка
on
schedule
every
10
hour
do
select
get_lock
(
"test_lock1"
,
20
);
##show processlist;
--
echo
"Should return 1 row"
#select release_lock("test_lock1");
select
definer
,
name
,
db
from
mysql
.
event
;
#drop event закачка;
#select count(*) from mysql.event;
--
echo
"Should be only 1 process"
--
replace_column
1
# 6 #
show
processlist
;
select
release_lock
(
"test_lock1"
);
drop
event
закачка
;
--
echo
"Should have 0 events"
select
count
(
*
)
from
mysql
.
event
;
#
#
#set global event_scheduler=1;
#
#select get_lock("test_lock2", 20);
#
#create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20);
--
echo
"ENABLE the scheduler and get a lock"
#select sleep(2);
set
global
event_scheduler
=
1
;
#show processlist;
select
get_lock
(
"test_lock2"
,
20
);
#select release_lock("test_lock2");
--
echo
"Create an event which tries to acquire a mutex. The event locks on the mutex"
#drop event закачка;
create
event
закачка
on
schedule
every
10
hour
do
select
get_lock
(
"test_lock2"
,
20
);
--
echo
"Let some time pass to the event starts"
--
sleep
2
--
echo
"Should have only 3 processes: the scheduler, our conn and the locked event"
--
replace_column
1
# 6 #
show
processlist
;
--
echo
"Release the mutex, the event worker should finish."
select
release_lock
(
"test_lock2"
);
drop
event
закачка
;
##
##
## 1. get a lock
## 1. get a lock
...
@@ -155,26 +170,33 @@ set global event_scheduler=2;
...
@@ -155,26 +170,33 @@ set global event_scheduler=2;
## 5. kill the scheduler, it will wait for the child to stop
## 5. kill the scheduler, it will wait for the child to stop
## 6. both processes should be there on show processlist
## 6. both processes should be there on show processlist
## 7. release the lock and sleep, both scheduler and child should end
## 7. release the lock and sleep, both scheduler and child should end
#set global event_scheduler=1;
set
global
event_scheduler
=
1
;
#select get_lock("test_lock2_1", 20);
select
get_lock
(
"test_lock2_1"
,
20
);
#create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20);
create
event
закачка21
on
schedule
every
10
hour
do
select
get_lock
(
"test_lock2_1"
,
20
);
#select sleep(2);
--
sleep
1
##show processlist;
--
echo
"Should see 2 processes, one locked on get_lock("
#set global event_scheduler=0;
#select sleep(2);
##show processlist;
#select release_lock("test_lock2_1");
#select sleep(2);
##show processlist;
#drop event закачка21;
#set global event_scheduler=1;
#select get_lock("test_lock3", 20);
#create event закачка on schedule every 10 hour do select get_lock("test_lock3", 20);
#select sleep(2);
#show processlist;
#show processlist;
#drop event закачка;
--
echo
"Shutting down the scheduler, it should wait for the running event"
#select release_lock("test_lock3");
set
global
event_scheduler
=
0
;
--
sleep
1
--
echo
"Should have only 3 processes: the scheduler, our conn and the locked event"
--
replace_column
1
# 6 #
show
processlist
;
--
echo
"Release the lock so the child process should finish. Hence the scheduler also"
select
release_lock
(
"test_lock2_1"
);
--
sleep
1
--
echo
"Should have only our process now:"
--
replace_column
1
# 6 #
show
processlist
;
drop
event
закачка21
;
##set global event_scheduler=1;
##select get_lock("test_lock3", 20);
##create event закачка on schedule every 10 hour do select get_lock("test_lock3", 20);
##select sleep(2);
##show processlist;
##drop event закачка;
##select release_lock("test_lock3");
#
#
# test with very often occuring event
# test with very often occuring event
...
@@ -182,14 +204,15 @@ set global event_scheduler=2;
...
@@ -182,14 +204,15 @@ set global event_scheduler=2;
##select get_lock("test_lock4", 20);
##select get_lock("test_lock4", 20);
##create event закачка4 on schedule every 1 second do select get_lock("test_lock4", 20);
##create event закачка4 on schedule every 1 second do select get_lock("test_lock4", 20);
##select sleep(3);
##select sleep(3);
##--replace_column 1 # 6 #
##show processlist;
##show processlist;
##drop event закачка4;
##drop event закачка4;
##select release_lock("test_lock4");
##select release_lock("test_lock4");
#set global event_scheduler=0;
##set global event_scheduler=0;
#select sleep(2);
##select sleep(2);
##--replace_column 1 # 6 #
##show processlist;
##show processlist;
##the following locks for some reason and is a bug, commented for now
##select count(*) from mysql.event;
##select count(*) from mysql.event;
drop
database
events_test
;
drop
database
events_test
;
sql/event.cc
View file @
24c01089
...
@@ -704,11 +704,17 @@ done:
...
@@ -704,11 +704,17 @@ done:
}
}
/*
0 - OK can drop from outside
1 - Scheduled from dropping, don't drop from outside
*/
static
int
static
int
evex_remove_from_cache
(
LEX_STRING
*
db
,
LEX_STRING
*
name
,
bool
use_lock
,
evex_remove_from_cache
(
LEX_STRING
*
db
,
LEX_STRING
*
name
,
bool
use_lock
,
bool
is_drop
)
bool
is_drop
)
{
{
uint
i
;
uint
i
;
int
ret
=
0
;
DBUG_ENTER
(
"evex_remove_from_cache"
);
DBUG_ENTER
(
"evex_remove_from_cache"
);
/*
/*
...
@@ -738,7 +744,8 @@ evex_remove_from_cache(LEX_STRING *db, LEX_STRING *name, bool use_lock,
...
@@ -738,7 +744,8 @@ evex_remove_from_cache(LEX_STRING *db, LEX_STRING *name, bool use_lock,
DBUG_PRINT
(
"evex_remove_from_cache"
,
DBUG_PRINT
(
"evex_remove_from_cache"
,
(
"running.defer mem free. is_drop=%d"
,
is_drop
));
(
"running.defer mem free. is_drop=%d"
,
is_drop
));
et
->
flags
|=
EVENT_EXEC_NO_MORE
;
et
->
flags
|=
EVENT_EXEC_NO_MORE
;
et
->
dropped
=
is_drop
;
if
((
et
->
dropped
=
is_drop
))
ret
=
1
;
}
}
DBUG_PRINT
(
"evex_remove_from_cache"
,
(
"delete from queue"
));
DBUG_PRINT
(
"evex_remove_from_cache"
,
(
"delete from queue"
));
evex_queue_delete_element
(
&
EVEX_EQ_NAME
,
i
);
evex_queue_delete_element
(
&
EVEX_EQ_NAME
,
i
);
...
@@ -751,7 +758,7 @@ done:
...
@@ -751,7 +758,7 @@ done:
if
(
use_lock
)
if
(
use_lock
)
VOID
(
pthread_mutex_unlock
(
&
LOCK_event_arrays
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_event_arrays
));
DBUG_RETURN
(
0
);
DBUG_RETURN
(
ret
);
}
}
...
@@ -866,21 +873,25 @@ done:
...
@@ -866,21 +873,25 @@ done:
Drops an event
Drops an event
SYNOPSIS
SYNOPSIS
evex
_drop_event()
db
_drop_event()
thd THD
thd THD
et event's name
et event's name
drop_if_exists if set and the event not existing => warning onto the stack
drop_if_exists if set and the event not existing => warning onto the stack
rows_affected affected number of rows is returned heres
*/
*/
int
int
db_drop_event
(
THD
*
thd
,
event_timed
*
et
,
bool
drop_if_exists
,
evex_drop_event
(
THD
*
thd
,
event_timed
*
et
,
bool
drop_if_exists
,
uint
*
rows_affected
)
uint
*
rows_affected
)
{
{
TABLE
*
table
;
TABLE
*
table
;
int
ret
=
EVEX_OPEN_TABLE_FAILED
;
Open_tables_state
backup
;
DBUG_ENTER
(
"evex_drop_event"
);
uint
ret
;
DBUG_ENTER
(
"db_drop_event"
);
ret
=
EVEX_OPEN_TABLE_FAILED
;
thd
->
reset_n_backup_open_tables_state
(
&
backup
);
if
(
evex_open_event_table
(
thd
,
TL_WRITE
,
&
table
))
if
(
evex_open_event_table
(
thd
,
TL_WRITE
,
&
table
))
{
{
my_error
(
ER_EVENT_OPEN_TABLE_FAILED
,
MYF
(
0
));
my_error
(
ER_EVENT_OPEN_TABLE_FAILED
,
MYF
(
0
));
...
@@ -908,10 +919,6 @@ evex_drop_event(THD *thd, event_timed *et, bool drop_if_exists,
...
@@ -908,10 +919,6 @@ evex_drop_event(THD *thd, event_timed *et, bool drop_if_exists,
goto
done
;
goto
done
;
}
}
VOID
(
pthread_mutex_lock
(
&
LOCK_evex_running
));
if
(
evex_is_running
)
ret
=
evex_remove_from_cache
(
&
et
->
dbname
,
&
et
->
name
,
true
,
true
);
VOID
(
pthread_mutex_unlock
(
&
LOCK_evex_running
));
done:
done:
/*
/*
...
@@ -919,6 +926,44 @@ done:
...
@@ -919,6 +926,44 @@ done:
we have to close our thread tables.
we have to close our thread tables.
*/
*/
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
thd
->
restore_backup_open_tables_state
(
&
backup
);
DBUG_RETURN
(
ret
);
}
/*
Drops an event
SYNOPSIS
evex_drop_event()
thd THD
et event's name
drop_if_exists if set and the event not existing => warning onto the stack
rows_affected affected number of rows is returned heres
*/
int
evex_drop_event
(
THD
*
thd
,
event_timed
*
et
,
bool
drop_if_exists
,
uint
*
rows_affected
)
{
TABLE
*
table
;
int
ret
=
0
;
DBUG_ENTER
(
"evex_drop_event"
);
VOID
(
pthread_mutex_lock
(
&
LOCK_evex_running
));
if
(
evex_is_running
)
ret
=
evex_remove_from_cache
(
&
et
->
dbname
,
&
et
->
name
,
true
,
true
);
VOID
(
pthread_mutex_unlock
(
&
LOCK_evex_running
));
if
(
ret
==
1
)
ret
=
0
;
else
if
(
ret
==
0
)
ret
=
db_drop_event
(
thd
,
et
,
drop_if_exists
,
rows_affected
);
else
my_error
(
ER_UNKNOWN_ERROR
,
MYF
(
0
));
DBUG_RETURN
(
ret
);
DBUG_RETURN
(
ret
);
}
}
...
...
sql/event_priv.h
View file @
24c01089
...
@@ -40,6 +40,9 @@ evex_db_find_event_aux(THD *thd, const LEX_STRING dbname,
...
@@ -40,6 +40,9 @@ evex_db_find_event_aux(THD *thd, const LEX_STRING dbname,
int
int
event_timed_compare_q
(
void
*
vptr
,
byte
*
a
,
byte
*
b
);
event_timed_compare_q
(
void
*
vptr
,
byte
*
a
,
byte
*
b
);
int
db_drop_event
(
THD
*
thd
,
event_timed
*
et
,
bool
drop_if_exists
,
uint
*
rows_affected
);
#define EXEC_QUEUE_QUEUE_NAME executing_queue
#define EXEC_QUEUE_QUEUE_NAME executing_queue
#define EXEC_QUEUE_DARR_NAME evex_executing_queue
#define EXEC_QUEUE_DARR_NAME evex_executing_queue
...
...
sql/event_timed.cc
View file @
24c01089
...
@@ -877,20 +877,10 @@ int
...
@@ -877,20 +877,10 @@ int
event_timed
::
drop
(
THD
*
thd
)
event_timed
::
drop
(
THD
*
thd
)
{
{
TABLE
*
table
;
TABLE
*
table
;
int
ret
=
0
;
uint
tmp
=
0
;
DBUG_ENTER
(
"event_timed::drop"
);
DBUG_ENTER
(
"event_timed::drop"
);
if
(
evex_open_event_table
(
thd
,
TL_WRITE
,
&
table
))
DBUG_RETURN
(
db_drop_event
(
thd
,
this
,
false
,
&
tmp
));
DBUG_RETURN
(
-
1
);
if
(
evex_db_find_event_aux
(
thd
,
dbname
,
name
,
definer
,
table
))
DBUG_RETURN
(
-
2
);
if
((
ret
=
table
->
file
->
ha_delete_row
(
table
->
record
[
0
])))
DBUG_RETURN
(
ret
);
close_thread_tables
(
thd
);
DBUG_RETURN
(
0
);
}
}
...
...
sql/sql_parse.cc
View file @
24c01089
...
@@ -3743,6 +3743,8 @@ end_with_restore_list:
...
@@ -3743,6 +3743,8 @@ end_with_restore_list:
res
=
evex_drop_event
(
thd
,
lex
->
et
,
lex
->
drop_if_exists
,
&
rows_affected
);
res
=
evex_drop_event
(
thd
,
lex
->
et
,
lex
->
drop_if_exists
,
&
rows_affected
);
default:
;
default:
;
}
}
DBUG_PRINT
(
"info"
,
(
"CREATE/ALTER/DROP returned error code=%d af_rows=%d"
,
res
,
rows_affected
));
if
(
!
res
)
if
(
!
res
)
send_ok
(
thd
,
rows_affected
);
send_ok
(
thd
,
rows_affected
);
...
...
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