summaryrefslogtreecommitdiff
path: root/sql/event_timed.cc
diff options
context:
space:
mode:
authorunknown <andrey@lmy004.>2005-12-20 14:21:02 +0200
committerunknown <andrey@lmy004.>2005-12-20 14:21:02 +0200
commit9b323387b817351caadcdb57b880242081c01abe (patch)
tree1a612497071763ab4b3604da0580a5531f863089 /sql/event_timed.cc
parenta820fa4fb11b8a5b60dbc9b27c18ac9aa973909c (diff)
downloadmariadb-git-9b323387b817351caadcdb57b880242081c01abe.tar.gz
WL #1034 update
- fix one bug found by PeterG, namely bug #51 #there is a major problem currently after removing the specialised DYNAMIC_ARRAY as storage for the events. I have to reintroduce similar storage, this time probably some linked list or maybe some API on top of DYNAMIC_ARRAY. sql/event.cc: close the table sql/event.h: change definition sql/event_executor.cc: don't start the thread in advance sql/event_timed.cc: - don't call evex_drop_event - quote the name during compilation to make create event `the rain in spain goes into the drain` not fail.
Diffstat (limited to 'sql/event_timed.cc')
-rw-r--r--sql/event_timed.cc48
1 files changed, 36 insertions, 12 deletions
diff --git a/sql/event_timed.cc b/sql/event_timed.cc
index 84a3eadef0e..50d171a658d 100644
--- a/sql/event_timed.cc
+++ b/sql/event_timed.cc
@@ -714,10 +714,34 @@ event_timed::mark_last_executed()
}
-bool
+/*
+ Returns :
+ 0 - OK
+ -1 - Cannot open mysql.event
+ -2 - Cannot find the event in mysql.event (already deleted?)
+
+ others - return code from SE in case deletion of the event row
+ failed.
+*/
+
+int
event_timed::drop(THD *thd)
{
- return (bool) evex_drop_event(thd, this, false);
+ TABLE *table;
+ int ret= 0;
+ DBUG_ENTER("event_timed::drop");
+
+ if (evex_open_event_table(thd, TL_WRITE, &table))
+ DBUG_RETURN(-1);
+
+ if (evex_db_find_event_aux(thd, dbname, name, table))
+ DBUG_RETURN(-2);
+
+ if ((ret= table->file->delete_row(table->record[0])))
+ DBUG_RETURN(ret);
+
+ close_thread_tables(thd);
+ DBUG_RETURN(0);
}
@@ -783,11 +807,11 @@ event_timed::get_show_create_event(THD *thd, uint *length)
char *dst, *ret;
uint len, tmp_len;
- len = strlen("CREATE EVENT ") + dbname.length + strlen(".") + name.length +
- strlen(" ON SCHEDULE EVERY 5 MINUTE DO ") + body.length + strlen(";");
+ len = strlen("CREATE EVENT `") + dbname.length + strlen(".") + name.length +
+ strlen("` ON SCHEDULE EVERY 5 MINUTE DO ") + body.length + strlen(";");
ret= dst= (char*) alloc_root(thd->mem_root, len + 1);
- memcpy(dst, "CREATE EVENT ", tmp_len= strlen("CREATE EVENT "));
+ memcpy(dst, "CREATE EVENT `", tmp_len= strlen("CREATE EVENT `"));
dst+= tmp_len;
memcpy(dst, dbname.str, tmp_len=dbname.length);
dst+= tmp_len;
@@ -795,8 +819,8 @@ event_timed::get_show_create_event(THD *thd, uint *length)
dst+= tmp_len;
memcpy(dst, name.str, tmp_len= name.length);
dst+= tmp_len;
- memcpy(dst, " ON SCHEDULE EVERY 5 MINUTE DO ",
- tmp_len= strlen(" ON SCHEDULE EVERY 5 MINUTE DO "));
+ memcpy(dst, "` ON SCHEDULE EVERY 5 MINUTE DO ",
+ tmp_len= strlen("` ON SCHEDULE EVERY 5 MINUTE DO "));
dst+= tmp_len;
memcpy(dst, body.str, tmp_len= body.length);
@@ -834,14 +858,14 @@ event_timed::execute(THD *thd, MEM_ROOT *mem_root)
DBUG_ENTER("event_timed::execute");
- VOID(pthread_mutex_lock(&LOCK_running));
+ VOID(pthread_mutex_lock(&this->LOCK_running));
if (running)
{
- VOID(pthread_mutex_unlock(&LOCK_running));
+ VOID(pthread_mutex_unlock(&this->LOCK_running));
DBUG_RETURN(-100);
}
running= true;
- VOID(pthread_mutex_unlock(&LOCK_running));
+ VOID(pthread_mutex_unlock(&this->LOCK_running));
// TODO Andrey : make this as member variable and delete in destructor
empty_item_list.empty();
@@ -851,9 +875,9 @@ event_timed::execute(THD *thd, MEM_ROOT *mem_root)
ret= sphead->execute_procedure(thd, &empty_item_list);
- VOID(pthread_mutex_lock(&LOCK_running));
+ VOID(pthread_mutex_lock(&this->LOCK_running));
running= false;
- VOID(pthread_mutex_unlock(&LOCK_running));
+ VOID(pthread_mutex_unlock(&this->LOCK_running));
done:
// Don't cache sphead if allocated on another mem_root