From 99438424ac4654e6ecd357e04263aaabc6391022 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Jun 2006 23:07:11 +0200 Subject: [PATCH 1/4] Reorganize, physically the events code Unify method naming -> create/update/drop_event Move class Event_timed to event_timed.h class Events is in events.h (renamed from event.h) The implementation is in events.cc (renamed from event.h) BitKeeper/deleted/.del-event_executor.cc~f4a4645b973838ab: Delete: sql/event_executor.cc include/my_time.h: add a boundary libmysqld/CMakeLists.txt: event.cc -> events.cc libmysqld/Makefile.am: event.cc -> event.cc sql/CMakeLists.txt: event.cc -> events.cc sql/Makefile.am: event.cc -> events.cc event_priv.h -> events_priv.h sql/event_scheduler.cc: event.h -> events.h add_event -> create_event replace_event -> update_event() event_timed_compare_q is only used in event_scheduler.cc , so moving it from event.cc and making it static sql/event_scheduler.h: add_event -> create_event replace_event -> update_event sql/event_timed.cc: moved extern interval_type_to_name to mysql_priv.h sql/mysql_priv.h: moved my_time_compare to time.cc sql/mysqld.cc: event.h -> events.h sql/sql_db.cc: event.h -> events.h sql/sql_parse.cc: event.h -> events.h class Event_timed moved to event_timed.h sql/sql_show.cc: event.h -> events.h class Event_timed moved to event_timed.h sql/sql_yacc.yy: event.h -> events.h class Event_timed moved to event_timed.h sql/events.cc: add_event -> create_event replace_event -> update_event event_timed_compare_q moved to event_scheduler.cc sql/events.h: class Event_timed moved to event_timed.h sql/events_priv.h: my_time_compare moved to mysql_priv.h event_timed_compare_q is static in event_scheduler.cc sql/time.cc: moved interval_type_to_name from event.cc to here. BitKeeper/etc/ignore: Added libmysqld/events.cc to the ignore list --- .bzrignore | 1 + include/my_time.h | 2 +- libmysqld/CMakeLists.txt | 2 +- libmysqld/Makefile.am | 2 +- sql/CMakeLists.txt | 2 +- sql/Makefile.am | 4 +- sql/event.h | 296 ---------------------------- sql/event_executor.cc | 15 -- sql/event_scheduler.cc | 53 +++-- sql/event_scheduler.h | 11 +- sql/event_timed.cc | 11 +- sql/{event.cc => events.cc} | 99 +--------- sql/events.h | 97 +++++++++ sql/{event_priv.h => events_priv.h} | 9 +- sql/mysql_priv.h | 4 + sql/mysqld.cc | 2 +- sql/sql_db.cc | 2 +- sql/sql_parse.cc | 3 +- sql/sql_show.cc | 3 +- sql/sql_yacc.yy | 2 +- sql/time.cc | 56 ++++++ 21 files changed, 236 insertions(+), 440 deletions(-) delete mode 100644 sql/event.h delete mode 100644 sql/event_executor.cc rename sql/{event.cc => events.cc} (93%) create mode 100644 sql/events.h rename sql/{event_priv.h => events_priv.h} (95%) diff --git a/.bzrignore b/.bzrignore index 57fcbdd8f73..fd3f52b9a57 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1771,3 +1771,4 @@ vio/viotest.cpp zlib/*.ds? zlib/*.vcproj libmysqld/event_scheduler.cc +libmysqld/events.cc diff --git a/include/my_time.h b/include/my_time.h index df500dc501b..3025b98a9c4 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -104,7 +104,7 @@ enum interval_type INTERVAL_YEAR_MONTH, INTERVAL_DAY_HOUR, INTERVAL_DAY_MINUTE, INTERVAL_DAY_SECOND, INTERVAL_HOUR_MINUTE, INTERVAL_HOUR_SECOND, INTERVAL_MINUTE_SECOND, INTERVAL_DAY_MICROSECOND, INTERVAL_HOUR_MICROSECOND, - INTERVAL_MINUTE_MICROSECOND, INTERVAL_SECOND_MICROSECOND + INTERVAL_MINUTE_MICROSECOND, INTERVAL_SECOND_MICROSECOND, INTERVAL_LAST }; C_MODE_END diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index ff8ceda5c5b..69d8b6e0f67 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -29,7 +29,7 @@ ADD_LIBRARY(mysqldemb emb_qcache.cc libmysqld.c lib_sql.cc ../libmysql/libmysql.c ../sql/password.c ../sql-common/client.c ../sql-common/my_time.c ../sql-common/my_user.c ../sql-common/pack.c ../sql/derror.cc ../sql/event_executor.cc - ../sql/event_timed.cc ../sql/event.cc ../sql/discover.cc + ../sql/event_timed.cc ../sql/events.cc ../sql/discover.cc ../sql/field_conv.cc ../sql/field.cc ../sql/filesort.cc ../sql/gstream.cc ../sql/ha_heap.cc ../sql/ha_myisam.cc ../sql/ha_myisammrg.cc ${mysql_se_ha_src} diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index a3af2d43bd5..1e8b84a17d0 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -68,7 +68,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \ spatial.cc gstream.cc sql_help.cc tztime.cc sql_cursor.cc \ sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \ parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \ - event_scheduler.cc event.cc event_timed.cc \ + event_scheduler.cc events.cc event_timed.cc \ rpl_filter.cc sql_partition.cc sql_builtin.cc sql_plugin.cc \ sql_tablespace.cc \ rpl_injector.cc my_user.c partition_info.cc diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 2b44fbdcc79..d80a51bb829 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -52,7 +52,7 @@ ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc sql_update.cc sql_view.cc strfunc.cc table.cc thr_malloc.cc time.cc tztime.cc uniques.cc unireg.cc item_xmlfunc.cc rpl_tblmap.cc sql_binlog.cc event_scheduler.cc event_timed.cc - sql_tablespace.cc event.cc ../sql-common/my_user.c + sql_tablespace.cc events.cc ../sql-common/my_user.c partition_info.cc ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h diff --git a/sql/Makefile.am b/sql/Makefile.am index 7f711a1e212..689c916fbba 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -64,7 +64,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ tztime.h my_decimal.h\ sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \ parse_file.h sql_view.h sql_trigger.h \ - sql_array.h sql_cursor.h event.h event_priv.h \ + sql_array.h sql_cursor.h events.h events_priv.h \ sql_plugin.h authors.h sql_partition.h \ partition_info.h partition_element.h event_scheduler.h \ contributors.h @@ -104,7 +104,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ tztime.cc my_time.c my_user.c my_decimal.cc\ sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \ sp_cache.cc parse_file.cc sql_trigger.cc \ - event_scheduler.cc event.cc event_timed.cc \ + event_scheduler.cc events.cc event_timed.cc \ sql_plugin.cc sql_binlog.cc \ sql_builtin.cc sql_tablespace.cc partition_info.cc diff --git a/sql/event.h b/sql/event.h deleted file mode 100644 index 02c5fa78150..00000000000 --- a/sql/event.h +++ /dev/null @@ -1,296 +0,0 @@ -#ifndef _EVENT_H_ -#define _EVENT_H_ -/* Copyright (C) 2004-2006 MySQL AB - - 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - - - -#define EVEX_OK 0 -#define EVEX_KEY_NOT_FOUND -1 -#define EVEX_OPEN_TABLE_FAILED -2 -#define EVEX_WRITE_ROW_FAILED -3 -#define EVEX_DELETE_ROW_FAILED -4 -#define EVEX_GET_FIELD_FAILED -5 -#define EVEX_PARSE_ERROR -6 -#define EVEX_INTERNAL_ERROR -7 -#define EVEX_NO_DB_ERROR -8 -#define EVEX_COMPILE_ERROR -19 -#define EVEX_GENERAL_ERROR -20 -#define EVEX_BAD_IDENTIFIER -21 -#define EVEX_BODY_TOO_LONG -22 -#define EVEX_BAD_PARAMS -23 -#define EVEX_NOT_RUNNING -24 -#define EVEX_MICROSECOND_UNSUP -25 -#define EVEX_CANT_KILL -26 - -#define EVENT_EXEC_NO_MORE (1L << 0) -#define EVENT_NOT_USED (1L << 1) -#define EVENT_FREE_WHEN_FINISHED (1L << 2) - -class Event_timed; - -class Events -{ -public: - static ulong opt_event_scheduler; - static TYPELIB opt_typelib; - - enum enum_table_field - { - FIELD_DB = 0, - FIELD_NAME, - FIELD_BODY, - FIELD_DEFINER, - FIELD_EXECUTE_AT, - FIELD_INTERVAL_EXPR, - FIELD_TRANSIENT_INTERVAL, - FIELD_CREATED, - FIELD_MODIFIED, - FIELD_LAST_EXECUTED, - FIELD_STARTS, - FIELD_ENDS, - FIELD_STATUS, - FIELD_ON_COMPLETION, - FIELD_SQL_MODE, - FIELD_COMMENT, - FIELD_COUNT /* a cool trick to count the number of fields :) */ - }; - - static int - create_event(THD *thd, Event_timed *et, uint create_options, - uint *rows_affected); - - static int - update_event(THD *thd, Event_timed *et, sp_name *new_name, - uint *rows_affected); - - static int - drop_event(THD *thd, Event_timed *et, bool drop_if_exists, - uint *rows_affected); - - static int - open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table); - - static int - show_create_event(THD *thd, sp_name *spn); - - static int - reconstruct_interval_expression(String *buf, interval_type interval, - longlong expression); - - static int - drop_schema_events(THD *thd, char *db); - - static int - dump_internal_status(THD *thd); - - static int - init(); - - static void - shutdown(); - - static void - init_mutexes(); - - static void - destroy_mutexes(); - - -private: - /* Prevent use of these */ - Events(const Events &); - void operator=(Events &); -}; - - - -class sp_head; - -class Event_timed -{ - Event_timed(const Event_timed &); /* Prevent use of these */ - void operator=(Event_timed &); - my_bool in_spawned_thread; - ulong locked_by_thread_id; - my_bool running; - ulong thread_id; - pthread_mutex_t LOCK_running; - pthread_cond_t COND_finished; - - bool status_changed; - bool last_executed_changed; - -public: - enum enum_status - { - ENABLED = 1, - DISABLED - }; - - enum enum_on_completion - { - ON_COMPLETION_DROP = 1, - ON_COMPLETION_PRESERVE - }; - - TIME last_executed; - - LEX_STRING dbname; - LEX_STRING name; - LEX_STRING body; - - LEX_STRING definer_user; - LEX_STRING definer_host; - LEX_STRING definer;// combination of user and host - - LEX_STRING comment; - TIME starts; - TIME ends; - TIME execute_at; - my_bool starts_null; - my_bool ends_null; - my_bool execute_at_null; - - longlong expression; - interval_type interval; - - ulonglong created; - ulonglong modified; - enum enum_on_completion on_completion; - enum enum_status status; - sp_head *sphead; - ulong sql_mode; - const uchar *body_begin; - - bool dropped; - bool free_sphead_on_delete; - uint flags;//all kind of purposes - - static void *operator new(size_t size) - { - void *p; - DBUG_ENTER("Event_timed::new(size)"); - p= my_malloc(size, MYF(0)); - DBUG_PRINT("info", ("alloc_ptr=0x%lx", p)); - DBUG_RETURN(p); - } - - static void *operator new(size_t size, MEM_ROOT *mem_root) - { return (void*) alloc_root(mem_root, (uint) size); } - - static void operator delete(void *ptr, size_t size) - { - DBUG_ENTER("Event_timed::delete(ptr,size)"); - DBUG_PRINT("enter", ("free_ptr=0x%lx", ptr)); - TRASH(ptr, size); - my_free((gptr) ptr, MYF(0)); - DBUG_VOID_RETURN; - } - - static void operator delete(void *ptr, MEM_ROOT *mem_root) - { - /* - Don't free the memory it will be done by the mem_root but - we need to call the destructor because we free other resources - which are not allocated on the root but on the heap, or we - deinit mutexes. - */ - DBUG_ASSERT(0); - } - - Event_timed(); - - ~Event_timed(); - - void - init(); - - void - deinit_mutexes(); - - int - init_definer(THD *thd); - - int - init_execute_at(THD *thd, Item *expr); - - int - init_interval(THD *thd, Item *expr, interval_type new_interval); - - void - init_name(THD *thd, sp_name *spn); - - int - init_starts(THD *thd, Item *starts); - - int - init_ends(THD *thd, Item *ends); - - void - init_body(THD *thd); - - void - init_comment(THD *thd, LEX_STRING *set_comment); - - int - load_from_row(MEM_ROOT *mem_root, TABLE *table); - - bool - compute_next_execution_time(); - - int - drop(THD *thd); - - void - mark_last_executed(THD *thd); - - bool - update_fields(THD *thd); - - int - get_create_event(THD *thd, String *buf); - - int - execute(THD *thd, MEM_ROOT *mem_root); - - int - compile(THD *thd, MEM_ROOT *mem_root); - - bool - is_running(); - - int - spawn_now(void * (*thread_func)(void*), void *arg); - - bool - spawn_thread_finish(THD *thd); - - void - free_sp(); - - bool - has_equal_db(Event_timed *etn); - - int - kill_thread(THD *thd); - - void - set_thread_id(ulong tid) { thread_id= tid; } -}; - - -#endif /* _EVENT_H_ */ diff --git a/sql/event_executor.cc b/sql/event_executor.cc deleted file mode 100644 index f236fb47771..00000000000 --- a/sql/event_executor.cc +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (C) 2004-2005 MySQL AB - - 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index e360254fdd2..10e641dceed 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -14,8 +14,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "event_priv.h" -#include "event.h" +#include "mysql_priv.h" +#include "events_priv.h" +#include "events.h" +#include "event_timed.h" #include "event_scheduler.h" #include "sp_head.h" @@ -46,8 +48,8 @@ The scheduler only manages execution of the events. Their creation, alteration and deletion is delegated to other routines found in event.cc . These routines interact with the scheduler : - - CREATE EVENT -> Event_scheduler::add_event() - - ALTER EVENT -> Event_scheduler::replace_event() + - CREATE EVENT -> Event_scheduler::create_event() + - ALTER EVENT -> Event_scheduler::update_event() - DROP EVENT -> Event_scheduler::drop_event() There is one mutex in the single Event_scheduler object which controls @@ -298,6 +300,35 @@ public: }; +/* + Compares the execute_at members of 2 Event_timed instances. + Used as callback for the prioritized queue when shifting + elements inside. + + SYNOPSIS + event_timed_compare_q() + + vptr - not used (set it to NULL) + a - first Event_timed object + b - second Event_timed object + + RETURN VALUE + -1 - a->execute_at < b->execute_at + 0 - a->execute_at == b->execute_at + 1 - a->execute_at > b->execute_at + + NOTES + execute_at.second_part is not considered during comparison +*/ + +static int +event_timed_compare_q(void *vptr, byte* a, byte *b) +{ + return my_time_compare(&((Event_timed *)a)->execute_at, + &((Event_timed *)b)->execute_at); +} + + /* Prints the stack of infos, warnings, errors from thd to the console so it can be fetched by the logs-into-tables and @@ -740,10 +771,10 @@ Event_scheduler::destroy() /* - Adds an event to the scheduler queue + Creates an event in the scheduler queue SYNOPSIS - Event_scheduler::add_event() + Event_scheduler::create_event() et The event to add check_existence Whether to check if already loaded. @@ -753,11 +784,11 @@ Event_scheduler::destroy() */ enum Event_scheduler::enum_error_code -Event_scheduler::add_event(THD *thd, Event_timed *et, bool check_existence) +Event_scheduler::create_event(THD *thd, Event_timed *et, bool check_existence) { enum enum_error_code res; Event_timed *et_new; - DBUG_ENTER("Event_scheduler::add_event"); + DBUG_ENTER("Event_scheduler::create_event"); DBUG_PRINT("enter", ("thd=%p et=%p lock=%p",thd,et,&LOCK_scheduler_data)); LOCK_SCHEDULER_DATA(); @@ -859,7 +890,7 @@ Event_scheduler::drop_event(THD *thd, Event_timed *et) /* - Replaces an event in the scheduler queue + Updates an event from the scheduler queue SYNOPSIS Event_scheduler::replace_event() @@ -873,14 +904,14 @@ Event_scheduler::drop_event(THD *thd, Event_timed *et) */ enum Event_scheduler::enum_error_code -Event_scheduler::replace_event(THD *thd, Event_timed *et, LEX_STRING *new_schema, +Event_scheduler::update_event(THD *thd, Event_timed *et, LEX_STRING *new_schema, LEX_STRING *new_name) { enum enum_error_code res; Event_timed *et_old, *et_new= NULL; LEX_STRING old_schema, old_name; - DBUG_ENTER("Event_scheduler::replace_event"); + DBUG_ENTER("Event_scheduler::update_event"); DBUG_PRINT("enter", ("thd=%p et=%p et=[%s.%s] lock=%p", thd, et, et->dbname.str, et->name.str, &LOCK_scheduler_data)); diff --git a/sql/event_scheduler.h b/sql/event_scheduler.h index dffd47539fa..5ae310bab2a 100644 --- a/sql/event_scheduler.h +++ b/sql/event_scheduler.h @@ -16,6 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +class Event_timed; class THD; typedef bool * (*event_timed_identifier_comparator)(Event_timed*, Event_timed*); @@ -26,7 +27,6 @@ events_init(); void events_shutdown(); - class Event_scheduler { public: @@ -66,14 +66,15 @@ public: /* Methods for queue management follow */ enum enum_error_code - add_event(THD *thd, Event_timed *et, bool check_existence); + create_event(THD *thd, Event_timed *et, bool check_existence); + + enum enum_error_code + update_event(THD *thd, Event_timed *et, LEX_STRING *new_schema, + LEX_STRING *new_name); bool drop_event(THD *thd, Event_timed *et); - enum enum_error_code - replace_event(THD *thd, Event_timed *et, LEX_STRING *new_schema, - LEX_STRING *new_name); int drop_schema_events(THD *thd, LEX_STRING *schema); diff --git a/sql/event_timed.cc b/sql/event_timed.cc index d6d6dddf971..4ec875f32a3 100644 --- a/sql/event_timed.cc +++ b/sql/event_timed.cc @@ -15,8 +15,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define MYSQL_LEX 1 -#include "event_priv.h" -#include "event.h" +#include "mysql_priv.h" +#include "events_priv.h" +#include "events.h" +#include "event_timed.h" #include "sp_head.h" @@ -395,6 +397,8 @@ Event_timed::init_interval(THD *thd, Item *expr, interval_type new_interval) break; case INTERVAL_MICROSECOND: DBUG_RETURN(EVEX_MICROSECOND_UNSUP); + case INTERVAL_LAST: + DBUG_ASSERT(0); } if (interval_tmp.neg || expression > EVEX_MAX_INTERVAL_VALUE) DBUG_RETURN(EVEX_BAD_PARAMS); @@ -834,6 +838,8 @@ bool get_next_time(TIME *next, TIME *start, TIME *time_now, TIME *last_exec, */ DBUG_RETURN(1); break; + case INTERVAL_LAST: + DBUG_ASSERT(0); } DBUG_PRINT("info", ("seconds=%ld months=%ld", seconds, months)); if (seconds) @@ -1279,7 +1285,6 @@ done: DBUG_RETURN(ret); } -extern LEX_STRING interval_type_to_name[]; /* Get SHOW CREATE EVENT as string diff --git a/sql/event.cc b/sql/events.cc similarity index 93% rename from sql/event.cc rename to sql/events.cc index 5273394640c..8398bb422f4 100644 --- a/sql/event.cc +++ b/sql/events.cc @@ -14,8 +14,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "event_priv.h" -#include "event.h" +#include "mysql_priv.h" +#include "events_priv.h" +#include "events.h" +#include "event_timed.h" #include "event_scheduler.h" #include "sp.h" #include "sp_head.h" @@ -160,35 +162,11 @@ TABLE_FIELD_W_TYPE event_table_fields[Events::FIELD_COUNT] = { }; -LEX_STRING interval_type_to_name[] = { - {(char *) STRING_WITH_LEN("YEAR")}, - {(char *) STRING_WITH_LEN("QUARTER")}, - {(char *) STRING_WITH_LEN("MONTH")}, - {(char *) STRING_WITH_LEN("DAY")}, - {(char *) STRING_WITH_LEN("HOUR")}, - {(char *) STRING_WITH_LEN("MINUTE")}, - {(char *) STRING_WITH_LEN("WEEK")}, - {(char *) STRING_WITH_LEN("SECOND")}, - {(char *) STRING_WITH_LEN("MICROSECOND")}, - {(char *) STRING_WITH_LEN("YEAR_MONTH")}, - {(char *) STRING_WITH_LEN("DAY_HOUR")}, - {(char *) STRING_WITH_LEN("DAY_MINUTE")}, - {(char *) STRING_WITH_LEN("DAY_SECOND")}, - {(char *) STRING_WITH_LEN("HOUR_MINUTE")}, - {(char *) STRING_WITH_LEN("HOUR_SECOND")}, - {(char *) STRING_WITH_LEN("MINUTE_SECOND")}, - {(char *) STRING_WITH_LEN("DAY_MICROSECOND")}, - {(char *) STRING_WITH_LEN("HOUR_MICROSECOND")}, - {(char *) STRING_WITH_LEN("MINUTE_MICROSECOND")}, - {(char *) STRING_WITH_LEN("SECOND_MICROSECOND")} -}; - - /* Compares 2 LEX strings regarding case. SYNOPSIS - my_time_compare() + sortcmp_lex_string() s - first LEX_STRING t - second LEX_STRING @@ -210,68 +188,6 @@ int sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs) } -/* - Compares 2 TIME structures - - SYNOPSIS - my_time_compare() - - a - first TIME - b - second time - - RETURN VALUE - -1 - a < b - 0 - a == b - 1 - a > b - - NOTES - TIME.second_part is not considered during comparison -*/ - -int -my_time_compare(TIME *a, TIME *b) -{ - my_ulonglong a_t= TIME_to_ulonglong_datetime(a); - my_ulonglong b_t= TIME_to_ulonglong_datetime(b); - - if (a_t > b_t) - return 1; - else if (a_t < b_t) - return -1; - - return 0; -} - - -/* - Compares the execute_at members of 2 Event_timed instances. - Used as callback for the prioritized queue when shifting - elements inside. - - SYNOPSIS - event_timed_compare() - - vptr - not used (set it to NULL) - a - first Event_timed object - b - second Event_timed object - - RETURNS: - -1 - a->execute_at < b->execute_at - 0 - a->execute_at == b->execute_at - 1 - a->execute_at > b->execute_at - - Notes - execute_at.second_part is not considered during comparison -*/ - -int -event_timed_compare_q(void *vptr, byte* a, byte *b) -{ - return my_time_compare(&((Event_timed *)a)->execute_at, - &((Event_timed *)b)->execute_at); -} - - /* Reconstructs interval expression from interval type and expression value that is in form of a value of the smalles entity: @@ -999,7 +915,8 @@ Events::create_event(THD *thd, Event_timed *et, uint create_options, rows_affected))) { Event_scheduler *scheduler= Event_scheduler::get_instance(); - if (scheduler->initialized() && (ret= scheduler->add_event(thd, et, true))) + if (scheduler->initialized() && + (ret= scheduler->create_event(thd, et, true))) my_error(ER_EVENT_MODIFY_QUEUE_ERROR, MYF(0), ret); } /* No need to close the table, it will be closed in sql_parse::do_command */ @@ -1044,7 +961,7 @@ Events::update_event(THD *thd, Event_timed *et, sp_name *new_name, { Event_scheduler *scheduler= Event_scheduler::get_instance(); if (scheduler->initialized() && - (ret= scheduler->replace_event(thd, et, + (ret= scheduler->update_event(thd, et, new_name? &new_name->m_db: NULL, new_name? &new_name->m_name: NULL))) my_error(ER_EVENT_MODIFY_QUEUE_ERROR, MYF(0), ret); diff --git a/sql/events.h b/sql/events.h new file mode 100644 index 00000000000..66cce6e7777 --- /dev/null +++ b/sql/events.h @@ -0,0 +1,97 @@ +#ifndef _EVENT_H_ +#define _EVENT_H_ +/* Copyright (C) 2004-2006 MySQL AB + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +class Event_timed; + +class Events +{ +public: + static ulong opt_event_scheduler; + static TYPELIB opt_typelib; + + enum enum_table_field + { + FIELD_DB = 0, + FIELD_NAME, + FIELD_BODY, + FIELD_DEFINER, + FIELD_EXECUTE_AT, + FIELD_INTERVAL_EXPR, + FIELD_TRANSIENT_INTERVAL, + FIELD_CREATED, + FIELD_MODIFIED, + FIELD_LAST_EXECUTED, + FIELD_STARTS, + FIELD_ENDS, + FIELD_STATUS, + FIELD_ON_COMPLETION, + FIELD_SQL_MODE, + FIELD_COMMENT, + FIELD_COUNT /* a cool trick to count the number of fields :) */ + }; + + static int + create_event(THD *thd, Event_timed *et, uint create_options, + uint *rows_affected); + + static int + update_event(THD *thd, Event_timed *et, sp_name *new_name, + uint *rows_affected); + + static int + drop_event(THD *thd, Event_timed *et, bool drop_if_exists, + uint *rows_affected); + + static int + open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table); + + static int + show_create_event(THD *thd, sp_name *spn); + + static int + reconstruct_interval_expression(String *buf, interval_type interval, + longlong expression); + + static int + drop_schema_events(THD *thd, char *db); + + static int + dump_internal_status(THD *thd); + + static int + init(); + + static void + shutdown(); + + static void + init_mutexes(); + + static void + destroy_mutexes(); + + +private: + /* Prevent use of these */ + Events(const Events &); + void operator=(Events &); +}; + + +#endif /* _EVENT_H_ */ diff --git a/sql/event_priv.h b/sql/events_priv.h similarity index 95% rename from sql/event_priv.h rename to sql/events_priv.h index 43ef30a659f..ed02cb7055b 100644 --- a/sql/event_priv.h +++ b/sql/events_priv.h @@ -16,9 +16,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mysql_priv.h" - - #define EVENT_EXEC_STARTED 0 #define EVENT_EXEC_ALREADY_EXEC 1 #define EVENT_EXEC_CANT_FORK 2 @@ -27,17 +24,13 @@ #define EVEX_NAME_FIELD_LEN 64 #define EVEX_MAX_INTERVAL_VALUE 2147483647L -int -my_time_compare(TIME *a, TIME *b); +class Event_timed; int evex_db_find_event_by_name(THD *thd, const LEX_STRING dbname, const LEX_STRING ev_name, TABLE *table); -int -event_timed_compare_q(void *vptr, byte* a, byte *b); - int db_drop_event(THD *thd, Event_timed *et, bool drop_if_exists, uint *rows_affected); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 0fd0c5597d1..7ed361d52b7 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1739,6 +1739,8 @@ bool date_add_interval(TIME *ltime, interval_type int_type, INTERVAL interval); bool calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, longlong *seconds_out, long *microseconds_out); +extern LEX_STRING interval_type_to_name[]; + extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type, const char *format_str, uint format_length); @@ -1754,6 +1756,7 @@ void make_date(const DATE_TIME_FORMAT *format, const TIME *l_time, String *str); void make_time(const DATE_TIME_FORMAT *format, const TIME *l_time, String *str); +int my_time_compare(TIME *a, TIME *b); int test_if_number(char *str,int *res,bool allow_wildcards); void change_byte(byte *,uint,char,char); @@ -1770,6 +1773,7 @@ void filesort_free_buffers(TABLE *table); void change_double_for_sort(double nr,byte *to); double my_double_round(double value, int dec, bool truncate); int get_quick_record(SQL_SELECT *select); + int calc_weekday(long daynr,bool sunday_first_day_of_week); uint calc_week(TIME *l_time, uint week_behaviour, uint *year); void find_date(char *pos,uint *vek,uint flag); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 42787d67351..52aa8560e99 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -24,7 +24,7 @@ #include "stacktrace.h" #include "mysqld_suffix.h" #include "mysys_err.h" -#include "event.h" +#include "events.h" #include "ha_myisam.h" diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 6d5362c2554..273ed3a5115 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -20,7 +20,7 @@ #include "mysql_priv.h" #include #include "sp.h" -#include "event.h" +#include "events.h" #include #include #ifdef __WIN__ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3206cfa2d52..491ccece03d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -26,7 +26,8 @@ #include "sp_head.h" #include "sp.h" #include "sp_cache.h" -#include "event.h" +#include "events.h" +#include "event_timed.h" #ifdef HAVE_OPENSSL /* diff --git a/sql/sql_show.cc b/sql/sql_show.cc index bdf0724ee96..a22c36fffa3 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -26,7 +26,8 @@ #include "sql_trigger.h" #include "authors.h" #include "contributors.h" -#include "event.h" +#include "events.h" +#include "event_timed.h" #include #ifdef WITH_PARTITION_STORAGE_ENGINE diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 82dcc758ff0..b4fe53749cc 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -38,7 +38,7 @@ #include "sp_pcontext.h" #include "sp_rcontext.h" #include "sp.h" -#include "event.h" +#include "event_timed.h" #include #include diff --git a/sql/time.cc b/sql/time.cc index 3c654de23bb..5b12aacf84a 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -24,6 +24,30 @@ /* Some functions to calculate dates */ #ifndef TESTTIME + +LEX_STRING interval_type_to_name[INTERVAL_LAST] = { + {(char *) STRING_WITH_LEN("YEAR")}, + {(char *) STRING_WITH_LEN("QUARTER")}, + {(char *) STRING_WITH_LEN("MONTH")}, + {(char *) STRING_WITH_LEN("DAY")}, + {(char *) STRING_WITH_LEN("HOUR")}, + {(char *) STRING_WITH_LEN("MINUTE")}, + {(char *) STRING_WITH_LEN("WEEK")}, + {(char *) STRING_WITH_LEN("SECOND")}, + {(char *) STRING_WITH_LEN("MICROSECOND")}, + {(char *) STRING_WITH_LEN("YEAR_MONTH")}, + {(char *) STRING_WITH_LEN("DAY_HOUR")}, + {(char *) STRING_WITH_LEN("DAY_MINUTE")}, + {(char *) STRING_WITH_LEN("DAY_SECOND")}, + {(char *) STRING_WITH_LEN("HOUR_MINUTE")}, + {(char *) STRING_WITH_LEN("HOUR_SECOND")}, + {(char *) STRING_WITH_LEN("MINUTE_SECOND")}, + {(char *) STRING_WITH_LEN("DAY_MICROSECOND")}, + {(char *) STRING_WITH_LEN("HOUR_MICROSECOND")}, + {(char *) STRING_WITH_LEN("MINUTE_MICROSECOND")}, + {(char *) STRING_WITH_LEN("SECOND_MICROSECOND")} +}; + /* Calc weekday from daynr */ /* Returns 0 for monday, 1 for tuesday .... */ @@ -909,4 +933,36 @@ calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, longlong *seconds_out, } +/* + Compares 2 TIME structures + + SYNOPSIS + my_time_compare() + + a - first TIME + b - second time + + RETURN VALUE + -1 - a < b + 0 - a == b + 1 - a > b + + NOTES + TIME.second_part is not considered during comparison +*/ + +int +my_time_compare(TIME *a, TIME *b) +{ + my_ulonglong a_t= TIME_to_ulonglong_datetime(a); + my_ulonglong b_t= TIME_to_ulonglong_datetime(b); + + if (a_t > b_t) + return 1; + else if (a_t < b_t) + return -1; + + return 0; +} + #endif From 7daf362e2436cc3a300c47d33fcb43e00774f3a8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Jun 2006 17:05:41 +0200 Subject: [PATCH 2/4] forgot to event_timed.h STRING_WITH_LEN -> C_STRING_WITH_LEN sql/time.cc: use C_STRING_WITH_LEN --- sql/event_timed.h | 217 ++++++++++++++++++++++++++++++++++++++++++++++ sql/time.cc | 42 ++++----- 2 files changed, 238 insertions(+), 21 deletions(-) create mode 100644 sql/event_timed.h diff --git a/sql/event_timed.h b/sql/event_timed.h new file mode 100644 index 00000000000..0652cece361 --- /dev/null +++ b/sql/event_timed.h @@ -0,0 +1,217 @@ +#ifndef _EVENT_TIMED_H_ +#define _EVENT_TIMED_H_ +/* Copyright (C) 2004-2006 MySQL AB + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +#define EVEX_OK 0 +#define EVEX_KEY_NOT_FOUND -1 +#define EVEX_OPEN_TABLE_FAILED -2 +#define EVEX_WRITE_ROW_FAILED -3 +#define EVEX_DELETE_ROW_FAILED -4 +#define EVEX_GET_FIELD_FAILED -5 +#define EVEX_PARSE_ERROR -6 +#define EVEX_INTERNAL_ERROR -7 +#define EVEX_NO_DB_ERROR -8 +#define EVEX_COMPILE_ERROR -19 +#define EVEX_GENERAL_ERROR -20 +#define EVEX_BAD_IDENTIFIER -21 +#define EVEX_BODY_TOO_LONG -22 +#define EVEX_BAD_PARAMS -23 +#define EVEX_NOT_RUNNING -24 +#define EVEX_MICROSECOND_UNSUP -25 +#define EVEX_CANT_KILL -26 + +#define EVENT_EXEC_NO_MORE (1L << 0) +#define EVENT_NOT_USED (1L << 1) +#define EVENT_FREE_WHEN_FINISHED (1L << 2) + + +class sp_head; + +class Event_timed +{ + Event_timed(const Event_timed &); /* Prevent use of these */ + void operator=(Event_timed &); + my_bool in_spawned_thread; + ulong locked_by_thread_id; + my_bool running; + ulong thread_id; + pthread_mutex_t LOCK_running; + pthread_cond_t COND_finished; + + bool status_changed; + bool last_executed_changed; + +public: + enum enum_status + { + ENABLED = 1, + DISABLED + }; + + enum enum_on_completion + { + ON_COMPLETION_DROP = 1, + ON_COMPLETION_PRESERVE + }; + + TIME last_executed; + + LEX_STRING dbname; + LEX_STRING name; + LEX_STRING body; + + LEX_STRING definer_user; + LEX_STRING definer_host; + LEX_STRING definer;// combination of user and host + + LEX_STRING comment; + TIME starts; + TIME ends; + TIME execute_at; + my_bool starts_null; + my_bool ends_null; + my_bool execute_at_null; + + longlong expression; + interval_type interval; + + ulonglong created; + ulonglong modified; + enum enum_on_completion on_completion; + enum enum_status status; + sp_head *sphead; + ulong sql_mode; + const uchar *body_begin; + + bool dropped; + bool free_sphead_on_delete; + uint flags;//all kind of purposes + + static void *operator new(size_t size) + { + void *p; + DBUG_ENTER("Event_timed::new(size)"); + p= my_malloc(size, MYF(0)); + DBUG_PRINT("info", ("alloc_ptr=0x%lx", p)); + DBUG_RETURN(p); + } + + static void *operator new(size_t size, MEM_ROOT *mem_root) + { return (void*) alloc_root(mem_root, (uint) size); } + + static void operator delete(void *ptr, size_t size) + { + DBUG_ENTER("Event_timed::delete(ptr,size)"); + DBUG_PRINT("enter", ("free_ptr=0x%lx", ptr)); + TRASH(ptr, size); + my_free((gptr) ptr, MYF(0)); + DBUG_VOID_RETURN; + } + + static void operator delete(void *ptr, MEM_ROOT *mem_root) + { + /* + Don't free the memory it will be done by the mem_root but + we need to call the destructor because we free other resources + which are not allocated on the root but on the heap, or we + deinit mutexes. + */ + DBUG_ASSERT(0); + } + + Event_timed(); + + ~Event_timed(); + + void + init(); + + void + deinit_mutexes(); + + int + init_definer(THD *thd); + + int + init_execute_at(THD *thd, Item *expr); + + int + init_interval(THD *thd, Item *expr, interval_type new_interval); + + void + init_name(THD *thd, sp_name *spn); + + int + init_starts(THD *thd, Item *starts); + + int + init_ends(THD *thd, Item *ends); + + void + init_body(THD *thd); + + void + init_comment(THD *thd, LEX_STRING *set_comment); + + int + load_from_row(MEM_ROOT *mem_root, TABLE *table); + + bool + compute_next_execution_time(); + + int + drop(THD *thd); + + void + mark_last_executed(THD *thd); + + bool + update_fields(THD *thd); + + int + get_create_event(THD *thd, String *buf); + + int + execute(THD *thd, MEM_ROOT *mem_root); + + int + compile(THD *thd, MEM_ROOT *mem_root); + + bool + is_running(); + + int + spawn_now(void * (*thread_func)(void*), void *arg); + + bool + spawn_thread_finish(THD *thd); + + void + free_sp(); + + bool + has_equal_db(Event_timed *etn); + + int + kill_thread(THD *thd); + + void + set_thread_id(ulong tid) { thread_id= tid; } +}; + +#endif /* _EVENT_H_ */ diff --git a/sql/time.cc b/sql/time.cc index 5b12aacf84a..b3164818f75 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -26,26 +26,26 @@ #ifndef TESTTIME LEX_STRING interval_type_to_name[INTERVAL_LAST] = { - {(char *) STRING_WITH_LEN("YEAR")}, - {(char *) STRING_WITH_LEN("QUARTER")}, - {(char *) STRING_WITH_LEN("MONTH")}, - {(char *) STRING_WITH_LEN("DAY")}, - {(char *) STRING_WITH_LEN("HOUR")}, - {(char *) STRING_WITH_LEN("MINUTE")}, - {(char *) STRING_WITH_LEN("WEEK")}, - {(char *) STRING_WITH_LEN("SECOND")}, - {(char *) STRING_WITH_LEN("MICROSECOND")}, - {(char *) STRING_WITH_LEN("YEAR_MONTH")}, - {(char *) STRING_WITH_LEN("DAY_HOUR")}, - {(char *) STRING_WITH_LEN("DAY_MINUTE")}, - {(char *) STRING_WITH_LEN("DAY_SECOND")}, - {(char *) STRING_WITH_LEN("HOUR_MINUTE")}, - {(char *) STRING_WITH_LEN("HOUR_SECOND")}, - {(char *) STRING_WITH_LEN("MINUTE_SECOND")}, - {(char *) STRING_WITH_LEN("DAY_MICROSECOND")}, - {(char *) STRING_WITH_LEN("HOUR_MICROSECOND")}, - {(char *) STRING_WITH_LEN("MINUTE_MICROSECOND")}, - {(char *) STRING_WITH_LEN("SECOND_MICROSECOND")} + { C_STRING_WITH_LEN("YEAR")}, + { C_STRING_WITH_LEN("QUARTER")}, + { C_STRING_WITH_LEN("MONTH")}, + { C_STRING_WITH_LEN("DAY")}, + { C_STRING_WITH_LEN("HOUR")}, + { C_STRING_WITH_LEN("MINUTE")}, + { C_STRING_WITH_LEN("WEEK")}, + { C_STRING_WITH_LEN("SECOND")}, + { C_STRING_WITH_LEN("MICROSECOND")}, + { C_STRING_WITH_LEN("YEAR_MONTH")}, + { C_STRING_WITH_LEN("DAY_HOUR")}, + { C_STRING_WITH_LEN("DAY_MINUTE")}, + { C_STRING_WITH_LEN("DAY_SECOND")}, + { C_STRING_WITH_LEN("HOUR_MINUTE")}, + { C_STRING_WITH_LEN("HOUR_SECOND")}, + { C_STRING_WITH_LEN("MINUTE_SECOND")}, + { C_STRING_WITH_LEN("DAY_MICROSECOND")}, + { C_STRING_WITH_LEN("HOUR_MICROSECOND")}, + { C_STRING_WITH_LEN("MINUTE_MICROSECOND")}, + { C_STRING_WITH_LEN("SECOND_MICROSECOND")} }; /* Calc weekday from daynr */ @@ -939,7 +939,7 @@ calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, longlong *seconds_out, SYNOPSIS my_time_compare() - a - first TIME + a - first time b - second time RETURN VALUE From 7d3f1e7a239b52c71db58c7e460e8d3b56ca7d2a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Jun 2006 08:58:56 +0200 Subject: [PATCH 3/4] add event_timed.h also to the distribution --- sql/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/Makefile.am b/sql/Makefile.am index e3b2447341d..387f18c2ae9 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -65,7 +65,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \ parse_file.h sql_view.h sql_trigger.h \ sql_array.h sql_cursor.h events.h events_priv.h \ - sql_plugin.h authors.h sql_partition.h \ + sql_plugin.h authors.h sql_partition.h event_timed.h \ partition_info.h partition_element.h event_scheduler.h \ contributors.h mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ From 0cb8f6958cfcd386caca79839369d8c8df115f7c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Jun 2006 16:02:51 +0400 Subject: [PATCH 4/4] Fix for BUG#20294: Instance manager test im_instance_conf fails randomly. The problem is that the test was affected by other running test-suites on the same box. The fix affects the test only, no code touched. mysql-test/r/im_instance_conf.result: Updated result file. mysql-test/t/disabled.def: Enable IM tests. mysql-test/t/im_instance_conf.imtest: Modify the test so that it does not depend on running test-suites on the same box. --- mysql-test/r/im_instance_conf.result | 83 +++++++++++++++++++--------- mysql-test/t/disabled.def | 6 +- mysql-test/t/im_instance_conf.imtest | 46 ++++++++++++--- 3 files changed, 96 insertions(+), 39 deletions(-) diff --git a/mysql-test/r/im_instance_conf.result b/mysql-test/r/im_instance_conf.result index efda9439f38..f68fcca25a3 100644 --- a/mysql-test/r/im_instance_conf.result +++ b/mysql-test/r/im_instance_conf.result @@ -13,7 +13,9 @@ Variable_name Value server_id 1 ---> connection: default -CREATE INSTANCE mysqld3; +CREATE INSTANCE mysqld3 +server_id = 3, +socket = "$MYSQL_TMP_DIR/mysqld_3.sock"; SHOW INSTANCES; instance_name state mysqld3 offline @@ -22,6 +24,7 @@ mysqld1 online -------------------------------------------------------------------- server_id = 1 server_id = 2 +server_id=3 -------------------------------------------------------------------- CREATE INSTANCE mysqld1; ERROR HY000: Instance already exists @@ -32,7 +35,10 @@ ERROR HY000: Instance already exists -------------------------------------------------------------------- nonguarded -------------------------------------------------------------------- -CREATE INSTANCE mysqld4 nonguarded; +CREATE INSTANCE mysqld4 +nonguarded, +server_id = 4, +socket = "$MYSQL_TMP_DIR/mysqld_4.sock"; SHOW INSTANCES; instance_name state mysqld3 offline @@ -46,7 +52,11 @@ nonguarded -------------------------------------------------------------------- -------------------------------------------------------------------- -------------------------------------------------------------------- -CREATE INSTANCE mysqld5 test-A = 000, test-B = test; +CREATE INSTANCE mysqld5 +test-A = 000, +test-B = test, +server_id = 5, +socket = "$MYSQL_TMP_DIR/mysqld_5.sock"; SHOW INSTANCES; instance_name state mysqld1 online @@ -61,7 +71,11 @@ test-B=test -------------------------------------------------------------------- -------------------------------------------------------------------- -------------------------------------------------------------------- -CREATE INSTANCE mysqld6 test-C1 = 10 , test-C2 = 02 ; +CREATE INSTANCE mysqld6 +test-C1 = 10 , +test-C2 = 02 , +server_id = 6, +socket = "$MYSQL_TMP_DIR/mysqld_6.sock"; SHOW INSTANCES; instance_name state mysqld1 online @@ -116,7 +130,11 @@ mysqld4 offline -------------------------------------------------------------------- -------------------------------------------------------------------- -------------------------------------------------------------------- -CREATE INSTANCE mysqld9 test-1=" hello world ", test-2=' '; +CREATE INSTANCE mysqld9 +test-1=" hello world ", +test-2=' ', +server_id = 9, +socket = "$MYSQL_TMP_DIR/mysqld_9.sock"; SHOW INSTANCES; instance_name state mysqld1 online @@ -126,56 +144,67 @@ mysqld6 offline mysqld3 offline mysqld4 offline mysqld9 offline -CREATE INSTANCE mysqld9a test-3='\b\babc\sdef'; +CREATE INSTANCE mysqld10 +test-3='\b\babc\sdef', +server_id = 10, +socket = "$MYSQL_TMP_DIR/mysqld_10.sock"; SHOW INSTANCES; instance_name state mysqld1 online -mysqld9a offline +mysqld9 offline mysqld5 offline mysqld6 offline mysqld3 offline mysqld4 offline -mysqld9 offline +mysqld10 offline mysqld2 offline -CREATE INSTANCE mysqld9b test-4='abc\tdef', test-5='abc\ndef'; +CREATE INSTANCE mysqld11 +test-4='abc\tdef', +test-5='abc\ndef', +server_id = 11, +socket = "$MYSQL_TMP_DIR/mysqld_11.sock"; SHOW INSTANCES; instance_name state -mysqld9b offline -mysqld9a offline +mysqld1 online +mysqld11 offline mysqld5 offline mysqld6 offline mysqld3 offline mysqld4 offline -mysqld9 offline +mysqld10 offline mysqld2 offline -mysqld1 online -CREATE INSTANCE mysqld9c test-6="abc\rdef", test-7="abc\\def"; +mysqld9 offline +CREATE INSTANCE mysqld12 +test-6="abc\rdef", +test-7="abc\\def", +server_id = 12, +socket = "$MYSQL_TMP_DIR/mysqld_12.sock"; SHOW INSTANCES; instance_name state -mysqld9b offline -mysqld6 offline +mysqld1 online +mysqld9 offline mysqld5 offline -mysqld9c offline +mysqld6 offline mysqld3 offline mysqld4 offline -mysqld9 offline +mysqld10 offline mysqld2 offline -mysqld1 online -mysqld9a offline -CREATE INSTANCE mysqld10 test-bad=' \ '; +mysqld12 offline +mysqld11 offline +CREATE INSTANCE mysqld13 test-bad=' \ '; ERROR 42000: You have an error in your command syntax. Check the manual that corresponds to your MySQL Instance Manager version for the right syntax to use SHOW INSTANCES; instance_name state -mysqld9b offline -mysqld6 offline +mysqld1 online +mysqld9 offline mysqld5 offline -mysqld9c offline +mysqld6 offline mysqld3 offline mysqld4 offline -mysqld9 offline +mysqld10 offline mysqld2 offline -mysqld1 online -mysqld9a offline +mysqld12 offline +mysqld11 offline -------------------------------------------------------------------- test-1= hello world -------------------------------------------------------------------- diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 96f31133e65..d0087568b58 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -13,9 +13,9 @@ #events_stress : BUG#17619 2006-02-21 andrey Race conditions #events : BUG#17619 2006-02-21 andrey Race conditions #events_scheduling : BUG#19170 2006-04-26 andrey Test case of 19170 fails on some platforms. Has to be checked. -im_instance_conf : Bug#20294 2006-06-06 monty Instance manager test im_instance_conf fails randomly -im_options : Bug#20294 2006-06-06 monty Instance manager test im_instance_conf fails randomly -im_life_cycle : Bug#20368 2006-06-10 alik im_life_cycle test fails +#im_instance_conf : Bug#20294 2006-06-06 monty Instance manager test im_instance_conf fails randomly +#im_options : Bug#20294 2006-06-06 monty Instance manager test im_instance_conf fails randomly +#im_life_cycle : Bug#20368 2006-06-10 alik im_life_cycle test fails ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog #ndb_binlog_discover : BUG#19395 2006-04-28 tomas/knielsen mysqld does not always detect cluster shutdown diff --git a/mysql-test/t/im_instance_conf.imtest b/mysql-test/t/im_instance_conf.imtest index 17703fdd303..2cd7b955978 100644 --- a/mysql-test/t/im_instance_conf.imtest +++ b/mysql-test/t/im_instance_conf.imtest @@ -69,7 +69,9 @@ SHOW VARIABLES LIKE 'server_id'; # Check that CREATE INSTANCE succeeds for non-existing instance and also check # that both config file and internal configuration cache have been updated. -CREATE INSTANCE mysqld3; +CREATE INSTANCE mysqld3 + server_id = 3, + socket = "$MYSQL_TMP_DIR/mysqld_3.sock"; SHOW INSTANCES; @@ -99,7 +101,10 @@ CREATE INSTANCE mysqld3; --exec grep nonguarded $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- -CREATE INSTANCE mysqld4 nonguarded; +CREATE INSTANCE mysqld4 + nonguarded, + server_id = 4, + socket = "$MYSQL_TMP_DIR/mysqld_4.sock"; SHOW INSTANCES; @@ -115,7 +120,11 @@ SHOW INSTANCES; --exec grep test-B $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- -CREATE INSTANCE mysqld5 test-A = 000, test-B = test; +CREATE INSTANCE mysqld5 + test-A = 000, + test-B = test, + server_id = 5, + socket = "$MYSQL_TMP_DIR/mysqld_5.sock"; SHOW INSTANCES; @@ -135,7 +144,11 @@ SHOW INSTANCES; --exec grep test-C $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- -CREATE INSTANCE mysqld6 test-C1 = 10 , test-C2 = 02 ; +CREATE INSTANCE mysqld6 + test-C1 = 10 , + test-C2 = 02 , + server_id = 6, + socket = "$MYSQL_TMP_DIR/mysqld_6.sock"; SHOW INSTANCES; @@ -183,22 +196,37 @@ SHOW INSTANCES; --exec grep test-4 $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- -CREATE INSTANCE mysqld9 test-1=" hello world ", test-2=' '; +CREATE INSTANCE mysqld9 + test-1=" hello world ", + test-2=' ', + server_id = 9, + socket = "$MYSQL_TMP_DIR/mysqld_9.sock"; SHOW INSTANCES; -CREATE INSTANCE mysqld9a test-3='\b\babc\sdef'; +CREATE INSTANCE mysqld10 + test-3='\b\babc\sdef', + server_id = 10, + socket = "$MYSQL_TMP_DIR/mysqld_10.sock"; # test-3='abc def' SHOW INSTANCES; -CREATE INSTANCE mysqld9b test-4='abc\tdef', test-5='abc\ndef'; +CREATE INSTANCE mysqld11 + test-4='abc\tdef', + test-5='abc\ndef', + server_id = 11, + socket = "$MYSQL_TMP_DIR/mysqld_11.sock"; SHOW INSTANCES; -CREATE INSTANCE mysqld9c test-6="abc\rdef", test-7="abc\\def"; +CREATE INSTANCE mysqld12 + test-6="abc\rdef", + test-7="abc\\def", + server_id = 12, + socket = "$MYSQL_TMP_DIR/mysqld_12.sock"; # test-6=abc SHOW INSTANCES; --error ER_SYNTAX_ERROR -CREATE INSTANCE mysqld10 test-bad=' \ '; +CREATE INSTANCE mysqld13 test-bad=' \ '; SHOW INSTANCES; --echo --------------------------------------------------------------------