| 8594 | */ |
| 8595 | |
| 8596 | int |
| 8597 | copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table) |
| 8598 | { |
| 8599 | const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; |
| 8600 | CHARSET_INFO *scs= system_charset_info; |
| 8601 | MYSQL_TIME time; |
| 8602 | Event_timed et; |
| 8603 | DBUG_ENTER("copy_event_to_schema_table"); |
| 8604 | |
| 8605 | restore_record(sch_table, s->default_values); |
| 8606 | |
| 8607 | if (et.load_from_row(thd, event_table)) |
| 8608 | { |
| 8609 | my_error(ER_CANNOT_LOAD_FROM_TABLE_V2, MYF(0), "mysql", "event"); |
| 8610 | DBUG_RETURN(1); |
| 8611 | } |
| 8612 | |
| 8613 | if (!(!wild || !wild[0] || !wild_case_compare(scs, et.name.str, wild))) |
| 8614 | DBUG_RETURN(0); |
| 8615 | |
| 8616 | /* |
| 8617 | Skip events in schemas one does not have access to. The check is |
| 8618 | optimized. It's guaranteed in case of SHOW EVENTS that the user |
| 8619 | has access. |
| 8620 | */ |
| 8621 | if (thd->lex->sql_command != SQLCOM_SHOW_EVENTS && |
| 8622 | check_access(thd, EVENT_ACL, et.dbname.str, NULL, NULL, 0, 1)) |
| 8623 | DBUG_RETURN(0); |
| 8624 | |
| 8625 | sch_table->field[ISE_EVENT_CATALOG]->store(STRING_WITH_LEN("def"), scs); |
| 8626 | sch_table->field[ISE_EVENT_SCHEMA]-> |
| 8627 | store(et.dbname.str, et.dbname.length,scs); |
| 8628 | sch_table->field[ISE_EVENT_NAME]-> |
| 8629 | store(et.name.str, et.name.length, scs); |
| 8630 | sch_table->field[ISE_DEFINER]-> |
| 8631 | store(et.definer.str, et.definer.length, scs); |
| 8632 | const String *tz_name= et.time_zone->get_name(); |
| 8633 | sch_table->field[ISE_TIME_ZONE]-> |
| 8634 | store(tz_name->ptr(), tz_name->length(), scs); |
| 8635 | sch_table->field[ISE_EVENT_BODY]-> |
| 8636 | store(STRING_WITH_LEN("SQL"), scs); |
| 8637 | sch_table->field[ISE_EVENT_DEFINITION]->store( |
| 8638 | et.body_utf8.str, et.body_utf8.length, scs); |
| 8639 | |
| 8640 | /* SQL_MODE */ |
| 8641 | { |
| 8642 | LEX_CSTRING sql_mode; |
| 8643 | sql_mode_string_representation(thd, et.sql_mode, &sql_mode); |
| 8644 | sch_table->field[ISE_SQL_MODE]-> |
| 8645 | store(sql_mode.str, sql_mode.length, scs); |
| 8646 | } |
| 8647 | |
| 8648 | int not_used=0; |
| 8649 | |
| 8650 | if (et.expression) |
| 8651 | { |
| 8652 | String show_str; |
| 8653 | /* type */ |
no test coverage detected