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