|
|||||||||||
|
bk commit into 5.1 tree (anozdrin:1.2600) BUG#31111
From: Alexander Nozdrin <alik(at)mysql.com>
Date: Wed Oct 17 2007 - 02:05:55 EDT
ChangeSet@1.2600, 2007-10-17 10:05:50+04:00, anozdrin@station. +7 -0 Patch for BUG#31111: --read-only crashes MySQL (events fail to load). There actually were several problems here:
The patch is to fix all these problems:
mysql-test/r/bug31111.result@1.1, 2007-10-17 10:05:48+04:00, anozdrin@station. +53 -0 Result file. mysql-test/r/bug31111.result@1.0, 2007-10-17 10:05:48+04:00, anozdrin@station. +0 -0 mysql-test/t/bug31111-master.opt@1.1, 2007-10-17 10:05:48+04:00, anozdrin@station. +1 -0 A test case for BUG#31111. mysql-test/t/bug31111-master.opt@1.0, 2007-10-17 10:05:48+04:00, anozdrin@station. +0 -0 mysql-test/t/bug31111.test@1.1, 2007-10-17 10:05:48+04:00, anozdrin@station. +101 -0 A test case for BUG#31111. mysql-test/t/bug31111.test@1.0, 2007-10-17 10:05:48+04:00, anozdrin@station. +0 -0 sql/event_db_repository.cc@1.37, 2007-10-17 10:05:48+04:00, anozdrin@station. +23 -3
sql/events.cc@1.85, 2007-10-17 10:05:48+04:00, anozdrin@station. +15 -1 Open the mysql.event table as the super user to be able to acquire WRITE-lock in the read-only mode. sql/mysqld.cc@1.670, 2007-10-17 10:05:48+04:00, anozdrin@station. +3 -0 If something went wrong with event loading, we the replication module should be deinitialized prior to general exit procedure. sql/sql_class.cc@1.351, 2007-10-17 10:05:48+04:00, anozdrin@station. +1 -0 Initialize Security_context::master_acces. diff -Nrup a/mysql-test/r/bug31111.result b/mysql-test/r/bug31111.result --- /dev/null Wed Dec 31 16:00:00 196900@@ -0,0 +1,53 @@ +SELECT @@global.read_only; +@@global.read_only +1 + +GRANT EVENT ON *.* TO u1@localhost; + +# +# Connection: con1 (u1@localhost/test). +# + +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; +ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement + +ALTER EVENT e1 COMMENT 'comment'; +ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement + +DROP EVENT e1; +ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement + +# +# Connection: default. +# + +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; + +ALTER EVENT e1 COMMENT 'comment'; + +DROP EVENT e1; + +CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND DO SET @a = 1; +CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO SET @a = 1; + +SELECT name, last_executed IS NULL FROM mysql.event; +name last_executed IS NULL +e1 1 +e2 1 + +SET GLOBAL EVENT_SCHEDULER = ON; + +# Sleeping for 3 seconds... + +SELECT name, last_executed IS NULL FROM mysql.event; +name last_executed IS NULL +e2 0 + +SET GLOBAL EVENT_SCHEDULER = OFF; + +DROP EVENT e1; +ERROR HY000: Unknown event 'e1' + +DROP EVENT e2; + +# That is it. diff -Nrup a/mysql-test/t/bug31111-master.opt b/mysql-test/t/bug31111-master.opt --- /dev/null Wed Dec 31 16:00:00 196900@@ -0,0 +1 @@ +--read-only diff -Nrup a/mysql-test/t/bug31111.test b/mysql-test/t/bug31111.test --- /dev/null Wed Dec 31 16:00:00 196900@@ -0,0 +1,101 @@ +# +# BUG#31111: --read-only crashes MySQL (events fail to load). +# +# It actually does not matter what SQL statements are here. The thing is being +# tested is that the server is able to start. +# + +SELECT @@global.read_only; + +--echo + +# Check that an ordinary user can not create/update/drop events. + +GRANT EVENT ON *.* TO u1@localhost; + +--echo + +--echo # +--echo # Connection: con1 (u1@localhost/test). +--echo # + +--connect(con1,localhost,u1,,test) + +--echo + +--error ER_OPTION_PREVENTS_STATEMENT +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; + +--echo + +--error ER_OPTION_PREVENTS_STATEMENT +ALTER EVENT e1 COMMENT 'comment'; + +--echo + +--error ER_OPTION_PREVENTS_STATEMENT +DROP EVENT e1; + +--echo + +--disconnect con1 + +--echo # +--echo # Connection: default. +--echo # + +--connection default + +# Check that the super user still can create/update/drop events. + +--echo + +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; + +--echo + +ALTER EVENT e1 COMMENT 'comment'; + +--echo + +DROP EVENT e1; + +--echo + +# Check that the scheduler is able to update event. + +CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND DO SET @a = 1; +CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO SET @a = 1; + +--echo + +SELECT name, last_executed IS NULL FROM mysql.event; + +--echo + +SET GLOBAL EVENT_SCHEDULER = ON; + +--echo + +--echo # Sleeping for 3 seconds... +--sleep 3 + +--echo + +SELECT name, last_executed IS NULL FROM mysql.event; + +--echo + +SET GLOBAL EVENT_SCHEDULER = OFF; + +--echo + +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT e1; + +--echo + +DROP EVENT e2; + +--echo +--echo # That is it. diff -Nrup a/sql/event_db_repository.cc b/sql/event_db_repository.cc --- a/sql/event_db_repository.cc 2007-08-25 12:43:10 +04:00@@ -525,6 +525,9 @@ Event_db_repository::fill_schema_events(
+ Note, if the table can not be open, this operation will clean out all @param[in] thd Thread context @param[in] lock_type How to lock the table @param[out] table We will store the open table here@@ -544,7 +547,10 @@ Event_db_repository::open_event_table(TH tables.init_one_table("mysql", "event", lock_type);
if (simple_open_n_lock_tables(thd, &tables))
DBUG_RETURN(TRUE);
*table= tables.table;
DBUG_ENTER("Event_db_repository::update_timing_fields_for_event");
@@ -995,7 +1002,20 @@ update_timing_fields_for_event(THD *thd,
if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based();
fields= table->field;
goto end;
end:
--- a/sql/events.cc 2007-08-15 19:08:40 +04:00@@ -1124,11 +1124,25 @@ Events::load_events_from_db(THD *thd)
READ_RECORD read_record_info;
DBUG_ENTER("Events::load_events_from_db"); DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
if (Events::init(opt_noacl))
unireg_abort(1);
sql_print_information(ER(ER_STARTUP),my_progname,server_version,
((unix_sock == INVALID_SOCKET) ? (char*) ""
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc 2007-10-15 16:42:39 +04:00
@@ -2404,6 +2404,7 @@ void Security_context::init()
host= user= priv_user= ip= 0;
-- MySQL Code Commits Mailing List For list archives: http://lists.mysql.com/commits To unsubscribe: http://lists.mysql.com/commits?unsub=lists@pantek.comReceived on Wed Oct 17 02:05:08 2007 This archive was generated by hypermail 2.1.8 : Thu Jul 03 2008 - 10:03:21 EDT |
||||||||||
|
|||||||||||