diff options
author | unknown <kostja@vajra.(none)> | 2007-04-05 15:49:46 +0400 |
---|---|---|
committer | unknown <kostja@vajra.(none)> | 2007-04-05 15:49:46 +0400 |
commit | a36054f4201568fac1717b451040ffa7925900a2 (patch) | |
tree | a91b4f984fd6317085b8bd7e94cd91134184aab6 /sql/event_queue.cc | |
parent | a0c4e184f80de8db3b9d1340715502454ee09ef6 (diff) | |
parent | fa1d637e896d71932adcd1451c1564f724590189 (diff) | |
download | mariadb-git-a36054f4201568fac1717b451040ffa7925900a2.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into vajra.(none):/opt/local/work/mysql-5.1-c1
mysql-test/r/events_bugs.result:
Auto merged
mysql-test/r/events_scheduling.result:
Auto merged
mysql-test/t/events.test:
Auto merged
mysql-test/t/events_scheduling.test:
Auto merged
sql/event_data_objects.h:
Auto merged
sql/event_db_repository.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/set_var.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/table.h:
Auto merged
sql/share/errmsg.txt:
Auto merged
mysql-test/r/events.result:
e
Use local.
mysql-test/r/events_restart_phase1.result:
Use local
mysql-test/r/events_time_zone.result:
SCCS merged
mysql-test/t/events_restart_phase1.test:
Use local
sql/event_data_objects.cc:
Use local
sql/event_db_repository.cc:
Manual merge.
sql/event_queue.cc:
Manual merge.
sql/events.cc:
Manual merge.
Diffstat (limited to 'sql/event_queue.cc')
-rw-r--r-- | sql/event_queue.cc | 79 |
1 files changed, 37 insertions, 42 deletions
diff --git a/sql/event_queue.cc b/sql/event_queue.cc index f958102e269..9b14d3cda7e 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -72,39 +72,21 @@ event_queue_element_compare_q(void *vptr, byte* a, byte *b) Event_queue::Event_queue() :mutex_last_unlocked_at_line(0), mutex_last_locked_at_line(0), mutex_last_attempted_lock_at_line(0), - mutex_queue_data_locked(FALSE), mutex_queue_data_attempting_lock(FALSE) + mutex_queue_data_locked(FALSE), + mutex_queue_data_attempting_lock(FALSE), + next_activation_at(0) { mutex_last_unlocked_in_func= mutex_last_locked_in_func= mutex_last_attempted_lock_in_func= ""; - next_activation_at= 0; -} - -/* - Inits mutexes. - - SYNOPSIS - Event_queue::init_mutexes() -*/ - -void -Event_queue::init_mutexes() -{ pthread_mutex_init(&LOCK_event_queue, MY_MUTEX_INIT_FAST); pthread_cond_init(&COND_queue_state, NULL); } -/* - Destroys mutexes. - - SYNOPSIS - Event_queue::deinit_mutexes() -*/ - -void -Event_queue::deinit_mutexes() +Event_queue::~Event_queue() { + deinit_queue(); pthread_mutex_destroy(&LOCK_event_queue); pthread_cond_destroy(&COND_queue_state); } @@ -176,34 +158,47 @@ Event_queue::deinit_queue() /** Adds an event to the queue. - SYNOPSIS - Event_queue::create_event() - dbname The schema of the new event - name The name of the new event + Compute the next execution time for an event, and if it is still + active, add it to the queue. Otherwise delete it. + The object is left intact in case of an error. Otherwise + the queue container assumes ownership of it. + + @param[in] thd thread handle + @param[in] new_element a new element to add to the queue + @param[out] created set to TRUE if no error and the element is + added to the queue, FALSE otherwise + + @retval TRUE an error occured. The value of created is undefined, + the element was not deleted. + @retval FALSE success */ -void -Event_queue::create_event(THD *thd, Event_queue_element *new_element) +bool +Event_queue::create_event(THD *thd, Event_queue_element *new_element, + bool *created) { DBUG_ENTER("Event_queue::create_event"); DBUG_PRINT("enter", ("thd: 0x%lx et=%s.%s", (long) thd, new_element->dbname.str, new_element->name.str)); - if ((new_element->status == Event_queue_element::DISABLED) - || (new_element->status == Event_queue_element::SLAVESIDE_DISABLED)) - delete new_element; - else + /* Will do nothing if the event is disabled */ + new_element->compute_next_execution_time(); + if (new_element->status != Event_queue_element::ENABLED) { - new_element->compute_next_execution_time(); - DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element)); - - LOCK_QUEUE_DATA(); - queue_insert_safe(&queue, (byte *) new_element); - dbug_dump_queue(thd->query_start()); - pthread_cond_broadcast(&COND_queue_state); - UNLOCK_QUEUE_DATA(); + delete new_element; + *created= FALSE; + DBUG_RETURN(FALSE); } - DBUG_VOID_RETURN; + + DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element)); + + LOCK_QUEUE_DATA(); + *created= (queue_insert_safe(&queue, (byte *) new_element) == FALSE); + dbug_dump_queue(thd->query_start()); + pthread_cond_broadcast(&COND_queue_state); + UNLOCK_QUEUE_DATA(); + + DBUG_RETURN(!*created); } |