Commit 3d854641 authored by andrey@lmy004's avatar andrey@lmy004

WL #1034 updates after review

(strip m_ as prefix from member variables' names)
parent b7578df0
This diff is collapsed.
/* Copyright (C) 2000-2003 MySQL AB
/* 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
......@@ -63,41 +63,45 @@ class event_timed
my_bool running;
pthread_mutex_t LOCK_running;
bool status_changed;
bool last_executed_changed;
TIME last_executed;
public:
LEX_STRING m_db;
LEX_STRING m_name;
LEX_STRING m_body;
LEX_STRING m_definer_user;
LEX_STRING m_definer_host;
LEX_STRING m_definer;// combination of user and host
LEX_STRING m_comment;
TIME m_starts;
TIME m_ends;
TIME m_execute_at;
longlong m_expr;
interval_type m_interval;
longlong m_created;
longlong m_modified;
TIME m_last_executed;
enum enum_event_on_completion m_on_completion;
enum enum_event_status m_status;
sp_head *m_sphead;
const uchar *m_body_begin;
bool m_dropped;
bool m_free_sphead_on_delete;
uint m_flags;//all kind of purposes
bool m_last_executed_changed;
bool m_status_changed;
event_timed():running(0), m_expr(0), m_created(0), m_modified(0),
m_on_completion(MYSQL_EVENT_ON_COMPLETION_DROP),
m_status(MYSQL_EVENT_ENABLED), m_sphead(0), m_dropped(false),
m_free_sphead_on_delete(true), m_flags(0),
m_last_executed_changed(false), m_status_changed(false)
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;
longlong expression;
interval_type interval;
longlong created;
longlong modified;
enum enum_event_on_completion on_completion;
enum enum_event_status status;
sp_head *sphead;
const uchar *body_begin;
bool dropped;
bool free_sphead_on_delete;
uint flags;//all kind of purposes
event_timed():running(0), status_changed(false), last_executed_changed(false),
expression(0), created(0), modified(0),
on_completion(MYSQL_EVENT_ON_COMPLETION_DROP),
status(MYSQL_EVENT_ENABLED), sphead(0), dropped(false),
free_sphead_on_delete(true), flags(0)
{
pthread_mutex_init(&LOCK_running, MY_MUTEX_INIT_FAST);
init();
......@@ -106,7 +110,7 @@ public:
~event_timed()
{
pthread_mutex_destroy(&LOCK_running);
if (m_free_sphead_on_delete)
if (free_sphead_on_delete)
free_sp();
}
......@@ -120,10 +124,10 @@ public:
init_execute_at(THD *thd, Item *expr);
int
init_interval(THD *thd, Item *expr, interval_type interval);
init_interval(THD *thd, Item *expr, interval_type new_interval);
void
init_name(THD *thd, sp_name *name);
init_name(THD *thd, sp_name *spn);
int
init_starts(THD *thd, Item *starts);
......@@ -135,7 +139,7 @@ public:
event_timed::init_body(THD *thd);
void
init_comment(THD *thd, LEX_STRING *comment);
init_comment(THD *thd, LEX_STRING *set_comment);
int
load_from_row(MEM_ROOT *mem_root, TABLE *table);
......@@ -163,11 +167,8 @@ public:
void free_sp()
{
if (m_sphead)
{
delete m_sphead;
m_sphead= 0;
}
delete sphead;
sphead= 0;
}
};
......@@ -176,7 +177,7 @@ int
evex_create_event(THD *thd, event_timed *et, uint create_options);
int
evex_update_event(THD *thd, sp_name *name, event_timed *et);
evex_update_event(THD *thd, event_timed *et, sp_name *new_name);
int
evex_drop_event(THD *thd, event_timed *et, bool drop_if_exists);
......
/* Copyright (C) 2000-2003 MySQL AB
/* 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
......@@ -226,7 +226,7 @@ event_executor_main(void *arg)
for (i= 0; (i < evex_executing_queue.elements) && !thd->killed; ++i)
{
event_timed *et= *dynamic_element(&evex_executing_queue,i,event_timed**);
// printf("%llu\n", TIME_to_ulonglong_datetime(&et->m_execute_at));
// printf("%llu\n", TIME_to_ulonglong_datetime(&et->execute_at));
if (!event_executor_running_global_var)
break;
......@@ -236,13 +236,13 @@ event_executor_main(void *arg)
if this is the first event which is after time_now then no
more need to iterate over more elements since the array is sorted.
*/
if (et->m_execute_at.year > 1969 &&
my_time_compare(&time_now, &et->m_execute_at) == -1)
if (et->execute_at.year > 1969 &&
my_time_compare(&time_now, &et->execute_at) == -1)
break;
if (et->m_status == MYSQL_EVENT_ENABLED &&
!check_access(thd, EVENT_ACL, et->m_db.str, 0, 0, 0,
is_schema_db(et->m_db.str)))
if (et->status == MYSQL_EVENT_ENABLED &&
!check_access(thd, EVENT_ACL, et->dbname.str, 0, 0, 0,
is_schema_db(et->dbname.str)))
{
pthread_t th;
......@@ -262,9 +262,9 @@ event_executor_main(void *arg)
thd->proc_info = "Computing next time";
et->compute_next_execution_time();
et->update_fields(thd);
if ((et->m_execute_at.year && !et->m_expr)
|| TIME_to_ulonglong_datetime(&et->m_execute_at) == 0L)
et->m_flags |= EVENT_EXEC_NO_MORE;
if ((et->execute_at.year && !et->expression)
|| TIME_to_ulonglong_datetime(&et->execute_at) == 0L)
et->flags |= EVENT_EXEC_NO_MORE;
}
}
/*
......@@ -275,13 +275,13 @@ event_executor_main(void *arg)
while (j < i && j < evex_executing_queue.elements)
{
event_timed *et= *dynamic_element(&evex_executing_queue, j, event_timed**);
if (et->m_flags & EVENT_EXEC_NO_MORE || et->m_status == MYSQL_EVENT_DISABLED)
if ((et->flags & EVENT_EXEC_NO_MORE) || et->status == MYSQL_EVENT_DISABLED)
{
delete_dynamic_element(&evex_executing_queue, j);
DBUG_PRINT("EVEX main thread", ("DELETING FROM EXECUTION QUEUE [%s.%s]",
et->m_db.str, et->m_name.str));
et->dbname.str, et->name.str));
// nulling the position, will delete later
if (et->m_dropped)
if (et->dropped)
{
// we have to drop the event
int idx;
......@@ -311,7 +311,7 @@ err:
evex_is_running= false;
VOID(pthread_mutex_unlock(&LOCK_evex_running));
sql_print_information("Event executor stopping");
sql_print_information("Event scheduler stopping");
/*
TODO: A better will be with a conditional variable
......@@ -334,7 +334,7 @@ err:
// No need to use lock here if EVEX is not running but anyway
delete_dynamic(&evex_executing_queue);
delete_dynamic(&events_array);
VOID(pthread_mutex_unlock(&LOCK_evex_running));
VOID(pthread_mutex_unlock(&LOCK_event_arrays));
thd->proc_info = "Clearing";
DBUG_ASSERT(thd->net.buff != 0);
......@@ -355,7 +355,7 @@ err_no_thd:
VOID(pthread_mutex_unlock(&LOCK_evex_running));
free_root(&evex_mem_root, MYF(0));
sql_print_information("Event executor stopped");
sql_print_information("Event scheduler stopped");
my_thread_end();
pthread_exit(0);
......@@ -381,7 +381,7 @@ event_executor_worker(void *event_void)
if (!(thd = new THD)) // note that contructor of THD uses DBUG_ !
{
sql_print_error("Cannot create a THD structure in worker thread");
sql_print_error("Cannot create a THD structure in a scheduler worker thread");
goto err_no_thd;
}
thd->thread_stack = (char*)&thd; // remember where our stack is
......@@ -406,20 +406,20 @@ event_executor_worker(void *event_void)
// thd->security_ctx->priv_host is char[MAX_HOSTNAME]
strxnmov(thd->security_ctx->priv_host, sizeof(thd->security_ctx->priv_host),
event->m_definer_host.str, NullS);
event->definer_host.str, NullS);
thd->security_ctx->priv_user= event->m_definer_user.str;
thd->security_ctx->priv_user= event->definer_user.str;
thd->db= event->m_db.str;
thd->db= event->dbname.str;
{
char exec_time[200];
int ret;
my_TIME_to_str(&event->m_execute_at, exec_time);
DBUG_PRINT("info", (" EVEX EXECUTING event for event %s.%s [EXPR:%d][EXECUTE_AT:%s]", event->m_db.str, event->m_name.str,(int) event->m_expr, exec_time));
sql_print_information(" EVEX EXECUTING event for event %s.%s [EXPR:%d][EXECUTE_AT:%s]", event->m_db.str, event->m_name.str,(int) event->m_expr, exec_time);
my_TIME_to_str(&event->execute_at, exec_time);
DBUG_PRINT("info", (" EVEX EXECUTING event for event %s.%s [EXPR:%d][EXECUTE_AT:%s]", event->dbname.str, event->name.str,(int) event->expression, exec_time));
sql_print_information(" EVEX EXECUTING event for event %s.%s [EXPR:%d][EXECUTE_AT:%s]", event->dbname.str, event->name.str,(int) event->expression, exec_time);
ret= event->execute(thd, &worker_mem_root);
sql_print_information(" EVEX EXECUTED event for event %s.%s [EXPR:%d][EXECUTE_AT:%s]. RetCode=%d", event->m_db.str, event->m_name.str,(int) event->m_expr, exec_time, ret);
DBUG_PRINT("info", (" EVEX EXECUTED event for event %s.%s [EXPR:%d][EXECUTE_AT:%s]", event->m_db.str, event->m_name.str,(int) event->m_expr, exec_time));
sql_print_information(" EVEX EXECUTED event for event %s.%s [EXPR:%d][EXECUTE_AT:%s]. RetCode=%d", event->dbname.str, event->name.str,(int) event->expression, exec_time, ret);
DBUG_PRINT("info", (" EVEX EXECUTED event for event %s.%s [EXPR:%d][EXECUTE_AT:%s]", event->dbname.str, event->name.str,(int) event->expression, exec_time));
}
thd->db= 0;
......@@ -495,19 +495,19 @@ evex_load_events_from_db(THD *thd)
}
DBUG_PRINT("evex_load_events_from_db",
("Event %s loaded from row. Time to compile", et->m_name.str));
("Event %s loaded from row. Time to compile", et->name.str));
if ((ret= et->compile(thd, &evex_mem_root)))
{
sql_print_error("Error while compiling %s.%s. Aborting load.",
et->m_db.str, et->m_name.str);
et->dbname.str, et->name.str);
goto end;
}
// let's find when to be executed
et->compute_next_execution_time();
DBUG_PRINT("evex_load_events_from_db",
("Adding %s to the executor list.", et->m_name.str));
("Adding %s to the executor list.", et->name.str));
VOID(push_dynamic(&events_array,(gptr) et));
/*
We always add at the end so the number of elements - 1 is the place
......@@ -518,7 +518,7 @@ evex_load_events_from_db(THD *thd)
et_copy= dynamic_element(&events_array, events_array.elements - 1,
event_timed*);
VOID(push_dynamic(&evex_executing_queue,(gptr) &et_copy));
et->m_free_sphead_on_delete= false;
et->free_sphead_on_delete= false;
delete et;
}
end_read_record(&read_record_info);
......
/* Copyright (C) 2000-2003 MySQL AB
/* 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
......
This diff is collapsed.
......@@ -3676,26 +3676,25 @@ end_with_restore_list:
case SQLCOM_CREATE_EVENT:
{
DBUG_ASSERT(lex->et);
if (! lex->et->m_db.str)
if (! lex->et->dbname.str)
{
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
delete lex->et;
lex->et= 0;
goto error;
}
if (check_access(thd, EVENT_ACL, lex->et->m_db.str, 0, 0, 0,
is_schema_db(lex->et->m_db.str)))
if (check_access(thd, EVENT_ACL, lex->et->dbname.str, 0, 0, 0,
is_schema_db(lex->et->dbname.str)))
break;
int result;
uint create_options= lex->create_info.options;
res= (result= evex_create_event(thd, lex->et, create_options));
if (result == EVEX_OK)
if (!(res= evex_create_event(thd, lex->et, (uint) lex->create_info.options)))
send_ok(thd, 1);
/* lex->unit.cleanup() is called outside, no need to call it here */
delete lex->et;
lex->et= 0;
delete lex->sphead;
lex->et= 0;
lex->sphead= 0;
break;
......@@ -3703,53 +3702,50 @@ end_with_restore_list:
case SQLCOM_ALTER_EVENT:
{
DBUG_ASSERT(lex->et);
if (! lex->et->m_db.str)
if (! lex->et->dbname.str)
{
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
delete lex->et;
lex->et= 0;
goto error;
}
if (check_access(thd, EVENT_ACL, lex->et->m_db.str, 0, 0, 0,
is_schema_db(lex->et->m_db.str)))
if (check_access(thd, EVENT_ACL, lex->et->dbname.str, 0, 0, 0,
is_schema_db(lex->et->dbname.str)))
break;
int result;
res= (result= evex_update_event(thd, lex->spname, lex->et));
res= (result= evex_update_event(thd, lex->et, lex->spname));
switch (result) {
case EVEX_OK:
send_ok(thd, 1);
break;
case EVEX_KEY_NOT_FOUND:
my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), lex->et->m_name.str);
my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), lex->et->name.str);
break;
default:
my_error(ER_EVENT_CANT_ALTER, MYF(0), lex->et->m_name.str);
my_error(ER_EVENT_CANT_ALTER, MYF(0), lex->et->name.str);
break;
}
/* lex->unit.cleanup() is called outside, no need to call it here */
delete lex->et;
lex->et= 0;
if (lex->sphead)
{
delete lex->sphead;
lex->et= 0;
lex->sphead= 0;
}
break;
}
case SQLCOM_DROP_EVENT:
{
DBUG_ASSERT(lex->et);
if (! lex->et->m_db.str)
if (! lex->et->dbname.str)
{
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
delete lex->et;
lex->et= 0;
goto error;
}
if (check_access(thd, EVENT_ACL, lex->et->m_db.str, 0, 0, 0,
is_schema_db(lex->et->m_db.str)))
if (check_access(thd, EVENT_ACL, lex->et->dbname.str, 0, 0, 0,
is_schema_db(lex->et->dbname.str)))
break;
int result;
......@@ -3759,10 +3755,10 @@ end_with_restore_list:
send_ok(thd, 1);
break;
case EVEX_KEY_NOT_FOUND:
my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), lex->et->m_name.str);
my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), lex->et->name.str);
break;
default:
my_error(ER_EVENT_DROP_FAILED, MYF(0), lex->et->m_name.str);
my_error(ER_EVENT_DROP_FAILED, MYF(0), lex->et->name.str);
break;
}
delete lex->et;
......
......@@ -1415,14 +1415,14 @@ ev_status: /* empty */
{
LEX *lex=Lex;
if (!lex->et_compile_phase)
lex->et->m_status= MYSQL_EVENT_ENABLED;
lex->et->status= MYSQL_EVENT_ENABLED;
}
| DISABLE_SYM
{
LEX *lex=Lex;
if (!lex->et_compile_phase)
lex->et->m_status= MYSQL_EVENT_DISABLED;
lex->et->status= MYSQL_EVENT_DISABLED;
}
;
ev_starts: /* empty */
......@@ -1457,13 +1457,13 @@ ev_on_completion: /* empty */
{
LEX *lex=Lex;
if (!lex->et_compile_phase)
lex->et->m_on_completion= MYSQL_EVENT_ON_COMPLETION_PRESERVE;
lex->et->on_completion= MYSQL_EVENT_ON_COMPLETION_PRESERVE;
}
| ON COMPLETION_SYM NOT_SYM PRESERVE_SYM
{
LEX *lex=Lex;
if (!lex->et_compile_phase)
lex->et->m_on_completion= MYSQL_EVENT_ON_COMPLETION_DROP;
lex->et->on_completion= MYSQL_EVENT_ON_COMPLETION_DROP;
}
;
ev_comment: /* empty */
......@@ -1497,7 +1497,7 @@ ev_sql_stmt:
lex->sphead->m_body_begin= lex->ptr;
if (!lex->et_compile_phase)
lex->et->m_body_begin= lex->ptr;
lex->et->body_begin= lex->ptr;
}
ev_sql_stmt_inner
{
......
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