#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"Include dependency graph for events.cc:

Go to the source code of this file.
Functions | |
| int | sortcmp_lex_string (LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs) |
| int | evex_db_find_event_aux (THD *thd, Event_timed *et, TABLE *table) |
| int | evex_db_find_event_by_name (THD *thd, const LEX_STRING dbname, const LEX_STRING ev_name, TABLE *table) |
| static int | evex_fill_row (THD *thd, TABLE *table, Event_timed *et, my_bool is_update) |
| int | db_create_event (THD *thd, Event_timed *et, my_bool create_if_not, uint *rows_affected) |
| static int | db_update_event (THD *thd, Event_timed *et, sp_name *new_name) |
| int | db_find_event (THD *thd, sp_name *name, Event_timed **ett, TABLE *tbl, MEM_ROOT *root) |
| int | db_drop_event (THD *thd, Event_timed *et, bool drop_if_exists, uint *rows_affected) |
| int | db_drop_events_from_table (THD *thd, LEX_STRING *db) |
Variables | |
| MEM_ROOT | evex_mem_root |
| time_t | mysql_event_last_create_time = 0L |
| const char * | event_scheduler_state_names [] |
| static TABLE_FIELD_W_TYPE | event_table_fields [Events::FIELD_COUNT] |
| int db_create_event | ( | THD * | thd, | |
| Event_timed * | et, | |||
| my_bool | create_if_not, | |||
| uint * | rows_affected | |||
| ) |
Definition at line 595 of file events.cc.
References Event_timed::body, close_thread_tables(), charset_info_st::cset, Event_timed::dbname, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, ER, ER_BAD_DB_ERROR, ER_EVENT_ALREADY_EXISTS, ER_EVENT_NEITHER_M_EXPR_NOR_M_AT, ER_EVENT_OPEN_TABLE_FAILED, ER_EVENT_STORE_FAILED, ER_TOO_LONG_BODY, ER_TOO_LONG_IDENT, err, EVEX_DB_FIELD_LEN, evex_db_find_event_aux(), evex_fill_row(), EVEX_GENERAL_ERROR, EVEX_OK, Event_timed::execute_at, Event_timed::expression, FALSE, st_table::field, Events::FIELD_BODY, Events::FIELD_CREATED, st_table::file, handler::ha_write_row(), MYSQL_LOG::is_open(), LEX_STRING::length, my_error(), MYF, mysql_bin_log, mysql_change_db(), Event_timed::name, NAME_LEN, my_charset_handler_st::numchars, ok(), Events::open_event_table(), push_warning_printf(), st_table::record, restore_record, sp_use_new_db(), LEX_STRING::str, system_charset_info, TL_WRITE, MYSQL_ERROR::WARN_LEVEL_NOTE, and st_mysql_time::year.
Referenced by Events::create_event().
00597 { 00598 int ret= 0; 00599 CHARSET_INFO *scs= system_charset_info; 00600 TABLE *table; 00601 char old_db_buf[NAME_LEN+1]; 00602 LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; 00603 bool dbchanged= FALSE; 00604 DBUG_ENTER("db_create_event"); 00605 DBUG_PRINT("enter", ("name: %.*s", et->name.length, et->name.str)); 00606 00607 *rows_affected= 0; 00608 DBUG_PRINT("info", ("open mysql.event for update")); 00609 if (Events::open_event_table(thd, TL_WRITE, &table)) 00610 { 00611 my_error(ER_EVENT_OPEN_TABLE_FAILED, MYF(0)); 00612 goto err; 00613 } 00614 00615 DBUG_PRINT("info", ("check existance of an event with the same name")); 00616 if (!evex_db_find_event_aux(thd, et, table)) 00617 { 00618 if (create_if_not) 00619 { 00620 push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, 00621 ER_EVENT_ALREADY_EXISTS, ER(ER_EVENT_ALREADY_EXISTS), 00622 et->name.str); 00623 goto ok; 00624 } 00625 my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), et->name.str); 00626 goto err; 00627 } 00628 00629 DBUG_PRINT("info", ("non-existant, go forward")); 00630 if ((ret= sp_use_new_db(thd, et->dbname, &old_db, 0, &dbchanged))) 00631 { 00632 my_error(ER_BAD_DB_ERROR, MYF(0)); 00633 goto err; 00634 } 00635 00636 restore_record(table, s->default_values); // Get default values for fields 00637 00638 if (system_charset_info->cset->numchars(system_charset_info, et->dbname.str, 00639 et->dbname.str + et->dbname.length) 00640 > EVEX_DB_FIELD_LEN) 00641 { 00642 my_error(ER_TOO_LONG_IDENT, MYF(0), et->dbname.str); 00643 goto err; 00644 } 00645 if (system_charset_info->cset->numchars(system_charset_info, et->name.str, 00646 et->name.str + et->name.length) 00647 > EVEX_DB_FIELD_LEN) 00648 { 00649 my_error(ER_TOO_LONG_IDENT, MYF(0), et->name.str); 00650 goto err; 00651 } 00652 00653 if (et->body.length > table->field[Events::FIELD_BODY]->field_length) 00654 { 00655 my_error(ER_TOO_LONG_BODY, MYF(0), et->name.str); 00656 goto err; 00657 } 00658 00659 if (!(et->expression) && !(et->execute_at.year)) 00660 { 00661 DBUG_PRINT("error", ("neither expression nor execute_at are set!")); 00662 my_error(ER_EVENT_NEITHER_M_EXPR_NOR_M_AT, MYF(0)); 00663 goto err; 00664 } 00665 00666 ((Field_timestamp *)table->field[Events::FIELD_CREATED])->set_time(); 00667 00668 /* 00669 evex_fill_row() calls my_error() in case of error so no need to 00670 handle it here 00671 */ 00672 if ((ret= evex_fill_row(thd, table, et, false))) 00673 goto err; 00674 00675 if (table->file->ha_write_row(table->record[0])) 00676 { 00677 my_error(ER_EVENT_STORE_FAILED, MYF(0), et->name.str, ret); 00678 goto err; 00679 } 00680 00681 #ifdef USE_THIS_CODE_AS_TEMPLATE_WHEN_EVENT_REPLICATION_IS_AGREED 00682 if (mysql_bin_log.is_open()) 00683 { 00684 thd->clear_error(); 00685 /* Such a statement can always go directly to binlog, no trans cache */ 00686 thd->binlog_query(THD::MYSQL_QUERY_TYPE, thd->query, thd->query_length, 00687 FALSE, FALSE); 00688 } 00689 #endif 00690 00691 *rows_affected= 1; 00692 ok: 00693 if (dbchanged) 00694 (void) mysql_change_db(thd, old_db.str, 1); 00695 if (table) 00696 close_thread_tables(thd); 00697 DBUG_RETURN(EVEX_OK); 00698 00699 err: 00700 if (dbchanged) 00701 (void) mysql_change_db(thd, old_db.str, 1); 00702 if (table) 00703 close_thread_tables(thd); 00704 DBUG_RETURN(EVEX_GENERAL_ERROR); 00705 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int db_drop_event | ( | THD * | thd, | |
| Event_timed * | et, | |||
| bool | drop_if_exists, | |||
| uint * | rows_affected | |||
| ) |
Definition at line 991 of file events.cc.
References backup, close_thread_tables(), DBUG_ENTER, DBUG_RETURN, ER, ER_EVENT_CANNOT_DELETE, ER_EVENT_DOES_NOT_EXIST, ER_EVENT_OPEN_TABLE_FAILED, ER_SP_DOES_NOT_EXIST, evex_db_find_event_aux(), EVEX_KEY_NOT_FOUND, EVEX_OPEN_TABLE_FAILED, st_table::file, handler::ha_delete_row(), my_error(), MYF, Event_timed::name, Events::open_event_table(), push_warning_printf(), st_table::record, LEX_STRING::str, TL_WRITE, and MYSQL_ERROR::WARN_LEVEL_NOTE.
Referenced by Event_timed::drop(), and Events::drop_event().
00993 { 00994 TABLE *table; 00995 Open_tables_state backup; 00996 int ret; 00997 00998 DBUG_ENTER("db_drop_event"); 00999 ret= EVEX_OPEN_TABLE_FAILED; 01000 01001 thd->reset_n_backup_open_tables_state(&backup); 01002 if (Events::open_event_table(thd, TL_WRITE, &table)) 01003 { 01004 my_error(ER_EVENT_OPEN_TABLE_FAILED, MYF(0)); 01005 goto done; 01006 } 01007 01008 if (!(ret= evex_db_find_event_aux(thd, et, table))) 01009 { 01010 if ((ret= table->file->ha_delete_row(table->record[0]))) 01011 { 01012 my_error(ER_EVENT_CANNOT_DELETE, MYF(0)); 01013 goto done; 01014 } 01015 } 01016 else if (ret == EVEX_KEY_NOT_FOUND) 01017 { 01018 if (drop_if_exists) 01019 { 01020 push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, 01021 ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), 01022 "Event", et->name.str); 01023 ret= 0; 01024 } else 01025 my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), et->name.str); 01026 goto done; 01027 } 01028 01029 01030 done: 01031 /* 01032 evex_drop_event() is used by Event_timed::drop therefore 01033 we have to close our thread tables. 01034 */ 01035 close_thread_tables(thd); 01036 thd->restore_backup_open_tables_state(&backup); 01037 DBUG_RETURN(ret); 01038 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int db_drop_events_from_table | ( | THD * | thd, | |
| LEX_STRING * | db | |||
| ) |
Definition at line 1193 of file events.cc.
References close_thread_tables(), db, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, end_read_record(), ER_EVENT_DROP_FAILED, st_table::field, Events::FIELD_DB, Events::FIELD_NAME, st_table::file, get_field(), handler::ha_delete_row(), init_read_record(), my_errno, my_error(), MYF, NULL, Events::open_event_table(), st_read_record::read_record, st_table::record, sortcmp_lex_string(), sql_print_error(), strlen(), system_charset_info, and TL_WRITE.
Referenced by Events::drop_schema_events(), and Event_scheduler::drop_schema_events().
01194 { 01195 int ret; 01196 TABLE *table; 01197 READ_RECORD read_record_info; 01198 DBUG_ENTER("db_drop_events_from_table"); 01199 DBUG_PRINT("info", ("dropping events from %s", db->str)); 01200 01201 if ((ret= Events::open_event_table(thd, TL_WRITE, &table))) 01202 { 01203 if (my_errno != ENOENT) 01204 sql_print_error("Table mysql.event is damaged. Got error %d on open", 01205 my_errno); 01206 DBUG_RETURN(ret); 01207 } 01208 /* only enabled events are in memory, so we go now and delete the rest */ 01209 init_read_record(&read_record_info, thd, table, NULL, 1, 0); 01210 while (!(read_record_info.read_record(&read_record_info)) && !ret) 01211 { 01212 char *et_db= get_field(thd->mem_root, 01213 table->field[Events::FIELD_DB]); 01214 01215 LEX_STRING et_db_lex= {et_db, strlen(et_db)}; 01216 DBUG_PRINT("info", ("Current event %s.%s", et_db, 01217 get_field(thd->mem_root, 01218 table->field[Events::FIELD_NAME]))); 01219 01220 if (!sortcmp_lex_string(et_db_lex, *db, system_charset_info)) 01221 { 01222 DBUG_PRINT("info", ("Dropping")); 01223 if ((ret= table->file->ha_delete_row(table->record[0]))) 01224 my_error(ER_EVENT_DROP_FAILED, MYF(0), 01225 get_field(thd->mem_root, 01226 table->field[Events::FIELD_NAME])); 01227 } 01228 } 01229 end_read_record(&read_record_info); 01230 thd->version--; /* Force close to free memory */ 01231 01232 close_thread_tables(thd); 01233 01234 DBUG_RETURN(ret); 01235 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int db_find_event | ( | THD * | thd, | |
| sp_name * | name, | |||
| Event_timed ** | ett, | |||
| TABLE * | tbl, | |||
| MEM_ROOT * | root | |||
| ) |
Definition at line 832 of file events.cc.
References close_thread_tables(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, ER_CANNOT_LOAD_FROM_TABLE, ER_EVENT_DOES_NOT_EXIST, ER_EVENT_OPEN_TABLE_FAILED, evex_db_find_event_by_name(), EVEX_GENERAL_ERROR, evex_mem_root, Event_timed::load_from_row(), my_error(), MYF, name, NULL, Events::open_event_table(), and TL_READ.
Referenced by Event_scheduler::load_named_event(), and Events::show_create_event().
00834 { 00835 TABLE *table; 00836 int ret; 00837 Event_timed *et= NULL; 00838 DBUG_ENTER("db_find_event"); 00839 DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str)); 00840 00841 if (!root) 00842 root= &evex_mem_root; 00843 00844 if (tbl) 00845 table= tbl; 00846 else if (Events::open_event_table(thd, TL_READ, &table)) 00847 { 00848 my_error(ER_EVENT_OPEN_TABLE_FAILED, MYF(0)); 00849 ret= EVEX_GENERAL_ERROR; 00850 goto done; 00851 } 00852 00853 if ((ret= evex_db_find_event_by_name(thd, name->m_db, name->m_name, table))) 00854 { 00855 my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), name->m_name.str); 00856 goto done; 00857 } 00858 et= new Event_timed; 00859 00860 /* 00861 1)The table should not be closed beforehand. ::load_from_row() only loads 00862 and does not compile 00863 00864 2)::load_from_row() is silent on error therefore we emit error msg here 00865 */ 00866 if ((ret= et->load_from_row(root, table))) 00867 { 00868 my_error(ER_CANNOT_LOAD_FROM_TABLE, MYF(0)); 00869 goto done; 00870 } 00871 00872 done: 00873 if (ret) 00874 { 00875 delete et; 00876 et= 0; 00877 } 00878 /* don't close the table if we haven't opened it ourselves */ 00879 if (!tbl && table) 00880 close_thread_tables(thd); 00881 *ett= et; 00882 DBUG_RETURN(ret); 00883 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int db_update_event | ( | THD * | thd, | |
| Event_timed * | et, | |||
| sp_name * | new_name | |||
| ) | [static] |
Definition at line 727 of file events.cc.
References close_thread_tables(), Event_timed::dbname, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, Event_timed::definer, ER_EVENT_ALREADY_EXISTS, ER_EVENT_DOES_NOT_EXIST, ER_EVENT_OPEN_TABLE_FAILED, ER_EVENT_SAME_NAME, ER_EVENT_STORE_FAILED, err, evex_db_find_event_aux(), evex_db_find_event_by_name(), evex_fill_row(), EVEX_GENERAL_ERROR, EVEX_KEY_NOT_FOUND, EVEX_OPEN_TABLE_FAILED, st_table::field, Events::FIELD_DB, Events::FIELD_NAME, st_table::file, handler::ha_update_row(), LEX_STRING::length, sp_name::m_db, sp_name::m_name, my_error(), MYF, Event_timed::name, Events::open_event_table(), st_table::record, sortcmp_lex_string(), store_record, LEX_STRING::str, system_charset_info, st_table::timestamp_field_type, TIMESTAMP_NO_AUTO_SET, and TL_WRITE.
Referenced by Events::update_event().
00728 { 00729 CHARSET_INFO *scs= system_charset_info; 00730 TABLE *table; 00731 int ret= EVEX_OPEN_TABLE_FAILED; 00732 DBUG_ENTER("db_update_event"); 00733 DBUG_PRINT("enter", ("dbname: %.*s", et->dbname.length, et->dbname.str)); 00734 DBUG_PRINT("enter", ("name: %.*s", et->name.length, et->name.str)); 00735 DBUG_PRINT("enter", ("user: %.*s", et->definer.length, et->definer.str)); 00736 if (new_name) 00737 DBUG_PRINT("enter", ("rename to: %.*s", new_name->m_name.length, 00738 new_name->m_name.str)); 00739 00740 if (Events::open_event_table(thd, TL_WRITE, &table)) 00741 { 00742 my_error(ER_EVENT_OPEN_TABLE_FAILED, MYF(0)); 00743 goto err; 00744 } 00745 00746 /* first look whether we overwrite */ 00747 if (new_name) 00748 { 00749 if (!sortcmp_lex_string(et->name, new_name->m_name, scs) && 00750 !sortcmp_lex_string(et->dbname, new_name->m_db, scs)) 00751 { 00752 my_error(ER_EVENT_SAME_NAME, MYF(0), et->name.str); 00753 goto err; 00754 } 00755 00756 if (!evex_db_find_event_by_name(thd,new_name->m_db,new_name->m_name,table)) 00757 { 00758 my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), new_name->m_name.str); 00759 goto err; 00760 } 00761 } 00762 /* 00763 ...and then if there is such an event. Don't exchange the blocks 00764 because you will get error 120 from table handler because new_name will 00765 overwrite the key and SE will tell us that it cannot find the already found 00766 row (copied into record[1] later 00767 */ 00768 if (EVEX_KEY_NOT_FOUND == evex_db_find_event_aux(thd, et, table)) 00769 { 00770 my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), et->name.str); 00771 goto err; 00772 } 00773 00774 store_record(table,record[1]); 00775 00776 /* Don't update create on row update. */ 00777 table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; 00778 00779 /* 00780 evex_fill_row() calls my_error() in case of error so no need to 00781 handle it here 00782 */ 00783 if ((ret= evex_fill_row(thd, table, et, true))) 00784 goto err; 00785 00786 if (new_name) 00787 { 00788 table->field[Events::FIELD_DB]-> 00789 store(new_name->m_db.str, new_name->m_db.length, scs); 00790 table->field[Events::FIELD_NAME]-> 00791 store(new_name->m_name.str, new_name->m_name.length, scs); 00792 } 00793 00794 if ((ret= table->file->ha_update_row(table->record[1], table->record[0]))) 00795 { 00796 my_error(ER_EVENT_STORE_FAILED, MYF(0), et->name.str, ret); 00797 goto err; 00798 } 00799 00800 /* close mysql.event or we crash later when loading the event from disk */ 00801 close_thread_tables(thd); 00802 DBUG_RETURN(0); 00803 00804 err: 00805 if (table) 00806 close_thread_tables(thd); 00807 DBUG_RETURN(EVEX_GENERAL_ERROR); 00808 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int evex_db_find_event_aux | ( | THD * | thd, | |
| Event_timed * | et, | |||
| TABLE * | table | |||
| ) | [inline] |
Definition at line 384 of file events.cc.
References Event_timed::dbname, evex_db_find_event_by_name(), and Event_timed::name.
Referenced by db_create_event(), db_drop_event(), and db_update_event().
00385 { 00386 return evex_db_find_event_by_name(thd, et->dbname, et->name, table); 00387 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int evex_db_find_event_by_name | ( | THD * | thd, | |
| const LEX_STRING | dbname, | |||
| const LEX_STRING | ev_name, | |||
| TABLE * | table | |||
| ) |
Definition at line 406 of file events.cc.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, EVEX_KEY_NOT_FOUND, st_table::field, Events::FIELD_DB, Events::FIELD_NAME, st_table::file, HA_READ_KEY_EXACT, handler::index_read_idx(), key, key_copy(), st_table::key_info, st_key::key_length, LEX_STRING::length, MAX_KEY_LENGTH, my_charset_bin, st_table::record, Field::store(), and LEX_STRING::str.
Referenced by db_find_event(), db_update_event(), evex_db_find_event_aux(), and Event_timed::update_fields().
00409 { 00410 byte key[MAX_KEY_LENGTH]; 00411 DBUG_ENTER("evex_db_find_event_by_name"); 00412 DBUG_PRINT("enter", ("name: %.*s", ev_name.length, ev_name.str)); 00413 00414 /* 00415 Create key to find row. We have to use field->store() to be able to 00416 handle VARCHAR and CHAR fields. 00417 Assumption here is that the two first fields in the table are 00418 'db' and 'name' and the first key is the primary key over the 00419 same fields. 00420 */ 00421 if (dbname.length > table->field[Events::FIELD_DB]->field_length || 00422 ev_name.length > table->field[Events::FIELD_NAME]->field_length) 00423 00424 DBUG_RETURN(EVEX_KEY_NOT_FOUND); 00425 00426 table->field[Events::FIELD_DB]->store(dbname.str, dbname.length, 00427 &my_charset_bin); 00428 table->field[Events::FIELD_NAME]->store(ev_name.str, ev_name.length, 00429 &my_charset_bin); 00430 00431 key_copy(key, table->record[0], table->key_info, 00432 table->key_info->key_length); 00433 00434 if (table->file->index_read_idx(table->record[0], 0, key, 00435 table->key_info->key_length, 00436 HA_READ_KEY_EXACT)) 00437 { 00438 DBUG_PRINT("info", ("Row not found")); 00439 DBUG_RETURN(EVEX_KEY_NOT_FOUND); 00440 } 00441 00442 DBUG_PRINT("info", ("Row found!")); 00443 DBUG_RETURN(0); 00444 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int evex_fill_row | ( | THD * | thd, | |
| TABLE * | table, | |||
| Event_timed * | et, | |||
| my_bool | is_update | |||
| ) | [static] |
Definition at line 466 of file events.cc.
References Event_timed::body, Event_timed::comment, Event_timed::dbname, DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, Event_timed::definer, Event_timed::ends, Event_timed::ends_null, ER_EVENT_DATA_TOO_LONG, EVEX_GENERAL_ERROR, Event_timed::execute_at, Event_timed::expression, st_table::field, Events::FIELD_BODY, Events::FIELD_COMMENT, Events::FIELD_DB, Events::FIELD_DEFINER, Events::FIELD_ENDS, Events::FIELD_EXECUTE_AT, Events::FIELD_INTERVAL_EXPR, Events::FIELD_MODIFIED, Field::field_name, Events::FIELD_NAME, Events::FIELD_ON_COMPLETION, Events::FIELD_SQL_MODE, Events::FIELD_STARTS, Events::FIELD_STATUS, Events::FIELD_TRANSIENT_INTERVAL, Event_timed::interval, LEX_STRING::length, my_error(), MYF, MYSQL_TIMESTAMP_DATETIME, Event_timed::name, Event_timed::on_completion, Field::set_notnull(), Field::set_null(), Event_timed::starts, Event_timed::starts_null, Event_timed::status, Field::store(), LEX_STRING::str, system_charset_info, and st_mysql_time::year.
Referenced by db_create_event(), and db_update_event().
00467 { 00468 CHARSET_INFO *scs= system_charset_info; 00469 enum Events::enum_table_field field_num; 00470 00471 DBUG_ENTER("evex_fill_row"); 00472 00473 DBUG_PRINT("info", ("dbname=[%s]", et->dbname.str)); 00474 DBUG_PRINT("info", ("name =[%s]", et->name.str)); 00475 DBUG_PRINT("info", ("body =[%s]", et->body.str)); 00476 00477 if (table->field[field_num= Events::FIELD_DEFINER]-> 00478 store(et->definer.str, et->definer.length, scs)) 00479 goto err_truncate; 00480 00481 if (table->field[field_num= Events::FIELD_DB]-> 00482 store(et->dbname.str, et->dbname.length, scs)) 00483 goto err_truncate; 00484 00485 if (table->field[field_num= Events::FIELD_NAME]-> 00486 store(et->name.str, et->name.length, scs)) 00487 goto err_truncate; 00488 00489 /* both ON_COMPLETION and STATUS are NOT NULL thus not calling set_notnull()*/ 00490 table->field[Events::FIELD_ON_COMPLETION]-> 00491 store((longlong)et->on_completion, true); 00492 00493 table->field[Events::FIELD_STATUS]->store((longlong)et->status, true); 00494 00495 /* 00496 Change the SQL_MODE only if body was present in an ALTER EVENT and of course 00497 always during CREATE EVENT. 00498 */ 00499 if (et->body.str) 00500 { 00501 table->field[Events::FIELD_SQL_MODE]-> 00502 store((longlong)thd->variables.sql_mode, true); 00503 00504 if (table->field[field_num= Events::FIELD_BODY]-> 00505 store(et->body.str, et->body.length, scs)) 00506 goto err_truncate; 00507 } 00508 00509 if (et->expression) 00510 { 00511 table->field[Events::FIELD_INTERVAL_EXPR]->set_notnull(); 00512 table->field[Events::FIELD_INTERVAL_EXPR]-> 00513 store((longlong)et->expression, true); 00514 00515 table->field[Events::FIELD_TRANSIENT_INTERVAL]->set_notnull(); 00516 /* 00517 In the enum (C) intervals start from 0 but in mysql enum valid values start 00518 from 1. Thus +1 offset is needed! 00519 */ 00520 table->field[Events::FIELD_TRANSIENT_INTERVAL]-> 00521 store((longlong)et->interval+1, true); 00522 00523 table->field[Events::FIELD_EXECUTE_AT]->set_null(); 00524 00525 if (!et->starts_null) 00526 { 00527 table->field[Events::FIELD_STARTS]->set_notnull(); 00528 table->field[Events::FIELD_STARTS]-> 00529 store_time(&et->starts, MYSQL_TIMESTAMP_DATETIME); 00530 } 00531 00532 if (!et->ends_null) 00533 { 00534 table->field[Events::FIELD_ENDS]->set_notnull(); 00535 table->field[Events::FIELD_ENDS]-> 00536 store_time(&et->ends, MYSQL_TIMESTAMP_DATETIME); 00537 } 00538 } 00539 else if (et->execute_at.year) 00540 { 00541 table->field[Events::FIELD_INTERVAL_EXPR]->set_null(); 00542 table->field[Events::FIELD_TRANSIENT_INTERVAL]->set_null(); 00543 table->field[Events::FIELD_STARTS]->set_null(); 00544 table->field[Events::FIELD_ENDS]->set_null(); 00545 00546 table->field[Events::FIELD_EXECUTE_AT]->set_notnull(); 00547 table->field[Events::FIELD_EXECUTE_AT]-> 00548 store_time(&et->execute_at, MYSQL_TIMESTAMP_DATETIME); 00549 } 00550 else 00551 { 00552 DBUG_ASSERT(is_update); 00553 /* 00554 it is normal to be here when the action is update 00555 this is an error if the action is create. something is borked 00556 */ 00557 } 00558 00559 ((Field_timestamp *)table->field[Events::FIELD_MODIFIED])->set_time(); 00560 00561 if (et->comment.str) 00562 { 00563 if (table->field[field_num= Events::FIELD_COMMENT]-> 00564 store(et->comment.str, et->comment.length, scs)) 00565 goto err_truncate; 00566 } 00567 00568 DBUG_RETURN(0); 00569 err_truncate: 00570 my_error(ER_EVENT_DATA_TOO_LONG, MYF(0), table->field[field_num]->field_name); 00571 DBUG_RETURN(EVEX_GENERAL_ERROR); 00572 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int sortcmp_lex_string | ( | LEX_STRING | s, | |
| LEX_STRING | t, | |||
| CHARSET_INFO * | cs | |||
| ) |
Definition at line 184 of file events.cc.
References charset_info_st::coll, LEX_STRING::length, LEX_STRING::str, and my_collation_handler_st::strnncollsp.
Referenced by db_drop_events_from_table(), db_update_event(), event_timed_db_equal(), event_timed_definer_equal(), and event_timed_name_equal().
00185 { 00186 return cs->coll->strnncollsp(cs, (uchar *) s.str,s.length, 00187 (uchar *) t.str,t.length, 0); 00188 }
Here is the caller graph for this function:

| const char* event_scheduler_state_names[] |
TABLE_FIELD_W_TYPE event_table_fields[Events::FIELD_COUNT] [static] |
| time_t mysql_event_last_create_time = 0L |
1.4.7

