mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
2a0d2fef51
cause ROLLBACK of statement", part 1. Review fixes. Do not send OK/EOF packets to the client until we reached the end of the current statement. This is a consolidation, to keep the functionality that is shared by all SQL statements in one place in the server. Currently this functionality includes: - close_thread_tables() - log_slow_statement(). After this patch and the subsequent patch for Bug#12713, it shall also include: - ha_autocommit_or_rollback() - net_end_statement() - query_cache_end_of_result(). In future it may also include: - mysql_reset_thd_for_next_command(). include/mysql_com.h: Rename now unused members of NET: no_send_ok, no_send_error, report_error. These were server-specific variables related to the client/server protocol. They have been made obsolete by this patch. Previously the same members of NET were used to store the error message both on the client and on the server. The error message was stored in net.last_error (client: mysql->net.last_error, server: thd->net.last_error). The error code was stored in net.last_errno (client: mysql->net.last_errno, server: thd->net.last_errno). The server error code and message are now stored elsewhere (in the Diagnostics_area), thus NET members are no longer used by the server. Rename last_error to client_last_error, last_errno to client_last_errno to avoid potential bugs introduced by merges. include/mysql_h.ic: Update the ABI file to reflect a rename. Renames do not break the binary compatibility. libmysql/libmysql.c: Rename last_error to client_last_error, last_errno to client_last_errno. This is necessary to ensure no unnoticed bugs introduced by merged changesets. Remove net.report_error, net.no_send_ok, net.no_send_error. libmysql/manager.c: Rename net.last_errno to net.client_last_errno. libmysqld/lib_sql.cc: Rename net.last_errno to net.client_last_errno. Update the embedded implementation of the client-server protocol to reflect the refactoring of protocol.cc. libmysqld/libmysqld.c: Rename net.last_errno to net.client_last_errno. mysql-test/r/events.result: Update to reflect the change in mysql_rm_db(). Now we drop stored routines and events for a given database name only if there is a directory for this database name. ha_drop_database() and query_cache_invalidate() are called likewise. Previously we would attempt to drop routines/events even if database directory was not found (it worked, since routines and events are stored in tables). This fixes Bug 29958 "Weird message on DROP DATABASE if mysql.proc does not exist". The change was done because the previous code used to call send_ok() twice, which led to an assertion failure when asserts against it were added by this patch. mysql-test/r/grant.result: Fix the patch for Bug 16470, now FLUSH PRIVILEGES produces an error if mysql.procs_priv is missing. This fixes the assert that send_ok() must not called after send_error() (the original patch for Bug 16470 was prone to this). mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result: Produce a more detailed error message. mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result: Produce a more detailed error message. mysql-test/t/grant.test: Update the test, now FLUSH PRIVILEGES returns an error if mysql.procs_priv is missing. server-tools/instance-manager/mysql_connection.cc: Rename net.last_errno to net.client_last_errno. sql/ha_ndbcluster_binlog.cc: Add asserts. Use getters to access statement status information. Add a comment why run_query() is broken. Reset the diagnostics area in the end of run_query() to fulfill the invariant that the diagnostics_area is never assigned twice per statement (see the comment in the code when this can happen). We still do not clear thd->is_fatal_error and thd->is_slave_error, which may lead to bugs, I consider the whole affair as something to be dealt with separately. sql/ha_partition.cc: fatal_error() doesn't set an error by itself. Perhaps we should remove this method altogether and instead add a flag to my_error to set thd->is_fatal_error property. Meanwhile, this change is a part of inspection made to the entire source code with the goal to ensure that fatal_error() is always accompanied by my_error(). sql/item_func.cc: There is no net.last_error anymore. Remove the obsolete assignment. sql/log_event.cc: Use getters to access statement error status information. sql/log_event_old.cc: Use getters to access statement error status information. sql/mysqld.cc: Previously, if a continue handler for an error was found, my_message_sql() would not set an error in THD. Since the current statement must be aborted in any case, find_handler() had a hack to assign thd->net.report_error to 1. Remove this hack. Set an error in my_message_sql() even if the continue handler is found. The error will be cleared anyway when the handler is executed. This is one action among many in this patch to ensure the invariant that whenever thd->is_error() is TRUE, we have a message in thd->main_da.message(). sql/net_serv.cc: Use a full-blown my_error() in net_serv.cc to report an error, instead of just setting net->last_errno. This ensures the invariant that whenever thd->is_error() returns TRUE, we have a message in thd->main_da.message(). Remove initialization of removed NET members. sql/opt_range.cc: Use my_error() instead of just raising thd->net.report_error. This ensures the invariant that whenever thd->is_error() returns TRUE, there is a message in thd->main_da.message(). sql/opt_sum.cc: Move invocation of fatal_error() right next to the place where we set the error message. That makes it easier to track that whenever fatal_error() is called, there is a message in THD. sql/protocol.cc: Rename send_ok() and send_eof() to net_send_ok() and net_send_eof() respectively. These functions write directly to the network and are not for use anywhere outside the client/server protocol code. Remove the code that was responsible for cases when either there is no error code, or no error message, or both. Instead the calling code ensures that they are always present. Asserts are added to enforce the invariant. Instead of a direct access to thd->server_status and thd->total_warn_count use function parameters, since these from now on don't always come directly from THD. Introduce net_end_statement(), the single-entry-point replacement API for send_ok(), send_eof() and net_send_error(). Implement Protocol::end_partial_result_set to use in select_send::abort() when there is a continue handler. sql/protocol.h: Update declarations. sql/repl_failsafe.cc: Use getters to access statement status information in THD. Rename net.last_error to net.client_last_error. sql/rpl_record.cc: Set an error message in prepare_record() if there is no default value for the field -- later we do print this message to the client. sql/rpl_rli.cc: Use getters to access statement status information in THD. sql/slave.cc: In create_table_from_dump() (a common function that is used in LOAD MASTER TABLE SQL statement and COM_LOAD_MASTER_DATA), instead of hacks with no_send_ok, clear the diagnostics area when mysql_rm_table() succeeded. Update has_temporary_error() to work correctly when no error is set. This is the case when Incident_log_event is executed: it always returns an error but does not set an error message. Use getters to access error status information. sql/sp_head.cc: Instead of hacks with no_send_error, work through the diagnostics area interface to suppress sending of OK/ERROR packets to the client. Move query_cache_end_of_result before log_slow_statement(), similarly to how it's done in dispatch_command(). sql/sp_rcontext.cc: Remove hacks with assignment of thd->net.report_error, they are not necessary any more (see the changes in mysqld.cc). sql/sql_acl.cc: Use getters to access error status information in THD. sql/sql_base.cc: Access thd->main_da.sql_errno() only if there is an error. This fixes a bug when auto-discovery, that was effectively disabled under pre-locking. sql/sql_binlog.cc: Remove hacks with no_send_ok/no_send_error, they are not necessary anymore: the caller is responsible for network communication. sql/sql_cache.cc: Disable sending of OK/ERROR/EOF packet in the end of dispatch_command if the response has been served from the query cache. This raises the question whether we should store EOF packet in the query cache at all, or generate it anew for each statement (we should generate it anew), but this is to be addressed separately. sql/sql_class.cc: Implement class Diagnostics_area. Please see comments in sql_class.h for details. Fix a subtle coding mistake in select_send::send_data: when on slave, an error in Item::send() was ignored. The problem became visible due to asserts that the diagnostics area is never double assigned. Remove initialization of removed NET members. In select_send::abort() do not call select_send::send_eof(). This is not inheritance-safe. Even if a stored procedure continue handler is found, the current statement is aborted, not succeeded. Instead introduce a Protocol API to send the required response, Protocol::end_partial_result_set(). This simplifies implementation of select_send::send_eof(). No need to add more asserts that there is no error, there is an assert inside Diagnostics_area::set_ok_status() already. Leave no trace of no_send_* in the code. sql/sql_class.h: Declare class Diagnostics_area. Remove the hack with no_send_ok from Substatement_state. Provide inline implementations of send_ok/send_eof. Add commetns. sql/sql_connect.cc: Remove hacks with no_send_error. Since now an error in THD is always set if net->error, it's not necessary to check both net->error and thd->is_error() in the do_command loop. Use thd->main_da.message() instead of net->last_errno. Remove the hack with is_slave_error in sys_init_connect. Since now we do not reset the diagnostics area in net_send_error (it's reset at the beginning of the next statement), we can access it safely even after execute_init_command. sql/sql_db.cc: Update the code to satisfy the invariant that the diagnostics area is never assigned twice. Incidentally, this fixes Bug 29958 "Weird message on DROP DATABASE if mysql.proc does not exist". sql/sql_delete.cc: Change multi-delete to abort in abort(), as per select_send protocol. Fixes the merge error with the test for Bug 29136 sql/sql_derived.cc: Use getters to access error information. sql/sql_insert.cc: Use getters to access error information. sql-common/client.c: Rename last_error to client_last_error, last_errno to client_last_errno. sql/sql_parse.cc: Remove hacks with no_send_error. Deploy net_end_statement(). The story of COM_SHUTDOWN is interesting. Long story short, the server would become on its death's door, and only no_send_ok/no_send_error assigned by send_ok()/net_send_error() would hide its babbling from the client. First of all, COM_QUIT does not require a response. So, the comment saying "Let's send a response to possible COM_QUIT" is not only groundless (even mysqladmin shutdown/mysql_shutdown() doesn't send COM_QUIT after COM_SHUTDOWN), it's plainly incorrect. Secondly, besides this additional 'OK' packet to respond to a hypothetical COM_QUIT, there was the following code in dispatch_command(): if (thd->killed) thd->send_kill_message(); if (thd->is_error() net_send_error(thd); This worked out really funny for the thread through which COM_SHUTDOWN was delivered: we would get COM_SHUTDOWN, say okay, say okay again, kill everybody, get the kill signal ourselves, and then attempt to say "Server shutdown in progress" to the client that is very likely long gone. This all became visible when asserts were added that the Diagnostics_area is not assigned twice. Move query_cache_end_of_result() to the end of dispatch_command(), since net_send_eof() has been moved there. This is safe, query_cache_end_of_result() is a no-op if there is no started query in the cache. Consistently use select_send interface to call abort() or send_eof() depending on the operation result. Remove thd->fatal_error() from reset_master(), it was a no-op. in hacks with no_send_error woudl save us from complete breakage of the client/server protocol. Consistently use select_send::abort() whenever there is an error, and select_send::send_eof() in case of success. The issue became visible due to added asserts. sql/sql_partition.cc: Always set an error in THD whenever there is a call to fatal_error(). sql/sql_prepare.cc: Deploy class Diagnostics_area. Remove the unnecessary juggling with the protocol in Select_fetch_protocol_binary::send_eof(). EOF packet format is protocol-independent. sql/sql_select.cc: Call fatal_error() directly in opt_sum_query. Call my_error() whenever we call thd->fatal_error(). sql/sql_servers.cc: Use getters to access error information in THD. sql/sql_show.cc: Use getters to access error information in THD. Add comments. Call my_error() whenever we call fatal_error(). sql/sql_table.cc: Replace hacks with no_send_ok with the interface of the diagnostics area. Clear the error if ENOENT error in ha_delete_table(). sql/sql_update.cc: Introduce multi_update::abort(), which is the proper way to abort a multi-update. This fixes the merge conflict between this patch and the patch for Bug 29136. sql/table.cc: Use a getter to access error information in THD. sql/tztime.cc: Use a getter to access error information in THD.
745 lines
33 KiB
Text
745 lines
33 KiB
Text
drop database if exists events_test;
|
||
drop database if exists db_x;
|
||
drop database if exists mysqltest_db2;
|
||
drop database if exists mysqltest_no_such_database;
|
||
create database events_test;
|
||
use events_test;
|
||
CREATE USER pauline@localhost;
|
||
CREATE DATABASE db_x;
|
||
GRANT EVENT ON db_x.* TO pauline@localhost;
|
||
USE db_x;
|
||
CREATE TABLE x_table(a int);
|
||
CREATE EVENT e_x1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db_x;
|
||
CREATE EVENT e_x2 ON SCHEDULE EVERY 1 SECOND DO DROP TABLE x_table;
|
||
SHOW DATABASES LIKE 'db_x';
|
||
Database (db_x)
|
||
db_x
|
||
SET GLOBAL event_scheduler=1;
|
||
SHOW DATABASES LIKE 'db_x';
|
||
Database (db_x)
|
||
db_x
|
||
SHOW TABLES FROM db_x;
|
||
Tables_in_db_x
|
||
x_table
|
||
SET GLOBAL event_scheduler=off;
|
||
DROP EVENT e_x1;
|
||
DROP EVENT e_x2;
|
||
DROP DATABASE db_x;
|
||
DROP USER pauline@localhost;
|
||
USE events_test;
|
||
SET GLOBAL event_scheduler=off;
|
||
drop event if exists event1;
|
||
Warnings:
|
||
Note 1305 Event event1 does not exist
|
||
create event event1 on schedule every 15 minute starts now() ends date_add(now(), interval 5 hour) DO begin end;
|
||
alter event event1 rename to event2 enable;
|
||
alter event event2 disable;
|
||
alter event event2 enable;
|
||
alter event event2 on completion not preserve;
|
||
alter event event2 on schedule every 1 year on completion preserve rename to event3 comment "new comment" do begin select 1; end__
|
||
alter event event3 rename to event2;
|
||
drop event event2;
|
||
create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end;
|
||
drop event event2;
|
||
CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1;
|
||
SELECT interval_field, interval_value, body FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
|
||
interval_field interval_value body
|
||
SECOND 10 SELECT 1
|
||
SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
|
||
execute_at IS NULL starts IS NULL ends IS NULL comment
|
||
1 0 1
|
||
ALTER EVENT event_starts_test ON SCHEDULE AT '2020-02-02 20:00:02';
|
||
SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
|
||
execute_at IS NULL starts IS NULL ends IS NULL comment
|
||
0 1 1
|
||
ALTER EVENT event_starts_test COMMENT "non-empty comment";
|
||
SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
|
||
execute_at IS NULL starts IS NULL ends IS NULL comment
|
||
0 1 1 non-empty comment
|
||
ALTER EVENT event_starts_test COMMENT "";
|
||
SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
|
||
execute_at IS NULL starts IS NULL ends IS NULL comment
|
||
0 1 1
|
||
DROP EVENT event_starts_test;
|
||
CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '2020-02-02 20:00:02' ENDS '2022-02-02 20:00:02' DO SELECT 2;
|
||
SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
|
||
execute_at IS NULL starts IS NULL ends IS NULL comment
|
||
1 0 0
|
||
ALTER EVENT event_starts_test COMMENT "non-empty comment";
|
||
SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
|
||
execute_at IS NULL starts IS NULL ends IS NULL comment
|
||
1 0 0 non-empty comment
|
||
ALTER EVENT event_starts_test COMMENT "";
|
||
SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
|
||
execute_at IS NULL starts IS NULL ends IS NULL comment
|
||
1 0 0
|
||
DROP EVENT event_starts_test;
|
||
create table test_nested(a int);
|
||
create event e_43 on schedule every 1 second do set @a = 5;
|
||
alter event e_43 do alter event e_43 do set @a = 4;
|
||
ERROR HY000: Recursion of EVENT DDL statements is forbidden when body is present
|
||
alter event e_43 do
|
||
begin
|
||
alter event e_43 on schedule every 5 minute;
|
||
insert into test_nested values(1);
|
||
end|
|
||
set global event_scheduler = on;
|
||
select db, name, body, status, interval_field, interval_value from mysql.event;
|
||
db name body status interval_field interval_value
|
||
events_test e_43 begin
|
||
alter event e_43 on schedule every 5 minute;
|
||
insert into test_nested values(1);
|
||
end ENABLED MINUTE 5
|
||
drop event e_43;
|
||
drop table test_nested;
|
||
"Let's check whether we can use non-qualified names"
|
||
create table non_qualif(a int);
|
||
create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values (800219);
|
||
select * from non_qualif;
|
||
a
|
||
800219
|
||
drop event non_qualif_ev;
|
||
drop table non_qualif;
|
||
alter event non_existant rename to non_existant_too;
|
||
ERROR HY000: Unknown event 'non_existant'
|
||
set global event_scheduler = off;
|
||
create event existant on schedule at now() + interval 1 year do select 12;
|
||
alter event non_existant rename to existant;
|
||
ERROR HY000: Event 'existant' already exists
|
||
alter event existant rename to events_test.existant;
|
||
ERROR HY000: Same old and new event name
|
||
drop event existant;
|
||
create table t_event3 (a int, b float);
|
||
drop event if exists event3;
|
||
Warnings:
|
||
Note 1305 Event event3 does not exist
|
||
create event event3 on schedule every 50 + 10 minute starts date_add("20100101", interval 5 minute) ends date_add("20151010", interval 5 day) comment "portokala_comment" DO insert into t_event3 values (unix_timestamp(), rand());
|
||
select count(*) from t_event3;
|
||
count(*)
|
||
0
|
||
drop event event3;
|
||
drop table t_event3;
|
||
set names utf8;
|
||
CREATE EVENT root6 ON SCHEDULE EVERY '10:20' MINUTE_SECOND ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1;
|
||
SHOW CREATE EVENT root6;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root6 SYSTEM CREATE EVENT `root6` ON SCHEDULE EVERY '10:20' MINUTE_SECOND STARTS '#' ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root7 on schedule every 2 year do select 1;
|
||
SHOW CREATE EVENT root7;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root7 SYSTEM CREATE EVENT `root7` ON SCHEDULE EVERY 2 YEAR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root8 on schedule every '2:5' year_month do select 1;
|
||
SHOW CREATE EVENT root8;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root8 SYSTEM CREATE EVENT `root8` ON SCHEDULE EVERY '2-5' YEAR_MONTH STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root8_1 on schedule every '2:15' year_month do select 1;
|
||
SHOW CREATE EVENT root8_1;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root8_1 SYSTEM CREATE EVENT `root8_1` ON SCHEDULE EVERY '3-3' YEAR_MONTH STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root9 on schedule every 2 week ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' do select 1;
|
||
SHOW CREATE EVENT root9;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root9 SYSTEM CREATE EVENT `root9` ON SCHEDULE EVERY 2 WEEK STARTS '#' ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root10 on schedule every '20:5' day_hour do select 1;
|
||
SHOW CREATE EVENT root10;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root10 SYSTEM CREATE EVENT `root10` ON SCHEDULE EVERY '20 5' DAY_HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root11 on schedule every '20:25' day_hour do select 1;
|
||
SHOW CREATE EVENT root11;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root11 SYSTEM CREATE EVENT `root11` ON SCHEDULE EVERY '21 1' DAY_HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root12 on schedule every '20:25' hour_minute do select 1;
|
||
SHOW CREATE EVENT root12;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root12 SYSTEM CREATE EVENT `root12` ON SCHEDULE EVERY '20:25' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root13 on schedule every '25:25' hour_minute do select 1;
|
||
SHOW CREATE EVENT root13;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root13 SYSTEM CREATE EVENT `root13` ON SCHEDULE EVERY '25:25' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root13_1 on schedule every '11:65' hour_minute do select 1;
|
||
SHOW CREATE EVENT root13_1;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root13_1 SYSTEM CREATE EVENT `root13_1` ON SCHEDULE EVERY '12:5' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root14 on schedule every '35:35' minute_second do select 1;
|
||
SHOW CREATE EVENT root14;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root14 SYSTEM CREATE EVENT `root14` ON SCHEDULE EVERY '35:35' MINUTE_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root15 on schedule every '35:66' minute_second do select 1;
|
||
SHOW CREATE EVENT root15;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root15 SYSTEM CREATE EVENT `root15` ON SCHEDULE EVERY '36:6' MINUTE_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root16 on schedule every '35:56' day_minute do select 1;
|
||
SHOW CREATE EVENT root16;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root16 SYSTEM CREATE EVENT `root16` ON SCHEDULE EVERY '1 11:56' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root17 on schedule every '35:12:45' day_minute do select 1;
|
||
SHOW CREATE EVENT root17;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root17 SYSTEM CREATE EVENT `root17` ON SCHEDULE EVERY '35 12:45' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root17_1 on schedule every '35:25:65' day_minute do select 1;
|
||
SHOW CREATE EVENT root17_1;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root17_1 SYSTEM CREATE EVENT `root17_1` ON SCHEDULE EVERY '36 2:5' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root18 on schedule every '35:12:45' hour_second do select 1;
|
||
SHOW CREATE EVENT root18;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root18 SYSTEM CREATE EVENT `root18` ON SCHEDULE EVERY '35:12:45' HOUR_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root19 on schedule every '15:59:85' hour_second do select 1;
|
||
SHOW CREATE EVENT root19;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root19 SYSTEM CREATE EVENT `root19` ON SCHEDULE EVERY '16:0:25' HOUR_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
create event root20 on schedule every '50:20:12:45' day_second do select 1;
|
||
SHOW CREATE EVENT root20;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
root20 SYSTEM CREATE EVENT `root20` ON SCHEDULE EVERY '50 20:12:45' DAY_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
set names cp1251;
|
||
create event <20><><EFBFBD><EFBFBD>21 on schedule every '50:23:59:95' day_second COMMENT '<27><><EFBFBD><EFBFBD> <20> 1251 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' do select 1;
|
||
SHOW CREATE EVENT <20><><EFBFBD><EFBFBD>21;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>21 SYSTEM CREATE EVENT `руут21` ON SCHEDULE EVERY '51 0:0:35' DAY_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'това е 1251 коментар' DO select 1 cp1251 cp1251_general_ci latin1_swedish_ci
|
||
insert into mysql.event (
|
||
db,
|
||
name,
|
||
body,
|
||
definer,
|
||
interval_value,
|
||
interval_field,
|
||
originator,
|
||
character_set_client,
|
||
collation_connection,
|
||
db_collation,
|
||
body_utf8)
|
||
values (
|
||
database(),
|
||
"root22",
|
||
"select 1",
|
||
user(),
|
||
100,
|
||
"SECOND_MICROSECOND",
|
||
1,
|
||
'utf8',
|
||
'utf8_general_ci',
|
||
'utf8_general_ci',
|
||
'select 1');
|
||
show create event root22;
|
||
ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
|
||
SHOW EVENTS;
|
||
ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
|
||
drop event root22;
|
||
create event root23 on schedule every -100 year do select 1;
|
||
ERROR HY000: INTERVAL is either not positive or too big
|
||
create event root23 on schedule every 222222222222222222222 year do select 1;
|
||
ERROR HY000: INTERVAL is either not positive or too big
|
||
drop event root6;
|
||
drop event root7;
|
||
drop event root8;
|
||
drop event root8_1;
|
||
drop event root9;
|
||
drop event root10;
|
||
drop event root11;
|
||
drop event root12;
|
||
drop event root13;
|
||
drop event root13_1;
|
||
drop event root14;
|
||
drop event root15;
|
||
drop event root16;
|
||
drop event root17;
|
||
drop event root17_1;
|
||
drop event root18;
|
||
drop event root19;
|
||
drop event root20;
|
||
drop event <20><><EFBFBD><EFBFBD>21;
|
||
set names latin1;
|
||
Create a test event. Only event metadata is relevant,
|
||
the actual schedule and body are not.
|
||
CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
|
||
SHOW EVENTS;
|
||
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
|
||
events_test intact_check root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||
Try to alter mysql.event: the server should fail to load
|
||
event information after mysql.event was tampered with.
|
||
|
||
First, let's add a column to the end and make sure everything
|
||
works as before
|
||
|
||
ALTER TABLE mysql.event ADD dummy INT;
|
||
SHOW EVENTS;
|
||
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
|
||
events_test intact_check root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||
SELECT event_name FROM INFORMATION_SCHEMA.events;
|
||
event_name
|
||
intact_check
|
||
SHOW CREATE EVENT intact_check;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
intact_check SYSTEM CREATE EVENT `intact_check` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO SELECT "nothing" latin1 latin1_swedish_ci latin1_swedish_ci
|
||
DROP EVENT no_such_event;
|
||
ERROR HY000: Unknown event 'no_such_event'
|
||
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
|
||
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
|
||
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
|
||
DROP EVENT intact_check_1;
|
||
ERROR HY000: Unknown event 'intact_check_1'
|
||
DROP EVENT intact_check_2;
|
||
DROP EVENT intact_check;
|
||
DROP DATABASE IF EXISTS mysqltest_no_such_database;
|
||
Warnings:
|
||
Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist
|
||
CREATE DATABASE mysqltest_db2;
|
||
DROP DATABASE mysqltest_db2;
|
||
SELECT @@event_scheduler;
|
||
@@event_scheduler
|
||
OFF
|
||
SHOW VARIABLES LIKE 'event_scheduler';
|
||
Variable_name Value
|
||
event_scheduler OFF
|
||
SET GLOBAL event_scheduler=OFF;
|
||
ALTER TABLE mysql.event DROP dummy;
|
||
CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
|
||
|
||
Now let's add a column to the first position: the server
|
||
expects to see event schema name there
|
||
|
||
ALTER TABLE mysql.event ADD dummy INT FIRST;
|
||
SHOW EVENTS;
|
||
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted
|
||
SELECT event_name FROM INFORMATION_SCHEMA.events;
|
||
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted
|
||
SHOW CREATE EVENT intact_check;
|
||
ERROR HY000: Unknown event 'intact_check'
|
||
DROP EVENT no_such_event;
|
||
ERROR HY000: Unknown event 'no_such_event'
|
||
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
|
||
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted
|
||
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
|
||
ERROR HY000: Unknown event 'intact_check_1'
|
||
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
|
||
ERROR HY000: Unknown event 'intact_check_1'
|
||
DROP EVENT intact_check_1;
|
||
ERROR HY000: Unknown event 'intact_check_1'
|
||
DROP EVENT intact_check_2;
|
||
ERROR HY000: Unknown event 'intact_check_2'
|
||
DROP EVENT intact_check;
|
||
ERROR HY000: Unknown event 'intact_check'
|
||
DROP DATABASE IF EXISTS mysqltest_no_such_database;
|
||
Warnings:
|
||
Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist
|
||
CREATE DATABASE mysqltest_db2;
|
||
DROP DATABASE mysqltest_db2;
|
||
SELECT @@event_scheduler;
|
||
@@event_scheduler
|
||
OFF
|
||
SHOW VARIABLES LIKE 'event_scheduler';
|
||
Variable_name Value
|
||
event_scheduler OFF
|
||
SET GLOBAL event_scheduler=OFF;
|
||
Clean up
|
||
ALTER TABLE mysql.event DROP dummy;
|
||
DELETE FROM mysql.event;
|
||
CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
|
||
Back up the table, further changes are not reversible
|
||
CREATE TABLE event_like LIKE mysql.event;
|
||
INSERT INTO event_like SELECT * FROM mysql.event;
|
||
|
||
Drop some columns and try more checks.
|
||
|
||
|
||
ALTER TABLE mysql.event DROP comment, DROP starts;
|
||
SHOW EVENTS;
|
||
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted
|
||
SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
|
||
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted
|
||
SHOW CREATE EVENT intact_check;
|
||
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted
|
||
DROP EVENT no_such_event;
|
||
ERROR HY000: Unknown event 'no_such_event'
|
||
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
|
||
ERROR HY000: Column count of mysql.event is wrong. Expected 22, found 20. The table is probably corrupted
|
||
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
|
||
ERROR HY000: Unknown event 'intact_check_1'
|
||
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
|
||
ERROR HY000: Unknown event 'intact_check_1'
|
||
DROP EVENT intact_check_1;
|
||
ERROR HY000: Unknown event 'intact_check_1'
|
||
DROP EVENT intact_check_2;
|
||
ERROR HY000: Unknown event 'intact_check_2'
|
||
DROP EVENT intact_check;
|
||
DROP DATABASE IF EXISTS mysqltest_no_such_database;
|
||
Warnings:
|
||
Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist
|
||
CREATE DATABASE mysqltest_db2;
|
||
DROP DATABASE mysqltest_db2;
|
||
SELECT @@event_scheduler;
|
||
@@event_scheduler
|
||
OFF
|
||
SHOW VARIABLES LIKE 'event_scheduler';
|
||
Variable_name Value
|
||
event_scheduler OFF
|
||
SET GLOBAL event_scheduler=OFF;
|
||
|
||
Now drop the table, and test again
|
||
|
||
|
||
DROP TABLE mysql.event;
|
||
SHOW EVENTS;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
SELECT event_name FROM INFORMATION_SCHEMA.events;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
SHOW CREATE EVENT intact_check;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
DROP EVENT no_such_event;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
DROP EVENT intact_check_1;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
DROP EVENT intact_check_2;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
DROP EVENT intact_check;
|
||
ERROR 42S02: Table 'mysql.event' doesn't exist
|
||
DROP DATABASE IF EXISTS mysqltest_no_such_database;
|
||
Warnings:
|
||
Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist
|
||
CREATE DATABASE mysqltest_db2;
|
||
DROP DATABASE mysqltest_db2;
|
||
Warnings:
|
||
Error 1146 Table 'mysql.event' doesn't exist
|
||
OK, there is an unnecessary warning about the non-existent table
|
||
but it's not easy to fix and no one complained about it.
|
||
A similar warning is printed if mysql.proc is missing.
|
||
SHOW WARNINGS;
|
||
Level Code Message
|
||
Error 1146 Table 'mysql.event' doesn't exist
|
||
SELECT @@event_scheduler;
|
||
@@event_scheduler
|
||
OFF
|
||
SHOW VARIABLES LIKE 'event_scheduler';
|
||
Variable_name Value
|
||
event_scheduler OFF
|
||
SET GLOBAL event_scheduler=OFF;
|
||
Restore the original table.
|
||
CREATE TABLE mysql.event like event_like;
|
||
DROP TABLE event_like;
|
||
SHOW EVENTS;
|
||
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
|
||
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;
|
||
db name body definer convert_tz(execute_at, 'UTC', 'SYSTEM') on_completion
|
||
events_test e_26 set @a = 5 root@localhost 2017-01-01 00:00:00 DROP
|
||
drop event e_26;
|
||
create event e_26 on schedule at NULL disable do set @a = 5;
|
||
ERROR HY000: Incorrect AT value: 'NULL'
|
||
create event e_26 on schedule at 'definitely not a datetime' disable do set @a = 5;
|
||
ERROR HY000: Incorrect AT value: 'definitely not a datetime'
|
||
set names utf8;
|
||
create event задачка on schedule every 123 minute starts now() ends now() + interval 1 month do select 1;
|
||
drop event задачка;
|
||
set event_scheduler=off;
|
||
ERROR HY000: Variable 'event_scheduler' is a GLOBAL variable and should be set with SET GLOBAL
|
||
set global event_scheduler=3;
|
||
ERROR 42000: Variable 'event_scheduler' can't be set to the value of '3'
|
||
set global event_scheduler=disabled;
|
||
ERROR 42000: Variable 'event_scheduler' can't be set to the value of 'disabled'
|
||
"DISABLE the scheduler. Testing that it does not work when the variable is 0"
|
||
set global event_scheduler=off;
|
||
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 0 process"
|
||
select /*1*/ user, host, db, command, state, info
|
||
from information_schema.processlist
|
||
where (user='event_scheduler')
|
||
order by info;
|
||
user host db command state info
|
||
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=on;
|
||
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);
|
||
"Should have only 2 processes: the scheduler and the locked event"
|
||
select /*2*/ user, host, db, command, state, info
|
||
from information_schema.processlist
|
||
where (info like "select get_lock%" OR user='event_scheduler')
|
||
order by info;
|
||
user host db command state info
|
||
event_scheduler localhost NULL Daemon Waiting for next activation NULL
|
||
root localhost 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 have only 2 processes: the scheduler and the locked event"
|
||
select /*3*/ user, host, db, command, state, info
|
||
from information_schema.processlist
|
||
where (info like "select get_lock%" OR user='event_scheduler')
|
||
order by info;
|
||
user host db command state info
|
||
event_scheduler localhost NULL Daemon Waiting for next activation NULL
|
||
root localhost events_test Connect User lock select get_lock("test_lock2_1", 20)
|
||
set global event_scheduler=off;
|
||
"Should have only our process now:"
|
||
select /*4*/ user, host, db, command, state, info
|
||
from information_schema.processlist
|
||
where (info like "select get_lock%" OR user='event_scheduler')
|
||
order by info;
|
||
user host db command state info
|
||
root localhost events_test Connect User lock select get_lock("test_lock2_1", 20)
|
||
select release_lock("test_lock2_1");
|
||
release_lock("test_lock2_1")
|
||
1
|
||
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: Recursion of EVENT DDL statements is forbidden when body is present
|
||
drop table t_16;
|
||
create event white_space
|
||
on schedule every 10 hour
|
||
disable
|
||
do
|
||
select 1;
|
||
select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space';
|
||
event_schema event_name definer event_definition
|
||
events_test white_space root@localhost select 1
|
||
drop event white_space;
|
||
create event white_space on schedule every 10 hour disable do
|
||
select 2;
|
||
select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space';
|
||
event_schema event_name definer event_definition
|
||
events_test white_space root@localhost select 2
|
||
drop event white_space;
|
||
create event white_space on schedule every 10 hour disable do select 3;
|
||
select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space';
|
||
event_schema event_name definer event_definition
|
||
events_test white_space root@localhost select 3
|
||
drop event white_space;
|
||
create event e1 on schedule every 1 year do set @a = 5;
|
||
create table t1 (s1 int);
|
||
create trigger t1_ai after insert on t1 for each row show create event e1;
|
||
ERROR 0A000: Not allowed to return a result set from a trigger
|
||
drop table t1;
|
||
drop event e1;
|
||
SHOW EVENTS FROM aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||
ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||
SHOW EVENTS FROM ``;
|
||
ERROR 42000: Incorrect database name ''
|
||
SHOW EVENTS FROM `events\\test`;
|
||
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
|
||
|
||
LOCK TABLES mode.
|
||
|
||
create table t1 (a int);
|
||
create event e1 on schedule every 10 hour do select 1;
|
||
lock table t1 read;
|
||
show create event e1;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
select event_name from information_schema.events;
|
||
event_name
|
||
e1
|
||
create event e2 on schedule every 10 hour do select 1;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
alter event e2 disable;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
alter event e2 rename to e3;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
drop event e2;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
drop event e1;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
unlock tables;
|
||
lock table t1 write;
|
||
show create event e1;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
select event_name from information_schema.events;
|
||
event_name
|
||
e1
|
||
create event e2 on schedule every 10 hour do select 1;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
alter event e2 disable;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
alter event e2 rename to e3;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
drop event e2;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
drop event e1;
|
||
ERROR HY000: Table 'event' was not locked with LOCK TABLES
|
||
unlock tables;
|
||
lock table t1 read, mysql.event read;
|
||
show create event e1;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
select event_name from information_schema.events;
|
||
event_name
|
||
e1
|
||
create event e2 on schedule every 10 hour do select 1;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
alter event e2 disable;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
alter event e2 rename to e3;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
drop event e2;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
drop event e1;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
unlock tables;
|
||
lock table t1 write, mysql.event read;
|
||
show create event e1;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
select event_name from information_schema.events;
|
||
event_name
|
||
e1
|
||
create event e2 on schedule every 10 hour do select 1;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
alter event e2 disable;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
alter event e2 rename to e3;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
drop event e2;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
drop event e1;
|
||
ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
|
||
unlock tables;
|
||
lock table t1 read, mysql.event write;
|
||
ERROR HY000: You can't combine write-locking of system tables with other tables or lock types
|
||
lock table t1 write, mysql.event write;
|
||
ERROR HY000: You can't combine write-locking of system tables with other tables or lock types
|
||
lock table mysql.event write;
|
||
show create event e1;
|
||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||
e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
|
||
select event_name from information_schema.events;
|
||
event_name
|
||
e1
|
||
create event e2 on schedule every 10 hour do select 1;
|
||
alter event e2 disable;
|
||
alter event e2 rename to e3;
|
||
drop event e3;
|
||
drop event e1;
|
||
unlock tables;
|
||
Make sure we have left no events
|
||
select event_name from information_schema.events;
|
||
event_name
|
||
|
||
Events in sub-statements, events and prelocking
|
||
|
||
|
||
create event e1 on schedule every 10 hour do select 1;
|
||
create function f1() returns int
|
||
begin
|
||
show create event e1;
|
||
return 1;
|
||
end|
|
||
ERROR 0A000: Not allowed to return a result set from a function
|
||
create trigger trg before insert on t1 for each row
|
||
begin
|
||
show create event e1;
|
||
end|
|
||
ERROR 0A000: Not allowed to return a result set from a trigger
|
||
create function f1() returns int
|
||
begin
|
||
select event_name from information_schema.events;
|
||
return 1;
|
||
end|
|
||
ERROR 0A000: Not allowed to return a result set from a function
|
||
create trigger trg before insert on t1 for each row
|
||
begin
|
||
select event_name from information_schema.events;
|
||
end|
|
||
ERROR 0A000: Not allowed to return a result set from a trigger
|
||
create function f1() returns int
|
||
begin
|
||
create event e2 on schedule every 10 hour do select 1;
|
||
return 1;
|
||
end|
|
||
ERROR HY000: Recursion of EVENT DDL statements is forbidden when body is present
|
||
create function f1() returns int
|
||
begin
|
||
alter event e1 rename to e2;
|
||
return 1;
|
||
end|
|
||
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
|
||
create function f1() returns int
|
||
begin
|
||
drop event e2;
|
||
return 1;
|
||
end|
|
||
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
|
||
----------------------------------------------------------------------
|
||
create trigger trg before insert on t1 for each row
|
||
begin
|
||
set new.a= f1();
|
||
end|
|
||
create function f1() returns int
|
||
begin
|
||
call p1();
|
||
return 0;
|
||
end|
|
||
create procedure p1()
|
||
begin
|
||
select event_name from information_schema.events;
|
||
end|
|
||
insert into t1 (a) values (1)|
|
||
ERROR 0A000: Not allowed to return a result set from a trigger
|
||
drop procedure p1|
|
||
create procedure p1()
|
||
begin
|
||
show create event e1;
|
||
end|
|
||
insert into t1 (a) values (1)|
|
||
ERROR 0A000: Not allowed to return a result set from a trigger
|
||
drop procedure p1|
|
||
create procedure p1()
|
||
begin
|
||
create temporary table tmp select event_name from information_schema.events;
|
||
end|
|
||
expected to work, since we redirect the output into a tmp table
|
||
insert into t1 (a) values (1)|
|
||
select * from tmp|
|
||
event_name
|
||
e1
|
||
drop temporary table tmp|
|
||
drop procedure p1|
|
||
create procedure p1()
|
||
begin
|
||
alter event e1 rename to e2;
|
||
end|
|
||
insert into t1 (a) values (1)|
|
||
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
|
||
drop procedure p1|
|
||
create procedure p1()
|
||
begin
|
||
drop event e1;
|
||
end|
|
||
insert into t1 (a) values (1)|
|
||
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
|
||
drop table t1|
|
||
drop event e1|
|
||
drop database events_test;
|