diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index bb313191f54..5357220b6c5 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -728,7 +728,7 @@ CREATE TABLE t_crashme ( f1 BIGINT); CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1; CREATE VIEW a2 AS SELECT t_CRASHME FROM a1; count(*) -105 +106 drop view a2, a1; drop table t_crashme; select table_schema,table_name, column_name from @@ -811,7 +811,7 @@ flush privileges; SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; table_schema count(*) information_schema 19 -mysql 18 +mysql 19 create table t1 (i int, j int); create trigger trg1 before insert on t1 for each row begin diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index b2202ff10d0..1d6bfda0f55 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -1,5 +1,6 @@ mysql.columns_priv OK mysql.db OK +mysql.event OK mysql.func OK mysql.help_category OK mysql.help_keyword OK @@ -18,6 +19,7 @@ mysql.time_zone_transition_type OK mysql.user OK mysql.columns_priv OK mysql.db OK +mysql.event OK mysql.func OK mysql.help_category OK mysql.help_keyword OK diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index d102eb189d3..ec9fba40c23 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2116,6 +2116,7 @@ Create view Tables To create new views Create user Server Admin To create new users Delete Tables To delete existing rows Drop Databases,Tables To drop databases, tables, and views +Event Server Admin Creation, alteration, deletion and execution of events. Execute Functions,Procedures To execute stored routines File File access on server To read and write files on the server Grant option Databases,Tables,Functions,Procedures To give to other users those privileges you possess @@ -2170,6 +2171,7 @@ Create view Tables To create new views Create user Server Admin To create new users Delete Tables To delete existing rows Drop Databases,Tables To drop databases, tables, and views +Event Server Admin Creation, alteration, deletion and execution of events. Execute Functions,Procedures To execute stored routines File File access on server To read and write files on the server Grant option Databases,Tables,Functions,Procedures To give to other users those privileges you possess diff --git a/sql/event.cc b/sql/event.cc index 26f960e4bae..6d62be903bd 100644 --- a/sql/event.cc +++ b/sql/event.cc @@ -413,7 +413,7 @@ db_create_event(THD *thd, event_timed *et, my_bool create_if_not, if ((ret= evex_fill_row(thd, table, et, false))) goto err; - if (table->file->write_row(table->record[0])) + if (table->file->ha_write_row(table->record[0])) { my_error(ER_EVENT_STORE_FAILED, MYF(0), et->name.str, ret); goto err; @@ -423,8 +423,8 @@ db_create_event(THD *thd, event_timed *et, my_bool create_if_not, { thd->clear_error(); /* Such a statement can always go directly to binlog, no trans cache */ - Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE); - mysql_bin_log.write(&qinfo); + thd->binlog_query(THD::MYSQL_QUERY_TYPE, + thd->query, thd->query_length, FALSE, FALSE); } *rows_affected= 1; @@ -522,7 +522,7 @@ db_update_event(THD *thd, event_timed *et, sp_name *new_name) store(new_name->m_name.str, new_name->m_name.length, system_charset_info); } - if ((ret= table->file->update_row(table->record[1], table->record[0]))) + if ((ret= table->file->ha_update_row(table->record[1], table->record[0]))) { my_error(ER_EVENT_STORE_FAILED, MYF(0), et->name.str, ret); goto err; @@ -853,7 +853,7 @@ evex_drop_event(THD *thd, event_timed *et, bool drop_if_exists, if (!(ret= evex_db_find_event_aux(thd, et->dbname, et->name, table))) { - if ((ret= table->file->delete_row(table->record[0]))) + if ((ret= table->file->ha_delete_row(table->record[0]))) { my_error(ER_EVENT_CANNOT_DELETE, MYF(0)); goto done; diff --git a/sql/event_timed.cc b/sql/event_timed.cc index 50d171a658d..c4a36a81402 100644 --- a/sql/event_timed.cc +++ b/sql/event_timed.cc @@ -737,7 +737,7 @@ event_timed::drop(THD *thd) if (evex_db_find_event_aux(thd, dbname, name, table)) DBUG_RETURN(-2); - if ((ret= table->file->delete_row(table->record[0]))) + if ((ret= table->file->ha_delete_row(table->record[0]))) DBUG_RETURN(ret); close_thread_tables(thd); @@ -790,7 +790,7 @@ event_timed::update_fields(THD *thd) status_changed= false; } - if ((table->file->update_row(table->record[1],table->record[0]))) + if ((table->file->ha_update_row(table->record[1],table->record[0]))) ret= EVEX_WRITE_ROW_FAILED; done: diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 7f76686f953..63fd9db4744 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5747,3 +5747,35 @@ ER_BINLOG_ROW_WRONG_TABLE_DEF eng "Table definition on master and slave does not match" ER_BINLOG_ROW_RBR_TO_SBR eng "Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events" +ER_EVENT_ALREADY_EXISTS + eng "Event '%-.64s' already exists" +ER_EVENT_STORE_FAILED + eng "Failed to store event %s. Error code %d from storage engine." +ER_EVENT_DOES_NOT_EXIST + eng "Unknown event '%-.64s'" +ER_EVENT_CANT_ALTER + eng "Failed to alter event '%-.64s'" +ER_EVENT_DROP_FAILED + eng "Failed to drop %s" +ER_EVENT_INTERVAL_NOT_POSITIVE + eng "INTERVAL must be positive" +ER_EVENT_ENDS_BEFORE_STARTS + eng "ENDS must be after STARTS" +ER_EVENT_EXEC_TIME_IN_THE_PAST + eng "Activation (AT) time is in the past" +ER_EVENT_OPEN_TABLE_FAILED + eng "Failed to open mysql.event" +ER_EVENT_NEITHER_M_EXPR_NOR_M_AT + eng "No datetime expression provided" +ER_EVENT_COL_COUNT_DOESNT_MATCH + eng "Column count of %s.%s is wrong. Table probably corrupted" +ER_EVENT_CANNOT_LOAD_FROM_TABLE + eng "Cannot load from mysql.event. Table probably corrupted" +ER_EVENT_CANNOT_DELETE + eng "Failed to delete the event from mysql.event" +ER_EVENT_COMPILE_ERROR + eng "Error during compilation of event's body" +ER_EVENT_SAME_NAME + eng "Same old and new event name" +ER_EVENT_DATA_TOO_LONG + eng "Data for column '%s' too long" diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index cb377e97f52..a3734a48c5c 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1404,6 +1404,93 @@ create: lex->alter_tablespace_info->ts_cmd_type= CREATE_TABLESPACE; } ; + + +ev_schedule_time: EVERY_SYM expr interval + { + LEX *lex=Lex; + if (!lex->et_compile_phase) + { + switch (lex->et->init_interval(YYTHD , $2, $3)) { + case EVEX_PARSE_ERROR: + yyerror(ER(ER_SYNTAX_ERROR)); + YYABORT; + break; + case EVEX_BAD_PARAMS: + my_error(ER_EVENT_INTERVAL_NOT_POSITIVE, MYF(0)); + YYABORT; + break; + } + } + } + ev_starts + ev_ends + | AT_SYM expr + { + LEX *lex=Lex; + if (!lex->et_compile_phase) + { + switch (lex->et->init_execute_at(YYTHD, $2)) { + case EVEX_PARSE_ERROR: + yyerror(ER(ER_SYNTAX_ERROR)); + YYABORT; + break; + case EVEX_BAD_PARAMS: + my_error(ER_EVENT_EXEC_TIME_IN_THE_PAST, MYF(0)); + YYABORT; + break; + } + } + } + ; + +ev_status: /* empty */ {$$= 0;} + | ENABLED_SYM + { + LEX *lex=Lex; + if (!lex->et_compile_phase) + lex->et->status= MYSQL_EVENT_ENABLED; + $$= 1; + } + | DISABLED_SYM + { + LEX *lex=Lex; + + if (!lex->et_compile_phase) + lex->et->status= MYSQL_EVENT_DISABLED; + $$= 1; + } + ; + +ev_starts: /* empty */ + | STARTS_SYM expr + { + LEX *lex= Lex; + if (!lex->et_compile_phase) + lex->et->init_starts(YYTHD, $2); + } + ; + +ev_ends: /* empty */ + | ENDS_SYM expr + { + LEX *lex= Lex; + if (!lex->et_compile_phase) + { + switch (lex->et->init_ends(YYTHD, $2)) { + case EVEX_PARSE_ERROR: + yyerror(ER(ER_SYNTAX_ERROR)); + YYABORT; + break; + case EVEX_BAD_PARAMS: + my_error(ER_EVENT_ENDS_BEFORE_STARTS, MYF(0)); + YYABORT; + break; + } + } + } + ; + ev_on_completion: /* empty */ {$$= 0;} | ON COMPLETION_SYM PRESERVE_SYM { @@ -1420,6 +1507,7 @@ ev_on_completion: /* empty */ {$$= 0;} $$= 1; } ; + ev_comment: /* empty */ {$$= 0;} | COMMENT_SYM TEXT_STRING_sys { @@ -1502,6 +1590,7 @@ ev_sql_stmt_inner: | sp_proc_stmt_close ; + clear_privileges: /* Nothing */ { @@ -4603,7 +4692,6 @@ alter: Recursive events are not possible because recursive SPs are not also possible. lex->sp_head is not stacked. */ - // ToDo Andrey : Change the error message my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "EVENT"); YYABORT; } @@ -4672,6 +4760,7 @@ alter: } ; + ev_on_schedule: /* empty */ { $$= 0;} | ON SCHEDULE_SYM ev_schedule_time { @@ -4688,6 +4777,13 @@ ev_rename_to: /* empty */ { $$= 0;} $$= 1; } ; + +ev_opt_sql_stmt: /* empty*/ { $$= 0;} + | DO_SYM ev_sql_stmt + { + $$= 1; + } + ; ident_or_empty: @@ -8106,8 +8202,8 @@ show_param: { Lex->sql_command = SQLCOM_SHOW_CREATE_EVENT; Lex->spname= $3; - }; - ; + } + ; show_engine_param: STATUS_SYM