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
78bec853
Commit
78bec853
authored
Feb 15, 2006
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/mydev/mysql-5.1
into mysql.com:/home/mydev/mysql-5.1-bug8841
parents
391c2e65
5a888df6
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
290 additions
and
262 deletions
+290
-262
dbug/Makefile.am
dbug/Makefile.am
+1
-1
mysql-test/r/events.result
mysql-test/r/events.result
+4
-0
mysql-test/t/events.test
mysql-test/t/events.test
+11
-0
sql/event.h
sql/event.h
+22
-22
sql/event_priv.h
sql/event_priv.h
+2
-2
sql/event_timed.cc
sql/event_timed.cc
+239
-235
sql/item.cc
sql/item.cc
+2
-2
sql/sp_head.cc
sql/sp_head.cc
+3
-0
sql/sql_parse.cc
sql/sql_parse.cc
+6
-0
No files found.
dbug/Makefile.am
View file @
78bec853
...
...
@@ -21,7 +21,7 @@ pkglib_LIBRARIES = libdbug.a
noinst_HEADERS
=
dbug_long.h
libdbug_a_SOURCES
=
dbug.c sanity.c
EXTRA_DIST
=
example1.c example2.c example3.c
\
user.r monty.doc
readme.prof
dbug_add_tags.pl
\
user.r monty.doc dbug_add_tags.pl
\
my_main.c main.c factorial.c dbug_analyze.c
NROFF_INC
=
example1.r example2.r example3.r main.r
\
factorial.r output1.r output2.r output3.r
\
...
...
mysql-test/r/events.result
View file @
78bec853
...
...
@@ -361,4 +361,8 @@ show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
drop event закачка21;
create table t_16 (s1 int);
create trigger t_16_bi before insert on t_16 for each row create event e_16 on schedule every 1 second do set @a=5;
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
drop table t_16;
drop database events_test;
mysql-test/t/events.test
View file @
78bec853
...
...
@@ -323,6 +323,17 @@ select release_lock("test_lock2_1");
show
processlist
;
drop
event
Ð
·
Ð
°
кÐ
°
Ñ
‡
кÐ
°
21
;
####
# Bug #16410 Events: CREATE EVENT is legal in a CREATE TRIGGER statement
#
create
table
t_16
(
s1
int
);
--
error
1422
create
trigger
t_16_bi
before
insert
on
t_16
for
each
row
create
event
e_16
on
schedule
every
1
second
do
set
@
a
=
5
;
drop
table
t_16
;
#
# end of test case
####
##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);
...
...
sql/event.h
View file @
78bec853
sql/event_priv.h
View file @
78bec853
sql/event_timed.cc
View file @
78bec853
...
...
@@ -132,11 +132,11 @@ event_timed::init_body(THD *thd)
event_timed::init_execute_at()
expr when (datetime)
RETURNS
0 -
OK
EVEX_PARSE_ERROR -
fix_fields failed
EVEX_BAD_PARAMS -
datetime is in the past
ER_WRONG_VALUE -
wrong value for execute at
RETURN VALUE
0
OK
EVEX_PARSE_ERROR
fix_fields failed
EVEX_BAD_PARAMS
datetime is in the past
ER_WRONG_VALUE
wrong value for execute at
*/
int
...
...
@@ -152,7 +152,7 @@ event_timed::init_execute_at(THD *thd, Item *expr)
if
(
expr
->
fix_fields
(
thd
,
&
expr
))
DBUG_RETURN
(
EVEX_PARSE_ERROR
);
/
/ let's check whether time is in the past
/
* Let's check whether time is in the past */
thd
->
variables
.
time_zone
->
gmt_sec_to_TIME
(
&
time_tmp
,
(
my_time_t
)
thd
->
query_start
());
...
...
@@ -166,8 +166,8 @@ event_timed::init_execute_at(THD *thd, Item *expr)
/*
This may result in a 1970-01-01 date if ltime is > 2037-xx-xx
CONVERT_TZ has similar problem
This may result in a 1970-01-01 date if ltime is > 2037-xx-xx.
CONVERT_TZ has similar problem.
*/
my_tz_UTC
->
gmt_sec_to_TIME
(
&
ltime
,
TIME_to_timestamp
(
thd
,
&
ltime
,
&
not_used
));
...
...
@@ -186,9 +186,9 @@ event_timed::init_execute_at(THD *thd, Item *expr)
new_interval what is the interval
RETURNS
0 -
OK
EVEX_PARSE_ERROR -
fix_fields failed
EVEX_BAD_PARAMS -
Interval is not positive
0
OK
EVEX_PARSE_ERROR
fix_fields failed
EVEX_BAD_PARAMS
Interval is not positive
*/
int
...
...
@@ -288,8 +288,8 @@ event_timed::init_interval(THD *thd, Item *expr, interval_type new_interval)
same time.
RETURNS
0 -
OK
EVEX_PARSE_ERROR -
fix_fields failed
0
OK
EVEX_PARSE_ERROR
fix_fields failed
*/
int
...
...
@@ -306,7 +306,7 @@ event_timed::init_starts(THD *thd, Item *new_starts)
if
((
not_used
=
new_starts
->
get_date
(
&
ltime
,
TIME_NO_ZERO_DATE
)))
DBUG_RETURN
(
EVEX_BAD_PARAMS
);
/
/ let's check whether time is in the past
/
* Let's check whether time is in the past */
thd
->
variables
.
time_zone
->
gmt_sec_to_TIME
(
&
time_tmp
,
(
my_time_t
)
thd
->
query_start
());
...
...
@@ -344,9 +344,9 @@ event_timed::init_starts(THD *thd, Item *new_starts)
same time.
RETURNS
0 -
OK
EVEX_PARSE_ERROR -
fix_fields failed
EVEX_BAD_PARAMS -
ENDS before STARTS
0
OK
EVEX_PARSE_ERROR
fix_fields failed
EVEX_BAD_PARAMS
ENDS before STARTS
*/
int
...
...
@@ -361,13 +361,13 @@ event_timed::init_ends(THD *thd, Item *new_ends)
if
(
new_ends
->
fix_fields
(
thd
,
&
new_ends
))
DBUG_RETURN
(
EVEX_PARSE_ERROR
);
/
/ the field was already fixed in init_ends
/
* The field was already fixed in init_ends */
if
((
not_used
=
new_ends
->
get_date
(
&
ltime
,
TIME_NO_ZERO_DATE
)))
DBUG_RETURN
(
EVEX_BAD_PARAMS
);
/*
This may result in a 1970-01-01 date if ltime is > 2037-xx-xx
CONVERT_TZ has similar problem
This may result in a 1970-01-01 date if ltime is > 2037-xx-xx
.
CONVERT_TZ has similar problem
.
*/
my_tz_UTC
->
gmt_sec_to_TIME
(
&
ltime
,
TIME_to_timestamp
(
thd
,
&
ltime
,
&
not_used
));
...
...
@@ -401,8 +401,7 @@ event_timed::init_comment(THD *thd, LEX_STRING *set_comment)
/*
Inits definer (definer_user and definer_host) during
parsing.
Inits definer (definer_user and definer_host) during parsing.
SYNOPSIS
event_timed::init_definer()
...
...
@@ -439,7 +438,7 @@ event_timed::init_definer(THD *thd)
SYNOPSIS
event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table)
REMARK
S
NOTE
S
This method is silent on errors and should behave like that. Callers
should handle throwing of error messages. The reason is that the class
should not know about how to deal with communication.
...
...
@@ -583,11 +582,10 @@ event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table)
SYNOPSIS
get_next_time(TIME *start, int interval_value, interval_type interval)
next - the sum
start - add interval_value to this time
i_value - quantity of time type interval to add
i_type - type of interval to add (SECOND, MINUTE, HOUR, WEEK ...)
next the sum
start add interval_value to this time
i_value quantity of time type interval to add
i_type type of interval to add (SECOND, MINUTE, HOUR, WEEK ...)
*/
static
...
...
@@ -653,7 +651,7 @@ bool get_next_time(TIME *next, TIME *start, int i_value, interval_type i_type)
SYNOPSIS
event_timed::compute_next_execution_time()
REMARKS:
NOTES
The time is set in execute_at, if no more executions the latter is set to
0000-00-00.
*/
...
...
@@ -673,10 +671,10 @@ event_timed::compute_next_execution_time()
(
"Event %s is DISABLED"
,
name
.
str
));
goto
ret
;
}
/
/if one-time no need to do computation
/
* If one-time, no need to do computation */
if
(
!
expression
)
{
/
/let's check whether it was executed
/
* Let's check whether it was executed */
if
(
last_executed
.
year
)
{
DBUG_PRINT
(
"compute_next_execution_time"
,
...
...
@@ -712,10 +710,10 @@ event_timed::compute_next_execution_time()
last_executed
.
second
);
#endif
/
/if time_now is after ends don't execute anymore
/
* If time_now is after ends don't execute anymore */
if
(
ends
.
year
&&
(
tmp
=
my_time_compare
(
&
ends
,
&
time_now
))
==
-
1
)
{
/
/ time_now is after ends. don't execute anymore
/
* time_now is after ends. don't execute anymore */
set_zero_time
(
&
execute_at
,
MYSQL_TIMESTAMP_DATETIME
);
if
(
on_completion
==
MYSQL_EVENT_ON_COMPLETION_DROP
)
dropped
=
true
;
...
...
@@ -728,7 +726,7 @@ event_timed::compute_next_execution_time()
/*
Here time_now is before or equals ends if the latter is set.
Let's check whether time_now is before starts.
If so schedule for starts
If so schedule for starts.
*/
if
(
starts
.
year
&&
(
tmp
=
my_time_compare
(
&
time_now
,
&
starts
))
<
1
)
{
...
...
@@ -767,10 +765,10 @@ event_timed::compute_next_execution_time()
if
(
get_next_time
(
&
next_exec
,
&
last_executed
,
expression
,
interval
))
goto
err
;
/
/ There was previous execution
/
* There was previous execution */
if
(
my_time_compare
(
&
ends
,
&
next_exec
)
==
-
1
)
{
/
/ Next execution after ends. No more executions
/
* Next execution after ends. No more executions */
set_zero_time
(
&
execute_at
,
MYSQL_TIMESTAMP_DATETIME
);
if
(
on_completion
==
MYSQL_EVENT_ON_COMPLETION_DROP
)
dropped
=
true
;
...
...
@@ -782,20 +780,24 @@ event_timed::compute_next_execution_time()
}
else
if
(
!
starts
.
year
&&
!
ends
.
year
)
{
// both starts and m_ends are not set, se we schedule for the next
// based on last_executed
/*
Both starts and m_ends are not set, so we schedule for the next
based on last_executed.
*/
if
(
last_executed
.
year
)
{
if
(
get_next_time
(
&
execute_at
,
&
last_executed
,
expression
,
interval
))
goto
err
;
}
else
//last_executed not set. Schedule the event for now
{
/* last_executed not set. Schedule the event for now */
execute_at
=
time_now
;
}
}
else
{
/
/either starts or m_ends is set
/
* Either starts or m_ends is set */
if
(
starts
.
year
)
{
/*
...
...
@@ -854,9 +856,9 @@ event_timed::compute_next_execution_time()
Set the internal last_executed TIME struct to now. NOW is the
time according to thd->query_start(), so the THD's clock.
S
ynopsis
S
YNOPSIS
event_timed::drop()
thd
-
thread context
thd
thread context
*/
void
...
...
@@ -878,16 +880,16 @@ event_timed::mark_last_executed(THD *thd)
/*
Drops the event
S
ynopsis
S
YNOPSIS
event_timed::drop()
thd
-
thread context
thd
thread context
RETURN
S :
0
-
OK
-1
-
Cannot open mysql.event
-2
-
Cannot find the event in mysql.event (already deleted?)
RETURN
VALUE
0
OK
-1
Cannot open mysql.event
-2
Cannot find the event in mysql.event (already deleted?)
others
-
return code from SE in case deletion of the event row
others
return code from SE in case deletion of the event row
failed.
*/
...
...
@@ -905,17 +907,17 @@ event_timed::drop(THD *thd)
/*
Saves status and last_executed_at to the disk if changed.
S
ynopsis
S
YNOPSIS
event_timed::drop()
thd - thread context
R
eturns :
0
-
OK
SP_OPEN_TABLE_FAILED
-
Error while opening mysql.event for writing
EVEX_WRITE_ROW_FAILED
-
On error to write to disk
R
ETURN VALUE
0
OK
SP_OPEN_TABLE_FAILED
Error while opening mysql.event for writing
EVEX_WRITE_ROW_FAILED
On error to write to disk
others
- return code from SE in case deletion of the event row
failed.
others
return code from SE in case deletion of the event
row
failed.
*/
bool
...
...
@@ -930,7 +932,7 @@ event_timed::update_fields(THD *thd)
DBUG_PRINT
(
"enter"
,
(
"name: %*s"
,
name
.
length
,
name
.
str
));
/
/no need to update if nothing has changed
/
* No need to update if nothing has changed */
if
(
!
(
status_changed
||
last_executed_changed
))
goto
done
;
...
...
@@ -947,7 +949,7 @@ event_timed::update_fields(THD *thd)
goto
done
;
store_record
(
table
,
record
[
1
]);
/
/ Don't update create on row update.
/
* Don't update create on row update. */
table
->
timestamp_field_type
=
TIMESTAMP_NO_AUTO_SET
;
if
(
last_executed_changed
)
...
...
@@ -978,12 +980,14 @@ event_timed::update_fields(THD *thd)
/*
Get SHOW CREATE EVENT as string
thd - Thread
buf - String*, should be already allocated. CREATE EVENT goes inside.
SYNOPSIS
event_timed::get_create_event(THD *thd, String *buf)
thd Thread
buf String*, should be already allocated. CREATE EVENT goes inside.
R
eturns:
0 -
OK
1 -
Error (for now if mysql.event has been tampered and MICROSECONDS
R
ETURN VALUE
0
OK
1
Error (for now if mysql.event has been tampered and MICROSECONDS
interval or derivative has been put there.
*/
...
...
@@ -1018,8 +1022,8 @@ event_timed::get_create_event(THD *thd, String *buf)
char
dtime_buff
[
20
*
2
+
32
];
// +32 to make my_snprintf_{8bit|ucs2} happy
buf
->
append
(
STRING_WITH_LEN
(
"AT '"
));
/*
pass the buffer and the second param tells fills the buffer and returns
the number of chars to copy
Pass the buffer and the second param tells fills the buffer and
returns the number of chars to copy.
*/
buf
->
append
(
dtime_buff
,
my_datetime_to_str
(
&
execute_at
,
dtime_buff
));
buf
->
append
(
STRING_WITH_LEN
(
"'"
));
...
...
@@ -1055,11 +1059,10 @@ event_timed::get_create_event(THD *thd, String *buf)
thd THD
mem_root If != NULL use it to compile the event on it
Returns
0 - success
-100 - event in execution (parallel execution is impossible)
others - retcodes of sp_head::execute_procedure()
RETURNS
0 success
-100 event in execution (parallel execution is impossible)
others retcodes of sp_head::execute_procedure()
*/
int
...
...
@@ -1107,16 +1110,15 @@ event_timed::execute(THD *thd, MEM_ROOT *mem_root)
Compiles an event before it's execution. Compiles the anonymous
sp_head object held by the event
S
ynopsis
S
YNOPSIS
event_timed::compile()
thd
-
thread context, used for memory allocation mostly
mem_root
-
if != NULL then this memory root is used for allocs
thd
thread context, used for memory allocation mostly
mem_root
if != NULL then this memory root is used for allocs
instead of thd->mem_root
Returns
0 - Success
EVEX_COMPILE_ERROR - Error during compilation
RETURN VALUE
0 success
EVEX_COMPILE_ERROR error during compilation
*/
int
...
...
@@ -1150,7 +1152,7 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
thd
->
update_charset
();
DBUG_ENTER
(
"event_timed::compile"
);
/
/ change the memory root for the execution time
/
* Change the memory root for the execution time */
if
(
mem_root
)
{
tmp_mem_root
=
thd
->
mem_root
;
...
...
@@ -1174,8 +1176,10 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
{
DBUG_PRINT
(
"error"
,
(
"error during compile or thd->is_fatal_error=%d"
,
thd
->
is_fatal_error
));
// Free lex associated resources
// QQ: Do we really need all this stuff here ?
/*
Free lex associated resources
QQ: Do we really need all this stuff here?
*/
sql_print_error
(
"error during compile of %s.%s or thd->is_fatal_error=%d"
,
dbname
.
str
,
name
.
str
,
thd
->
is_fatal_error
);
if
(
lex
.
sphead
)
...
...
@@ -1192,8 +1196,10 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
sphead
=
lex
.
et
->
sphead
;
sphead
->
m_db
=
dbname
;
//copy also chistics since they will vanish otherwise we get 0x0 pointer
// Todo : Handle sql_mode !!
/*
Ccopy also chistics since they will vanish otherwise we get 0x0 pointer
TODO: Handle sql_mode!!
*/
sphead
->
set_definer
(
definer
.
str
,
definer
.
length
);
sphead
->
set_info
(
0
,
0
,
&
lex
.
sp_chistics
,
0
/*sql_mode*/
);
sphead
->
optimize
();
...
...
@@ -1214,9 +1220,7 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
thd
->
variables
.
collation_connection
=
old_collation_connection
;
thd
->
update_charset
();
/*
Change the memory root for the execution time.
*/
/* Change the memory root for the execution time. */
if
(
mem_root
)
thd
->
mem_root
=
tmp_mem_root
;
...
...
sql/item.cc
View file @
78bec853
...
...
@@ -375,8 +375,8 @@ void Item::print_item_w_name(String *str)
void
Item
::
cleanup
()
{
DBUG_ENTER
(
"Item::cleanup"
);
DBUG_PRINT
(
"info"
,
(
"Item: 0x%lx,
Type: %d,
name %s, original name %s"
,
this
,
(
int
)
type
(),
name
?
name
:
"(null)"
,
DBUG_PRINT
(
"info"
,
(
"Item: 0x%lx, name %s, original name %s"
,
this
,
name
?
name
:
"(null)"
,
orig_name
?
orig_name
:
"null"
));
fixed
=
0
;
marker
=
0
;
...
...
sql/sp_head.cc
View file @
78bec853
...
...
@@ -255,6 +255,9 @@ sp_get_flags_for_command(LEX *lex)
case
SQLCOM_ALTER_FUNCTION
:
case
SQLCOM_DROP_PROCEDURE
:
case
SQLCOM_DROP_FUNCTION
:
case
SQLCOM_CREATE_EVENT
:
case
SQLCOM_ALTER_EVENT
:
case
SQLCOM_DROP_EVENT
:
flags
=
sp_head
::
HAS_COMMIT_OR_ROLLBACK
;
break
;
default:
...
...
sql/sql_parse.cc
View file @
78bec853
...
...
@@ -3773,6 +3773,12 @@ mysql_execute_command(THD *thd)
is_schema_db
(
lex
->
et
->
dbname
.
str
)))
break
;
if
(
end_active_trans
(
thd
))
{
res
=
-
1
;
break
;
}
switch
(
lex
->
sql_command
)
{
case
SQLCOM_CREATE_EVENT
:
res
=
evex_create_event
(
thd
,
lex
->
et
,
(
uint
)
lex
->
create_info
.
options
,
...
...
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