diff options
author | Alfranio Correia <alfranio.correia@sun.com> | 2010-01-13 12:22:34 +0000 |
---|---|---|
committer | Alfranio Correia <alfranio.correia@sun.com> | 2010-01-13 12:22:34 +0000 |
commit | 40949a3110a97e41d48c24e51004851521dd807b (patch) | |
tree | dddf2d3ec6941e3f9c47deefb52bcfa19ef6a23e /sql/events.cc | |
parent | 26b12adb5d19fea7308edd0c2b49e1c972ea79c3 (diff) | |
parent | 51caeae915d3a5add57a785e69b7ce52cac084ad (diff) | |
download | mariadb-git-40949a3110a97e41d48c24e51004851521dd807b.tar.gz |
merge mysql-next-mr --> mysql-5.1-rpl-merge
Conflicts:
Text conflict in sql/log.cc
Text conflict in sql/slave.cc
Text conflict in sql/sql_base.cc
Diffstat (limited to 'sql/events.cc')
-rw-r--r-- | sql/events.cc | 98 |
1 files changed, 72 insertions, 26 deletions
diff --git a/sql/events.cc b/sql/events.cc index 15d398ed5f0..ad98e257f79 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -68,7 +68,7 @@ Event_queue *Events::event_queue; Event_scheduler *Events::scheduler; Event_db_repository *Events::db_repository; uint Events::opt_event_scheduler= Events::EVENTS_OFF; -pthread_mutex_t Events::LOCK_event_metadata; +mysql_mutex_t Events::LOCK_event_metadata; bool Events::check_system_tables_error= FALSE; @@ -319,8 +319,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, /* At create, one of them must be set */ DBUG_ASSERT(parse_data->expression || parse_data->execute_at); - if (check_access(thd, EVENT_ACL, parse_data->dbname.str, 0, 0, 0, - is_schema_db(parse_data->dbname.str))) + if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); if (check_db_dir_existence(parse_data->dbname.str)) @@ -338,7 +337,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, if (thd->is_current_stmt_binlog_format_row()) thd->clear_current_stmt_binlog_format_row(); - pthread_mutex_lock(&LOCK_event_metadata); + mysql_mutex_lock(&LOCK_event_metadata); /* On error conditions my_error() is called so no need to handle here */ if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists))) @@ -383,7 +382,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length()); } } - pthread_mutex_unlock(&LOCK_event_metadata); + mysql_mutex_unlock(&LOCK_event_metadata); DBUG_RETURN(ret); } @@ -430,8 +429,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, if (parse_data->check_parse_data(thd) || parse_data->do_not_create) DBUG_RETURN(TRUE); - if (check_access(thd, EVENT_ACL, parse_data->dbname.str, 0, 0, 0, - is_schema_db(parse_data->dbname.str))) + if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); if (new_dbname) /* It's a rename */ @@ -452,8 +450,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, to tell the user that a database doesn't exist if they can not access it. */ - if (check_access(thd, EVENT_ACL, new_dbname->str, 0, 0, 0, - is_schema_db(new_dbname->str))) + if (check_access(thd, EVENT_ACL, new_dbname->str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); /* Check that the target database exists */ @@ -471,7 +468,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, if (thd->is_current_stmt_binlog_format_row()) thd->clear_current_stmt_binlog_format_row(); - pthread_mutex_lock(&LOCK_event_metadata); + mysql_mutex_lock(&LOCK_event_metadata); /* On error conditions my_error() is called so no need to handle here */ if (!(ret= db_repository->update_event(thd, parse_data, @@ -504,7 +501,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, ret= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); } } - pthread_mutex_unlock(&LOCK_event_metadata); + mysql_mutex_unlock(&LOCK_event_metadata); DBUG_RETURN(ret); } @@ -557,8 +554,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) if (check_if_system_tables_error()) DBUG_RETURN(TRUE); - if (check_access(thd, EVENT_ACL, dbname.str, 0, 0, 0, - is_schema_db(dbname.str))) + if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); /* @@ -568,7 +564,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) if (thd->is_current_stmt_binlog_format_row()) thd->clear_current_stmt_binlog_format_row(); - pthread_mutex_lock(&LOCK_event_metadata); + mysql_mutex_lock(&LOCK_event_metadata); /* On error conditions my_error() is called so no need to handle here */ if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists))) { @@ -578,7 +574,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) DBUG_ASSERT(thd->query() && thd->query_length()); ret= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); } - pthread_mutex_unlock(&LOCK_event_metadata); + mysql_mutex_unlock(&LOCK_event_metadata); DBUG_RETURN(ret); } @@ -607,11 +603,11 @@ Events::drop_schema_events(THD *thd, char *db) are damaged, as intended. */ - pthread_mutex_lock(&LOCK_event_metadata); + mysql_mutex_lock(&LOCK_event_metadata); if (event_queue) event_queue->drop_schema_events(thd, db_lex); db_repository->drop_schema_events(thd, db_lex); - pthread_mutex_unlock(&LOCK_event_metadata); + mysql_mutex_unlock(&LOCK_event_metadata); DBUG_VOID_RETURN; } @@ -714,8 +710,7 @@ Events::show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name) if (check_if_system_tables_error()) DBUG_RETURN(TRUE); - if (check_access(thd, EVENT_ACL, dbname.str, 0, 0, 0, - is_schema_db(dbname.str))) + if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); /* @@ -773,8 +768,9 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */) if (thd->lex->sql_command == SQLCOM_SHOW_EVENTS) { DBUG_ASSERT(thd->lex->select_lex.db); - if (!is_schema_db(thd->lex->select_lex.db) && // There is no events in I_S - check_access(thd, EVENT_ACL, thd->lex->select_lex.db, 0, 0, 0, 0)) + if (!is_infoschema_db(thd->lex->select_lex.db) && // There is no events in I_S + check_access(thd, EVENT_ACL, thd->lex->select_lex.db, + NULL, NULL, 0, 0)) DBUG_RETURN(1); db= thd->lex->select_lex.db; } @@ -934,6 +930,51 @@ Events::deinit() DBUG_VOID_RETURN; } +#ifdef HAVE_PSI_INTERFACE +PSI_mutex_key key_LOCK_event_metadata, key_LOCK_event_queue, + key_event_scheduler_LOCK_scheduler_state; + +static PSI_mutex_info all_events_mutexes[]= +{ + { &key_LOCK_event_metadata, "LOCK_event_metadata", PSI_FLAG_GLOBAL}, + { &key_LOCK_event_queue, "LOCK_event_queue", PSI_FLAG_GLOBAL}, + { &key_event_scheduler_LOCK_scheduler_state, "Event_scheduler::LOCK_scheduler_state", PSI_FLAG_GLOBAL} +}; + +PSI_cond_key key_event_scheduler_COND_state, key_COND_queue_state; + +static PSI_cond_info all_events_conds[]= +{ + { &key_event_scheduler_COND_state, "Event_scheduler::COND_state", PSI_FLAG_GLOBAL}, + { &key_COND_queue_state, "COND_queue_state", PSI_FLAG_GLOBAL}, +}; + +PSI_thread_key key_thread_event_scheduler, key_thread_event_worker; + +static PSI_thread_info all_events_threads[]= +{ + { &key_thread_event_scheduler, "event_scheduler", PSI_FLAG_GLOBAL}, + { &key_thread_event_worker, "event_worker", 0} +}; + +static void init_events_psi_keys(void) +{ + const char* category= "sql"; + int count; + + if (PSI_server == NULL) + return; + + count= array_elements(all_events_mutexes); + PSI_server->register_mutex(category, all_events_mutexes, count); + + count= array_elements(all_events_conds); + PSI_server->register_cond(category, all_events_conds, count); + + count= array_elements(all_events_threads); + PSI_server->register_thread(category, all_events_threads, count); +} +#endif /* HAVE_PSI_INTERFACE */ /** Inits Events mutexes @@ -946,7 +987,12 @@ Events::deinit() void Events::init_mutexes() { - pthread_mutex_init(&LOCK_event_metadata, MY_MUTEX_INIT_FAST); +#ifdef HAVE_PSI_INTERFACE + init_events_psi_keys(); +#endif + + mysql_mutex_init(key_LOCK_event_metadata, + &LOCK_event_metadata, MY_MUTEX_INIT_FAST); } @@ -960,7 +1006,7 @@ Events::init_mutexes() void Events::destroy_mutexes() { - pthread_mutex_destroy(&LOCK_event_metadata); + mysql_mutex_destroy(&LOCK_event_metadata); } @@ -982,7 +1028,7 @@ Events::dump_internal_status() puts("LLA = Last Locked At LUA = Last Unlocked At"); puts("WOC = Waiting On Condition DL = Data Locked"); - pthread_mutex_lock(&LOCK_event_metadata); + mysql_mutex_lock(&LOCK_event_metadata); if (opt_event_scheduler == EVENTS_DISABLED) puts("The Event Scheduler is disabled"); else @@ -991,7 +1037,7 @@ Events::dump_internal_status() event_queue->dump_internal_status(); } - pthread_mutex_unlock(&LOCK_event_metadata); + mysql_mutex_unlock(&LOCK_event_metadata); DBUG_VOID_RETURN; } |