Commit bc3708a5 authored by unknown's avatar unknown

WL#1034 ongoing updates after review


sql/event.cc:
  -my_error() as close as possible to the place where the error
   occurs.
  -a thought how to replicate events
  -use close_thread_tables() in some cases and for others rely on
   this call being done in sql_parse.cc::do_command()
sql/event.h:
  remove redundant defines
sql/event_executor.cc:
  - reenable the compilation again
  - don't backup the open_tables_state, it's not needed
sql/event_timed.cc:
  - inline a bit
  - comment added
sql/mysqld.cc:
  - start mysqld with --event-scheduler=0 by default
sql/share/errmsg.txt:
  3 new messages
sql/sql_parse.cc:
  remove now obsolete error checking - the errors are reported
  as closer as possible to the place where they are detected
sql/sql_yacc.yy:
  add WARNING message. fix a bug that was corrupting 
  thd->client_capabilites ->
  select count(*) from mysql.event
  was reporting : "Unknown table test.event"!!!
  Using temporal variable is nice but IMO quite error-prone.
parent a581a4a1
This diff is collapsed.
......@@ -40,17 +40,6 @@ extern ulong opt_event_executor;
#define EVENT_EXEC_NO_MORE (1L << 0)
#define EVENT_NOT_USED (1L << 1)
#define SP_OK 0
#define SP_KEY_NOT_FOUND -1
#define SP_OPEN_TABLE_FAILED -2
#define SP_WRITE_ROW_FAILED -3
#define SP_DELETE_ROW_FAILED -4
#define SP_GET_FIELD_FAILED -5
#define SP_PARSE_ERROR -6
#define SP_INTERNAL_ERROR -7
#define SP_NO_DB_ERROR -8
#define SP_BAD_IDENTIFIER -9
#define SP_BODY_TOO_LONG -10
extern ulong opt_event_executor;
......
......@@ -80,8 +80,6 @@ init_events()
event_executor_running_global_var= false;
VOID(pthread_mutex_unlock(&LOCK_evex_running));
DBUG_RETURN(0);
/*
#ifndef DBUG_FAULTY_THR
//TODO Andrey: Change the error code returned!
if (pthread_create(&th, NULL, event_executor_main, (void*)NULL))
......@@ -91,7 +89,6 @@ init_events()
#endif
DBUG_RETURN(0);
*/
}
......@@ -109,7 +106,6 @@ shutdown_events()
DBUG_VOID_RETURN;
}
#ifdef ANDREY_0
static int
init_event_thread(THD* thd)
......@@ -479,13 +475,11 @@ evex_load_events_from_db(THD *thd)
TABLE *table;
READ_RECORD read_record_info;
MYSQL_LOCK *lock;
Open_tables_state open_tables_state_backup;
int ret= -1;
DBUG_ENTER("evex_load_events_from_db");
if (!(table= open_proc_type_table_for_read(thd, &open_tables_state_backup,
"event", &mysql_event_table_exists)))
if (!(table= evex_open_event_table(thd, TL_READ)))
DBUG_RETURN(SP_OPEN_TABLE_FAILED);
VOID(pthread_mutex_lock(&LOCK_event_arrays));
......@@ -541,18 +535,16 @@ evex_load_events_from_db(THD *thd)
end:
close_thread_tables(thd);
thd->restore_backup_open_tables_state(&open_tables_state_backup);
DBUG_PRINT("evex_load_events_from_db",
("Events loaded from DB. Status code %d", ret));
DBUG_RETURN(ret);
}
#endif
bool sys_var_event_executor::update(THD *thd, set_var *var)
{
#ifdef ANDREY_0
// here start the thread if not running.
VOID(pthread_mutex_lock(&LOCK_evex_running));
if ((my_bool) var->save_result.ulong_value && !evex_is_running) {
......@@ -560,7 +552,7 @@ bool sys_var_event_executor::update(THD *thd, set_var *var)
init_events();
} else
VOID(pthread_mutex_unlock(&LOCK_evex_running));
#endif
return sys_var_bool_ptr::update(thd, var);
}
......@@ -322,10 +322,8 @@ event_timed::init_comment(THD *thd, LEX_STRING *comment)
{
DBUG_ENTER("event_timed::init_comment");
MEM_ROOT *root= thd->mem_root;
m_comment.length= comment->length;
m_comment.str= strmake_root(root, comment->str, comment->length);
DBUG_PRINT("m_comment", ("len=%d",m_comment.length));
m_comment.str= strmake_root(thd->mem_root, comment->str,
m_comment.length= comment->length);
DBUG_VOID_RETURN;
}
......@@ -359,6 +357,11 @@ event_timed::init_definer(THD *thd)
SYNOPSIS
event_timed::load_from_row()
REMARKS
This method is silent on errors and should behave like that. Callers
should handle throwing of error messages. The reason is that the class
should not know about how to deal with communication.
*/
int
......
......@@ -4810,7 +4810,7 @@ Disable with --skip-bdb (will save memory).",
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"event-scheduler", OPT_EVENT_EXECUTOR, "Enable/disable the event scheduler.",
(gptr*) &opt_event_executor, (gptr*) &opt_event_executor, 0, GET_BOOL, NO_ARG,
1/*default*/, 0/*min-value*/, 1/*max-value*/, 0, 0, 0},
0/*default*/, 0/*min-value*/, 1/*max-value*/, 0, 0, 0},
{"exit-info", 'T', "Used for debugging; Use at your own risk!", 0, 0, 0,
GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"external-locking", OPT_USE_LOCKING, "Use system (external) locking. With this option enabled you can run myisamchk to test (not repair) tables while the MySQL server is running.",
......
......@@ -5741,3 +5741,9 @@ 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"
......@@ -3689,21 +3689,8 @@ mysql_execute_command(THD *thd)
int result;
uint create_options= lex->create_info.options;
res= (result= evex_create_event(thd, lex->et, create_options));
switch (result) {
case EVEX_OK:
if (result == EVEX_OK)
send_ok(thd, 1);
break;
case EVEX_WRITE_ROW_FAILED:
my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), lex->et->m_name.str);
break;
case EVEX_NO_DB_ERROR:
my_error(ER_BAD_DB_ERROR, MYF(0), lex->et->m_db.str);
break;
default:
//includes EVEX_PARSE_ERROR
my_error(ER_EVENT_STORE_FAILED, MYF(0), lex->et->m_name.str);
break;
}
/* lex->unit.cleanup() is called outside, no need to call it here */
delete lex->et;
lex->et= 0;
......
......@@ -1312,6 +1312,10 @@ create:
Lex->sql_command = SQLCOM_CREATE_USER;
}
| CREATE EVENT_SYM opt_if_not_exists sp_name
/*
BE CAREFUL when you add a new rule to update the block where
YYTHD->client_capabilities is set back to original value
*/
{
LEX *lex=Lex;
......@@ -1351,12 +1355,19 @@ create:
DO_SYM ev_sql_stmt
{
/*
sql_command is set here because some rules in ev_sql_stmt
can overwrite it
Restore flag if it was cleared above
$1 - CREATE
$2 - EVENT_SYM
$3 - opt_if_not_exists
$4 - sp_name
$5 - the block above
*/
// Restore flag if it was cleared above
YYTHD->client_capabilities |= $<ulong_num>5;
/*
sql_command is set here because some rules in ev_sql_stmt
can overwrite it
*/
Lex->sql_command= SQLCOM_CREATE_EVENT;
}
;
......@@ -4192,6 +4203,10 @@ alter:
view_list_opt AS view_select view_check_option
{}
| ALTER EVENT_SYM sp_name
/*
BE CAREFUL when you add a new rule to update the block where
YYTHD->client_capabilities is set back to original value
*/
{
LEX *lex=Lex;
event_timed *et;
......@@ -4233,11 +4248,18 @@ alter:
ev_comment
ev_opt_sql_stmt
{
/*
$1 - ALTER
$2 - EVENT_SYM
$3 - sp_name
$4 - the block above
*/
YYTHD->client_capabilities |= $<ulong_num>4;
/*
sql_command is set here because some rules in ev_sql_stmt
can overwrite it
*/
YYTHD->client_capabilities |= $<ulong_num>3;
Lex->sql_command= SQLCOM_ALTER_EVENT;
}
;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment