summaryrefslogtreecommitdiff
path: root/sql/event_db_repository.cc
diff options
context:
space:
mode:
authoranozdrin/alik@station. <>2007-10-19 19:57:08 +0400
committeranozdrin/alik@station. <>2007-10-19 19:57:08 +0400
commitc60397ef1988ed1286a4d99dc2b9f9216c5dd98b (patch)
tree20d207ba5cba2e066daefa6ce8ca6d5bdde321aa /sql/event_db_repository.cc
parentedec79d60a0fbb8156c6f4649401be5cf5f0b192 (diff)
downloadmariadb-git-c60397ef1988ed1286a4d99dc2b9f9216c5dd98b.tar.gz
Patch for BUG#31111: --read-only crashes MySQL (events fail to load).
There actually were several problems here: - WRITE-lock is required to load events from the mysql.event table, but in the read-only mode an ordinary user can not acquire it; - Security_context::master_access attribute was not properly initialized in Security_context::init(), which led to differences in behavior with and without debug configure options. - if the server failed to load events from mysql.event, it forgot to close the mysql.event table, that led to the coredump, described in the bug report. The patch is to fix all these problems: - Use the super-user to acquire WRITE-lock on the mysql.even table; - The WRITE-lock is acquired by the event scheduler in two cases: - on initial loading of events from the database; - when an event has been executed, so its attributes should be updated. Other cases when WRITE-lock is needed for the mysql.event table happen under the user account. So, nothing should be changed there for the read-only mode. The user is able to create/update/drop an event only if he is a super-user. - Initialize Security_context::master_access; - Close the mysql.event table in case something went wrong.
Diffstat (limited to 'sql/event_db_repository.cc')
-rw-r--r--sql/event_db_repository.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index 705bd8b2704..4451e763ff7 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -525,6 +525,10 @@ Event_db_repository::fill_schema_events(THD *thd, TABLE_LIST *tables,
- whether this open mode would work under LOCK TABLES, or inside a
stored function or trigger.
+ Note that if the table can't be locked successfully this operation will
+ close it. Therefore it provides guarantee that it either opens and locks
+ table or fails without leaving any tables open.
+
@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 +548,10 @@ Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type,
tables.init_one_table("mysql", "event", lock_type);
if (simple_open_n_lock_tables(thd, &tables))
+ {
+ close_thread_tables(thd, FALSE, FALSE);
DBUG_RETURN(TRUE);
+ }
*table= tables.table;
tables.table->use_all_columns();
@@ -995,6 +1002,8 @@ update_timing_fields_for_event(THD *thd,
if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based();
+ DBUG_ASSERT(thd->security_ctx->master_access & SUPER_ACL);
+
if (open_event_table(thd, TL_WRITE, &table))
goto end;