More small fixes to the API : use LEX_STRING instead of LEX_STRING* and if error
then return bool(true) instead of error code.
Merged functions. Reduced usage of sp_name.
Fixed a lot of function documentation errors.
Added function documentation wherever needed.
Removed some unused defines and error codes.
Next to come is batch rename of Event_scheduler_ng to Event_scheduler.
mysql-test/r/events.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/t/events.test:
more test coverage
mysql-test/t/events_logs_tests.test:
fix test
sql/event_data_objects.cc:
Cosmetics.
Fix function documentation whenever needed.
Move Event_job_data::compile() next to Event_job_data::execute()
sql/event_data_objects.h:
Remove unneeded error codes and defines
Move function declarations at the end of the header
sql/event_db_repository.cc:
Fix function documentation.
Event_db_repository::update_event() now uses LEX_STRING *-s instead of
sp_name . Lower coupling.
sql/event_db_repository.h:
Event_db_repository::update_event() now uses LEX_STRING *-s instead of
sp_name . Lower coupling.
find_event -> find_named_event
find_event_by_name is not used externally, merge with load_named_event()
sql/event_queue.cc:
LEX_STRING* to LEX_STRING
Fix comments.
Fix and add function documentation.
Remove Event_queue::events_count() as it is unused
Change get_top_for_execution_if_time() to return status code as return value
and the object is in out parameter.
sql/event_queue.h:
LEX_STRING* to LEX_STRING
Fix comments.
Fix and add function documentation.
Remove Event_queue::events_count() as it is unused
Change get_top_for_execution_if_time() to return status code as return value
and the object is in out parameter.
Try to detect also lock attemptions for deadlocks.
sql/event_scheduler_ng.cc:
Always execute on thd->mem_root
Fix according to changed API of Event_queue::get_top_for_execution_if_time()
sql/events.cc:
Fix function documentation.
Fix code after API changes of internal Event module classes.
sql/events.h:
sp_name -> LEX_STRINGs
sql/sql_parse.cc:
Fix according to changed API of Events::show_create_event()
sql/sql_yacc.yy:
Don't pass NULL as third parameter to sp_head::init_strings()
This patch introduces specialized Event data objects
Event_basic as parent.
Event_queue_element used for queue storage
Event_timed used for SHOW EVENTS/ I_S.EVENTS / SHOW CREATE EVENT
Event_job_data using during execution.
Methods were moved out of Event_timed to other classes.
This patch also introduces Events::LOCK_event_metadata.
This patch gives new implementation of Events::dump_internal_status().
Now both the Event_scheduler and Event_queue return information during
their ::dump_internal_status().
Shortened a bit the runtime for executing events test cases.
mysql-test/r/events.result:
update results
mysql-test/r/events_bugs.result:
update results
mysql-test/r/events_logs_tests.result:
update results
mysql-test/r/events_scheduling.result:
update results
mysql-test/t/events.test:
update test
make --sleep more appropriate . saving some time could mean failure on loaded boxes though :(
add tests for previously uncovered branches.
mysql-test/t/events_bugs.test:
update test
make --sleep more appropriate . saving some time could mean failure on loaded boxes though :(
add tests for previously uncovered branches.
mysql-test/t/events_logs_tests.test:
make the test shorter by time
mysql-test/t/events_scheduling.test:
when selecting always use ORDER BY
mysql-test/t/events_stress.test:
sleep 2.5secs for shorter stress test
sql/event_data_objects.cc:
Event_timed is no more used during execution.
Event_timed is no more used during in the memory queue.
Event_timed is only used for SHOW CREATE EVENT/ I_S.EVENTS/ SHOW EVENTS
Event_basic is the parent of almost all Event data objects.
Event_basic -> Event_queue_element (used for the memory queue) -> Event_timed
Event_basic -> Event_job_data (the object used for execution)
Sql_alloc -> Event_parse_data (used during parsing)
sql/event_data_objects.h:
Event_timed is no more used during execution.
Event_timed is no more used during in the memory queue.
Event_timed is only used for SHOW CREATE EVENT/ I_S.EVENTS/ SHOW EVENTS
Event_basic is the parent of almost all Event data objects.
Event_basic -> Event_queue_element (used for the memory queue) -> Event_timed
Event_basic -> Event_job_data (the object used for execution)
Sql_alloc -> Event_parse_data (used during parsing)
sql/event_db_repository.cc:
Cosmetics.
load_named_event now uses Event_basic, for polymorphism
find_event uses Event_basic, to be polymorphic.
use Field **fields= table->field and then index fields[...]
Add documentation.
Fix documentation.
sql/event_db_repository.h:
Event_db_repository depends only on Event_basic's interface
sql/event_queue.cc:
Cosmetics.
Don't use Event_timed for the queue and giving back object for execution.
Event_queue_element is for the queue, Event_job_data is for execution.
Add Event_queue::dump_internal_status() for SHOW SCHEDULER STATUS command
sql/event_queue.h:
Cosmetics.
Don't use Event_timed for the queue and giving back object for execution.
Event_queue_element is for the queue, Event_job_data is for execution.
Add Event_queue::dump_internal_status() for SHOW SCHEDULER STATUS command
sql/event_scheduler_ng.cc:
Add back Event_scheduler::cond_wait()
Add back Event_scheduler::dump_internal_status()
Using Event_job_data for execution. Make the scheduler thread unkillable (thd->command= COM_DAEMON).
Add a lot of documentation.
sql/event_scheduler_ng.h:
Add back Event_scheduler::cond_wait()
Add back Event_scheduler::dump_internal_status()
Using Event_job_data for execution.
sql/events.cc:
Documentation
Add LOCK_event_metadata
sql/events.h:
Change the signature of Events::drop_event() not to use sp_name but LEX_STRING
sql/share/errmsg.txt:
Fix error message
sql/sql_parse.cc:
Events::drop_event() has new signature
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
the parsing. Next step will be to refactor of usage of Event_timed
during Events::create_event() and Events::update_event().
Disallow:
- CREATE EVENT ... DO CREATE EVENT ...;
- ALTER EVENT ... DO CREATE EVENT ...;
- CREATE EVENT ... DO ALTER EVENT DO ....;
- CREATE PROCEDURE ... BEGIN CREATE EVENT ... END|
Allowed:
- CREATE EVENT ... DO DROP EVENT yyy;
- CREATE EVENT ... DO ALTER EVENT yyy;
(the nested ALTER EVENT can have anything but DO clause)
- ALTER EVENT ... DO ALTER EVENT yyy;
(the nested ALTER EVENT can have anything but DO clause)
- ALTER EVENT ... DO DROP EVENT yyy;
- CREATE PROCEDURE ... BEGIN ALTER EVENT ... END|
(the nested ALTER EVENT can have anything but DO clause)
- CREATE PROCEDURE ... BEGIN DROP EVENT ... END|
mysql-test/r/events.result:
update results
mysql-test/r/events_bugs.result:
update results
mysql-test/t/events.test:
use number as error, mysql-test-run does not like the name.
will come back to this later, now it's enough to pass the test.
disable nested events / events in SP, when the nested event has
a body. If no body is provided, namely DROP EVENT or ALTER that
changes the characteristics, then these are allowed.
mysql-test/t/events_bugs.test:
use number as error, mysql-test-run does not like the name.
will come back to this later, now it's enough to pass the test.
disable nested events / events in SP, when the nested event has
a body. If no body is provided, namely DROP EVENT or ALTER that
changes the characteristics, then these are allowed.
sql/share/errmsg.txt:
new message
sql/sql_yacc.yy:
refactor CREATE EVENT parsing to fit into the structure
CREATE DEFINER=xxx EVENT
The actual definer part is not used, but parsed, for now.
Disable nested CREATE EVENTS, CREATE EVENT inside CREATE PROCEDURE.
And an event DDL with body inside an ALTER.
This stops the following :
- CREATE EVENT ... DO CREATE EVENT ...;
- ALTER EVENT ... DO CREATE EVENT ...;
- CREATE EVENT ... DO ALTER EVENT DO ....;
- CREATE PROCEDURE ... BEGIN CREATE EVENT ... END|
This allows:
- CREATE EVENT ... DO DROP EVENT yyy;
- CREATE EVENT ... DO ALTER EVENT yyy;
(the nested ALTER EVENT can have anything but DO clause)
- ALTER EVENT ... DO ALTER EVENT yyy;
(the nested ALTER EVENT can have anything but DO clause)
- ALTER EVENT ... DO DROP EVENT yyy;
- CREATE PROCEDURE ... BEGIN ALTER EVENT ... END|
(the nested ALTER EVENT can have anything but DO clause)
- CREATE PROCEDURE ... BEGIN DROP EVENT ... END|
into lmy004.:/work/mysql-5.1-runtime-bug16992
mysql-test/t/events.test:
Auto merged
mysql-test/t/events_grant.test:
Auto merged
sql/sql_show.cc:
Auto merged
(fix for bug#20290 Event mechanism incompatible with embedded server, but tests tried)
mysql-test/t/events.test:
disable test in embedded
mysql-test/t/events_bugs.test:
disable test in embedded
mysql-test/t/events_grant.test:
disable test in embedded
mysql-test/t/events_logs_tests.test:
disable test in embedded
mysql-test/t/events_microsec.test:
disable test in embedded
mysql-test/t/events_scheduling.test:
disable test in embedded
mysql-test/t/events_stress.test:
disable test in embedded
Introduced EVENTS.EVENT_DEFINITION, like ROUTINES.ROUTINE_DEFINITION
Hence, the contents of the current EVENTS.EVENT_BODY become the contents
of EVENT_DEFINITION. EVENT_BODY will contain always, for now, "SQL" (wo
quotes).
mysql-test/r/events.result:
update result
event_body -> event_definition
event_body -> SQL
mysql-test/r/events_grant.result:
update result
event_body -> event_definition
event_body -> SQL
mysql-test/r/information_schema.result:
update result
event_body -> event_definition
mysql-test/t/events.test:
update result
event_body -> event_definition
event_body -> SQL
mysql-test/t/events_grant.test:
update result
event_body -> event_definition
event_body -> SQL
sql/sql_show.cc:
Introduce enum_i_s_events_fields, because I hate recounting
all the time a field is changed.
Rename EVENT_BODY to EVENT_DEFINITION
Introduce EVENT_BODY after that to be "SQL"
(final fix for bug#16992 Events: Information schema troubles ) ?
mysql-test/lib/init_db.sql:
remove definer from PK
mysql-test/r/events.result:
update results
mysql-test/r/system_mysql_db.result:
update results
mysql-test/t/events.test:
remove I_S.EVENTS test and move it to events_grant.test
scripts/mysql_fix_privilege_tables.sql:
change table definition
sql/event.cc:
make events non-user specific (namespace change)
sql/event.h:
make events non-user specific (namespace change)
sql/event_priv.h:
make events non-user specific (namespace change)
sql/event_scheduler.cc:
make events non-user specific (namespace change)
sql/event_timed.cc:
make events non-user specific (namespace change)
sql/sql_parse.cc:
make events non-user specific (namespace change)
sql/sql_show.cc:
SHOW EVENTS is available to everyone who has EVENT on specific schema.
No additional privileges are needed to see others' events.
- user A has events in db1 and db2
- user B has events in db1 and db3
A will see all his events from db1 and db2 as well as B's events
from db1 but not from db3.
B will see her events from db1 and db3. In addition B will see
only A's events from db1 but not db2.
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
When looking up the error number for named errors in mysqltest .test
files, we inadvertantly would match ER_WRONG_VALUE against
ER_WRONG_VALUE_COUNT because we were using the length of the shorter
string in strncmp(). Now we double-check the length of matches to
make sure it was a complete match.
client/mysqltest.c:
Check the length of the error name to make sure it wasn't just a
partial match
mysql-test/t/events.test:
Replace error numbers with error names, with side-effect of testing
Bug #18495.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
update test (bk mangles cp1251 during merge)
mysql-test/t/events_scheduling.test:
fix test
mysql-test/r/events.result:
Auto merged
sql/event.cc:
Auto merged
sql/event_timed.cc:
Auto merged
sql/item_timefunc.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_show.cc:
Auto merged
This also should fix 17493 and 17346, and probably 16397 (not tested).
WL#1034 (Internal CRON)
(post-review commit)
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
update test
sql/event.cc:
seems we get a crash if we compile it this way. better let the worker thread do it,
this increases the stability.
sql/event_executor.cc:
kick in more often
sql/event_timed.cc:
- don't NULLify last_executed
- implement (fix) better get_next_time() which does not use last_executed as basis
but STARTS. STARTS is used as basis and the next point of time which is before ENDS,
if set, is being found. The point > now and (point-starts) % interval_expression == 0.
sql/item_timefunc.cc:
move calc_time_diff to time.cc as it can be reused in other parts of the
server code (see event_timed.cc)
sql/mysql_priv.h:
export calc_time_diff() moved to time.cc from item_timefunc.cc
sql/sql_show.cc:
- fix presenting of LAST_EXECUTED
- cleanup a bit
sql/time.cc:
- move calc_time_diff() from item_timefunc.cc to here
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/t/events.test:
- use information_schema.processlist
- move from error codes to constants
mysql-test/t/events_bugs.test:
fix for bug #17578: Test "events" fails due to scheduling difference
use information_schema.processlist
SHOW AUTHORS caused 'Packets out of order' in stored functions:
add the corresponding SQLCOM to sp_get_flags_for_command so that
it'd return sp-related flags for it.
Fix Bug#17403 "Events: packets out of order with show create event"
in the same chaneset.
mysql-test/r/events.result:
Update the results (Bug#17403)
mysql-test/r/sp-error.result:
Test results fixed (Bug#16164)
mysql-test/t/events.test:
Add a test case for Bug#17403 "Events: packets out of order with
show create event"
mysql-test/t/sp-error.test:
Add a test case for Bug#16164 "Easter egg"
sql/sp_head.cc:
Add SHOW AUTHORS to the list of commands that return a result
set: such commands are not allowed in stored functions and
triggers. Add SHOW CREATE EVENT for the same reason.
mysql-test/r/events.result:
Auto merged
mysql-test/t/events.test:
Auto merged
sql/event.cc:
Auto merged
sql/event.h:
Auto merged
sql/sql_yacc.yy:
Auto merged
- now when the event is created and STARTS is omitted then STARTS is implicitly
CURRENT_TIMESTAMP
- This CS also fixed incorrect presentation of STARTS/ENDS in I_S.EVENTS
(incorporated review changes)
mysql-test/r/events.result:
results of new test cases
mysql-test/t/events.test:
new test cases for bug #16537 (Events: mysql.event.starts is null)
sql/event.cc:
- check whether event_timed::starts_null only in case
event_timed::expression is set, so for recurring events only
- disable binlogging of CREATE EVENT statement. It should not be
replicated but the result of the execution. Still the replication is
untouched topic.
sql/event.h:
- add flags whether starts, ends and execute_at are null or not
sql/event_executor.cc:
- check whether xxx_null instead of !xxxx.year
sql/event_timed.cc:
- introduce xxx_null and change the usage of xxx.year to !xxx_null
sql/sql_show.cc:
- don't show 0000-00-00 in I_S.EVENTS when the value is NULL
sql/sql_yacc.yy:
- if STARTS is omitted default to current_timestamp
this problem affects only debug builds
mysql-test/r/events.result:
update results
mysql-test/t/events.test:
tests for bug#17543 Creating Event crash the server
sql/event_timed.cc:
the delimiter between DO and the body could be not only a space
but any other recognized white space, so use proper macro.
(pre-push)
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
few more tests
sql/event.cc:
fix compilation failure after big merge
sql/event.h:
initialize s_ctx to be the context to be used.
don't use sphead->m_security_ctx but we will copy
the initted ctx to there
sql/event_timed.cc:
-initialize s_ctx to be the context to be used.
don't use sphead->m_security_ctx but we will copy
the initted ctx to there
- first init the context
- then compile the event
- and then copy the context
- don't use mysql_change_db() for now change_security_context() gets the
right context info
WL#1034
- This changeset also changes the executor so its quite more stable now.
Stressing test case added that executes ~800 events per second and dropping
hundreds of events at once using DROP DATABASE.
(with fixes after review of JimW)
(with fixes after review of Serg)
mysql-test/r/events.result:
update results after TRIGGER_ACL was added
mysql-test/t/events.test:
-redundant line
sql/event.cc:
Implemented evex_db_drop_events() which drops all events
from a specific database. Needed for SQLCOM_DROP_DATABASE
sql/event.h:
- protect the event better (see the changes to event_executor.cc
and event.cc). An event object could be used in a spawned thread
before it's executed but till now the object is marked as being
executed when the anonymous sp_head is executed. However, there are
timeframes before and after that during which the event is not marked
as executed and other thread may delete the object -> so we end with
a nirvana pointer.
sql/event_executor.cc:
- extract some of the code executed in the main thread to a function. Too long
functions are bad for the overview.
- prepend all information/error messages to the console with "SCHEDULER:" for
better overview, and easied searching in the log tables.
sql/event_priv.h:
- change the name, of evex_db_find_event_by_name() and don't
used C++ features like function overloading
- define consts for result returned from event_timed::spawn_now()
sql/event_timed.cc:
- add few methods related to event execution.
now the event spawns the worker thread and
passes itself as parameter. This way it locks itself for exectution
first and then spawning -> no race condition. When the worker thread
has finished working with the reference it calls back
event_timed::spawn_thread_finish() to unlock itself.
sql/sql_db.cc:
- call evex_drop_db_events() on DROP DATABASE
WL#1034 (Internal CRON)
(post-post-review updates)
mysql-test/r/events.result:
update results file
mysql-test/t/events.test:
add test for Bug #16410 Events: CREATE EVENT is legal in a CREATE TRIGGER statement
sql/sp_head.cc:
CREATE/ALTER/DROP event mean explicit commit, so they are not allowed in
a FUNCTION/TRIGGER. Fixes bug#16410
sql/sql_parse.cc:
- end active transaction for CREATE/ALTER/DROP EVENT because
they are DDL statements.
into lmy004.:/work/mysql-5.1-bug17289
mysql-test/r/events.result:
Auto merged
mysql-test/t/events.test:
Auto merged
sql/event.h:
Auto merged
sql/event_executor.cc:
Auto merged
sql/event_timed.cc:
Auto merged
mysql-test/r/events.result:
Auto merged
mysql-test/t/events.test:
Auto merged
sql/event.h:
Auto merged
sql/event_executor.cc:
Auto merged
sql/event_timed.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_acl.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/table.cc:
Auto merged
sql/table.h:
Auto merged
- fix for bug#16423 (Events: SHOW CREATE EVENT doesn't work)
- this Changeset commits makes CREATE/UPDATE/DELETE EVENT real DDL statements
by committing the currently open transaction before they are executed.
- this Changeset also fixes a trailing space problem since the very early days
of the internal cron
- adds sophisticated checking of whether mysql.event was tampered accidentally
or with purpose by an user.
- adds a lot of inline function documentation - documents everything left
uncodumented
- INTERVAL_XXXX to XXX in I_S.EVENTS.INTERVAL_FIELD
WL#1034 (Internal CRON)
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
add test cases for SHOW CREATE EVENT
add test cases where the structure of mysql.event is changed and error reporting in this case
sql/event.cc:
- do a lot more checking on mysql.event whether it's valid
introduced generic function table_check_intact() which can be used also
for checking whether a system table (mysql.*) has been tampered by user
and report an error in this case. The checking is quite strict, thus
maybe some mechanism can be added later that loosens this like some
session variable, for instance, i_am_aware_that_i_can_damage_my_data
so the table will be opened nevertheless we think that it's not valid.
- add evex_show_create_event(THD *thd, sp_name *spn, LEX_STRING definer)
- document a loooot. not a single function left undocumented.
sql/event.h:
- add evex_show_create_event(THD *thd, sp_name *spn, LEX_STRING definer)
- change get_show_create_event() to get_create_event()
- add TABLE_FIELD_W_TYPE used by table_check_intact()
- add event_timed::sql_mode so it can be used by show create event. currently
always 0, will be fixed by a patch for another bug. At least makes the code
of show create event complete.
sql/event_executor.cc:
- add evex_check_system_tables() that checks on boot and event
main thread startup that mysql.db and mysql.user tables are correct.
- document everything!
sql/event_priv.h:
remove a line
sql/event_timed.cc:
- implement SHOW CREATE EVENT
- document undocumented functions!
sql/share/errmsg.txt:
- fix an error message and add two new
sql/sql_acl.cc:
- add mysql.db table definition to use by table_check_intact()
- exchange some of the positions by numbers from mysql.db to enum names (see sql_acl.h)
sql/sql_acl.h:
- define the structure of mysql.db table
sql/sql_parse.cc:
- handle SQLCOM_SHOW_CREATE_EVENT
- end the current transaction becase CREATE/UPDATE/DELETE EVENT is a DDL
statement
sql/sql_show.cc:
- remove interval_type_to_name
- use common function event_reconstruct_interval_expression()
that reconstructs the expression given at create/alter, to some
extent - interval of 2:62 MINUTE_SECOND will be reconstructed as
interval of 3:02 MINUTE_SECOND!
sql/sql_yacc.yy:
init the definer of event_timed also when doing SHOW CREATE EVENT
because it's needed for checking into mysql.event
sql/table.cc:
- remove stale code. only mysql.event should be a 'system_table'
- add table_check_intact() to check the consistency of a table.
mostly usable with mysql.xxx tables.
sql/table.h:
- export TABLE_FIELD_W_TYPE and table_check_intact() which are used for
checking the structure of a table. mostly usable for mysql.xxx tables.
Events were executed with all privileges possible on planet Earth :(
WL#1034
mysql-test/r/events.result:
update test results
mysql-test/t/events.test:
test for bug#17289 Events: missing privilege check for drop database
sql/event.h:
-add two new methods to event_timed to change and restore
the security context
sql/event_executor.cc:
- move code regarding privilieges checking to event_timed::execute()
- add a new function evex_print_warnings() which prints the notes/warnings/errors
to the console (easily capturable with logs-into-tables) so one can see what
has happened if there was an error of some sort!
sql/event_timed.cc:
- fix documentation
- add a new error code -99, EVENT was revoked from the user on the DB
- set_sec_ctx, execute, restore_sex_ctx
sql/sql_error.cc:
- make warning_level_names public to be used in event_executor.cc
- change from 2 arrays to a LEX_STRING array
WL#1034 (Internal CRON)
(with post-review fix)
mysql-test/r/events.result:
update the result
mysql-test/t/events.test:
use --sleep instead of select sleep()
enable some scheduler related tests. They were disabled because of a hang that
happened. The hang is fixed with this bugfix.
sql/event.cc:
- evex_remove_from_cache reports back whether the in_memory
object was deleted or was scheduled. In case scheduling then
don't delete it from outside but let it do it itself
- move out db interaction code out of evex_drop_event to db_drop_event
so it can be called from outter space :)
sql/event_priv.h:
- export the new function db_drop_event()
sql/event_timed.cc:
- use db_drop_event() and don't implement the dropping ourselves
sql/sql_parse.cc:
- some debug info about the status code returned.
WL#1034 (Internal CRON)
mysql-test/r/events.result:
fix result of t/events (post-merge fix of bug #16642)
mysql-test/r/system_mysql_db.result:
fix result(post-merge fix of bug #16642)
mysql-test/t/events.test:
fix test, use --echo instead of select, fix failing create event statement
sql/event_timed.cc:
add a bit more debug information
mysql-test/lib/init_db.sql:
Auto merged
scripts/mysql_create_system_tables.sh:
Auto merged
scripts/mysql_fix_privilege_tables.sql:
Auto merged
sql/event.cc:
Auto merged
sql/event.h:
Auto merged
sql/event_executor.cc:
Auto merged
sql/event_priv.h:
Auto merged
sql/event_timed.cc:
Auto merged
sql/mysqld.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/events.result:
manual merge
mysql-test/r/system_mysql_db.result:
manual merge
mysql-test/t/events.test:
manual merge
post-review change - use pointer instead of copy on the stack.
WL#1034 (Internal CRON)
This patch adds INFORMATION_SCHEMA.EVENTS table with the following format:
EVENT_CATALOG - MYSQL_TYPE_STRING (Always NULL)
EVENT_SCHEMA - MYSQL_TYPE_STRING (the database)
EVENT_NAME - MYSQL_TYPE_STRING (the name)
DEFINER - MYSQL_TYPE_STRING (user@host)
EVENT_BODY - MYSQL_TYPE_STRING (the body from mysql.event)
EVENT_TYPE - MYSQL_TYPE_STRING ("ONE TIME" | "RECURRING")
EXECUTE_AT - MYSQL_TYPE_TIMESTAMP (set for "ONE TIME" otherwise NULL)
INTERVAL_VALUE - MYSQL_TYPE_LONG (set for RECURRING otherwise NULL)
INTERVAL_FIELD - MYSQL_TYPE_STRING (set for RECURRING otherwise NULL)
SQL_MODE - MYSQL_TYPE_STRING (for now NULL)
STARTS - MYSQL_TYPE_TIMESTAMP (starts from mysql.event)
ENDS - MYSQL_TYPE_TIMESTAMP (ends from mysql.event)
STATUS - MYSQL_TYPE_STRING (ENABLED | DISABLED)
ON_COMPLETION - MYSQL_TYPE_STRING (NOT PRESERVE | PRESERVE)
CREATED - MYSQL_TYPE_TIMESTAMP
LAST_ALTERED - MYSQL_TYPE_TIMESTAMP
LAST_EXECUTED - MYSQL_TYPE_TIMESTAMP
EVENT_COMMENT - MYSQL_TYPE_STRING
SQL_MODE is NULL for now, because the value is still not stored in mysql.event .
Support will be added as a fix for another bug.
This patch also adds SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
1. SHOW EVENTS shows always only the events on the same user,
because the PK of mysql.event is (definer, db, name) several
users may have event with the same name -> no information disclosure.
2. SHOW FULL EVENTS - shows the events (in the current db as SHOW EVENTS)
of all users. The user has to have PROCESS privilege, if not then
SHOW FULL EVENTS behave like SHOW EVENTS.
3. If [FROM db] is specified then this db is considered.
4. Event names can be filtered with LIKE pattern.
SHOW EVENTS returns table with the following columns, which are subset of
the data which is returned by SELECT * FROM I_S.EVENTS
Db
Name
Definer
Type
Execute at
Interval value
Interval field
Starts
Ends
Status
mysql-test/lib/init_db.sql:
change the PK - (definer, db, name)
quicker searches when SHOW EVENTS;
allow also different users to have events with the same name ->
no information disclosure
mysql-test/r/events.result:
result of new tests
mysql-test/r/information_schema.result:
result of new tests
mysql-test/r/information_schema_db.result:
result of new tests
mysql-test/r/system_mysql_db.result:
result of new tests
mysql-test/t/events.test:
new tests for information_schema.events
scripts/mysql_create_system_tables.sh:
change the PK of mysql.event to (definer, db, name)
scripts/mysql_fix_privilege_tables.sql:
change the PK of mysql.event to (definer, db, name)
sql/event.cc:
pass around the definer of the event because of the new PK
which is (definer, db, name). It's needed for index searching.
sql/event.h:
- make enum evex_table_field again public so it can be used
in sql_show.cc
- make created and modified ulonglong, because they should be such
- make public evex_open_event_table so it can be used in sql_show.cc
sql/event_executor.cc:
- cosmetics
sql/event_priv.h:
- moved enum evex_table_field and evex_open_event_table()
to event.h (made them therefore public)
sql/event_timed.cc:
- in event_timed::init_definer() always fill this.definer with
the concatenated value of definer_user@definer_host. Makes
later the work easier.
- pass around the definer wherever is needed for searching
(new prototype of evex_db_find_evex_aux)
sql/mysqld.cc:
- add counter for SHOW EVENTS
sql/sql_lex.h:
- register SHOW EVENTS as command
sql/sql_parse.cc:
- handle SCH_EVENTS (I_S.EVENTS like SCH_TRIGGERS)
- make additional check in case of SHOW EVENTS (check for EVENT on
the current database. if it is null check_access() gives appropriate
message back.
sql/sql_show.cc:
- add INFORMATION_SCHEMA.EVENTS and SHOW EVENTS
- I_S.EVENTS.SQL_MODE is NULL for now -> not implemented. Trudy
asked to be added so bug #16642 can be completely closed. There
is another bug report which will fix the lack of storage of
SQL_MODE during event creation.
sql/sql_yacc.yy:
- always call event_timed::init_definer() when CREATE/ALTER/DROP
EVENT but not when just compiling the body of the event because
in this case this operation is not needed, it takes memory and
CPU time and at the end the result is not used. event_timed::definer
is used only on SQLCOM_CREATE/ALTER/DROP_EVENT execution not on
statement compilation.
- add SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
in case of FULL and the user has PROCESS privilege then he will see
also others' events in the current database, otherwise the output
is the same as of SHOW EVENTS. Because the events are per DB only
the events from the current database are shown. pattern is applied
against event name. FROM db is self explanatory.
sql/table.h:
add SCH_EVENTS as part of INFORMATION_SCHEMA
WL#1034 (Internal CRON)
(not interesting for the Changelog)
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
update test after pull after comit of fix for bug 16419
WL #1034 (Internal CRON)
mysql-test/r/events.result:
update test result
mysql-test/t/events.test:
add tests
sql/event_timed.cc:
- remove stupid check of val_int()
- fix for bug #16419 (Events: can't use timestamp in the schedule)
=> don't use val_int() but only get_date() and use the date!
sql/share/errmsg.txt:
- fix an error message, one more "einen"
sql/sql_yacc.yy:
- handle new return value of event_timed::init_execute_at()
WL#1034 (Internal CRON)
mysql-test/r/events.result:
fix results file
mysql-test/t/events.test:
change test for the fix of bug#16404
sql/lex.h:
enabled/disabled were only for events, going back to enable/disable
fix for bug#16404
sql/sql_yacc.yy:
ENABLED -> ENABLE
DISABLED -> DISABLE
fix for bug#16404 (Events: keyword is ENABLED rather than ENABLE)
WL#1034 (Internal CRON)
mysql-test/r/events.result:
add a test for to test bug #16431
mysql-test/t/events.test:
results of new tests
sql/event.cc:
- more debug info
- pass info to evex_remove_from_cache() whether the operation
was drop or alter. this fixes possible bug that may lead to dropping
of an event when it's altered. also fix for bug#16431
sql/event_executor.cc:
be more verbose and throw more errors
sql/event_timed.cc:
- add ` around the names of the db and the event_name and not
their concatenation. remove ; from the end - unneeded. this fixes bug #16431,
which was failing because after some recursion the query was ending on ;;
which is normally an error in the parser because that's the delimiter
- more debug info
- don't execute lex_end() two times when there's a parse error or thd->is_fatal_error
WL #1034 (Internal CRON)
mysql-test/r/events.result:
fix the results
mysql-test/t/disabled.def:
make it enabled
mysql-test/t/events.test:
- comment out some tests (having problems now)
- add test for fix for bug#16548
sql/sql_yacc.yy:
- fix for bug#16548 (Events: can't alter clause for preserve)
- prefix optional non-terminals with opt_
- add a bit more debug messages
- disable events.test for now due to a bug
mysql-test/r/events.result:
fix result
mysql-test/t/disabled.def:
make it disabled
mysql-test/t/events.test:
disable show processlist
sql/event_executor.cc:
a bit more debug messages
- various fixes of test cases
(hopefully the last pre-push update before the push)
mysql-test/include/system_db_struct.inc:
extend test case to include testing for event system table
mysql-test/r/events.result:
results of events test
mysql-test/r/system_mysql_db.result:
more testing - add structure of event system table
mysql-test/t/events.test:
test case for events (internal CRON)
mysql-test/t/system_mysql_db_fix.test:
drop event table and leave the test database empty
scripts/mysql_create_system_tables.sh:
add missing create table statement
scripts/mysql_fix_privilege_tables.sql:
don't specify the database. this fixes a failing test case which creates the
tables not on mysql but on a test database and then tests again mysql.
sql/event_executor.cc:
if asked to stop -> stop.
- fixed test results
- fixed bug caught by information_schema.test . Bison temporal
variables are very nice but extremely error-prone (Count one more
time just to be sure).
mysql-test/r/connect.result:
fix result for WL#1034 (internal CRON)
mysql-test/r/events.result:
fix result for WL#1034 (internal CRON)
mysql-test/r/grant.result:
fix result for WL#1034 (internal CRON)
mysql-test/r/information_schema.result:
fix result for WL#1034 (internal CRON)
mysql-test/r/lowercase_table_grant.result:
fix result for WL#1034 (internal CRON)
mysql-test/r/ps.result:
fix result for WL#1034 (internal CRON)
mysql-test/r/system_mysql_db.result:
fix result for WL#1034 (internal CRON)
mysql-test/t/events.test:
fix result for WL#1034 (internal CRON)
sql/sql_yacc.yy:
- fix bug introduced by me when making usage of temporal
bison variables. COUNT 7 times then write!
- fix EVENT_ACL problem that GRANT ALL on some_db.* to someone@somewhere did not get to mysql.db
- fix crash when the following is executed :
CREATE EVENT P() CREATE EVENT E ON SCHEDULER 1 SECOND DO ROLLBACK;
(creation works as well as calling P() which creates the event).
mysql-test/lib/init_db.sql:
- fix init_db.sql so add Event_priv to the database privs, many tests failed because of that
ommision
- remove the quotes from the column names
mysql-test/t/events.test:
- fix the small test, don't create own db
scripts/mysql_fix_privilege_tables.sql:
- fix that
sql/event.cc:
- be defensive and don't crash if outside has already has opened some table
sql/event_executor.cc:
- show in SHOW PROCESSLIST - "event_scheduler" as name of the user of the main thread
- use "localhost" as the host where event_scheduler comes from
- comment out some debug info, fix other debug info
sql/event_timed.cc:
- enable EVENT creation inside SP. sphead from lex->sphead goes to et->sphead. it's there only
if we compile the event. OTOH when doing
CREATE PROCEDURE PROC() CREATE EVENT SOME_EV ON SCHEDULE EVERY 1 SECOND DO ROLLBACK;
I have only to get the body of the event which is anonymous SP. Before it being "compiled"
but then freed without being used because a bit later it is compiled one more time before
being put in the events cache. So it was good that the memory structures weren't reused but
scrapped out. Now lex->sphead is not needed during event creation but only where the event's
body starts and where it ends so to be able at later stage to compile this anonymous SP (the
body of the event).
sql/sp_head.cc:
- copy over a fix to a crash
sql/sql_acl.h:
- fix privileges.
There was _NO_ documentation about that. Another CHUNK had to be created to so EVENT_ACL gets shifted to
it's place in the db table. So how this is calculated? EVENT_ACL is 1 << 26. Remember 26, see which poistion
in the db table is EVENT_ACL, it's 17, counted from 0. 26 - 17 = 9, then shift it with 9.
CHUNKS are created because in some cases some privileges are in chunks and they are shifted at once. There are
few chunks of such privileges which has to be shifted to get to exactly the structure of mysql.db table.
sql/sql_parse.cc:
- ok, we don't care anymore about lex->sphead because our sphead is lex->et->sphead
sql/sql_yacc.yy:
- bail out if new event_timed returns 0x0
- enable creation of an event inside a SP
CREATE PROCEDURE P() CREATE EVENT E ON SCHEDULE EVERY 1 SECOND DO SELECT 1;