Skip to content

Commit 0946128

Browse files
author
kostja@bodhi.local
committed
Trivial cleanups and whitespace change in Event Scheduler code.
A larger patch is to come, this is to exclude rudimentary changes from it.
1 parent f017117 commit 0946128

10 files changed

+65
-86
lines changed

sql/event_data_objects.cc

+11-12
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Event_queue_element_for_exec::~Event_queue_element_for_exec()
8181
8282
RETURN VALUE
8383
Address or NULL in case of error
84-
84+
8585
NOTE
8686
Created on THD's mem_root
8787
*/
@@ -174,7 +174,7 @@ Event_parse_data::init_body(THD *thd)
174174
while (body_begin < body_end)
175175
{
176176

177-
if ((*body_end == '\0') ||
177+
if ((*body_end == '\0') ||
178178
(my_isspace(thd->variables.character_set_client, *body_end)))
179179
{ /* consume NULs and meaningless whitespace */
180180
--body.length;
@@ -186,7 +186,7 @@ Event_parse_data::init_body(THD *thd)
186186
consume closing comments
187187
188188
This is arguably wrong, but it's the best we have until the parser is
189-
changed to be smarter. FIXME PARSER
189+
changed to be smarter. FIXME PARSER
190190
191191
See also the sp_head code, where something like this is done also.
192192
@@ -296,7 +296,7 @@ Event_parse_data::init_execute_at(THD *thd)
296296

297297
if (item_execute_at->fix_fields(thd, &item_execute_at))
298298
goto wrong_value;
299-
299+
300300
/* no starts and/or ends in case of execute_at */
301301
DBUG_PRINT("info", ("starts_null && ends_null should be 1 is %d",
302302
(starts_null && ends_null)));
@@ -702,7 +702,7 @@ Event_basic::load_string_fields(Field **fields, ...)
702702
ret= TRUE;
703703
break;
704704
}
705-
field_value->length= strlen(field_value->str);
705+
field_value->length= strlen(field_value->str);
706706

707707
field_name= (enum enum_events_table_field) va_arg(args, int);
708708
}
@@ -778,7 +778,7 @@ Event_timed::Event_timed():
778778
*/
779779

780780
Event_timed::~Event_timed()
781-
{
781+
{
782782
}
783783

784784

@@ -1382,7 +1382,6 @@ Event_queue_element::compute_next_execution_time()
13821382
DBUG_PRINT("info", ("Dropped: %d", dropped));
13831383
status= Event_queue_element::DISABLED;
13841384
status_changed= TRUE;
1385-
dropped= TRUE;
13861385

13871386
goto ret;
13881387
}
@@ -1574,7 +1573,7 @@ Event_queue_element::mark_last_executed(THD *thd)
15741573

15751574
last_executed= (my_time_t) thd->query_start();
15761575
last_executed_changed= TRUE;
1577-
1576+
15781577
execution_count++;
15791578
}
15801579

@@ -1762,7 +1761,7 @@ Event_timed::get_create_event(THD *thd, String *buf)
17621761
*/
17631762

17641763
int
1765-
Event_job_data::get_fake_create_event(THD *thd, String *buf)
1764+
Event_job_data::get_fake_create_event(String *buf)
17661765
{
17671766
DBUG_ENTER("Event_job_data::get_create_event");
17681767
/* FIXME: "EVERY 3337 HOUR" is asking for trouble. */
@@ -1853,7 +1852,7 @@ Event_job_data::execute(THD *thd)
18531852
RETURN VALUE
18541853
0 success
18551854
EVEX_COMPILE_ERROR error during compilation
1856-
EVEX_MICROSECOND_UNSUP mysql.event was tampered
1855+
EVEX_MICROSECOND_UNSUP mysql.event was tampered
18571856
*/
18581857

18591858
int
@@ -1878,7 +1877,7 @@ Event_job_data::compile(THD *thd, MEM_ROOT *mem_root)
18781877

18791878
show_create.length(0);
18801879

1881-
switch (get_fake_create_event(thd, &show_create)) {
1880+
switch (get_fake_create_event(&show_create)) {
18821881
case EVEX_MICROSECOND_UNSUP:
18831882
DBUG_RETURN(EVEX_MICROSECOND_UNSUP);
18841883
case 0:
@@ -2043,7 +2042,7 @@ event_change_security_context(THD *thd, LEX_STRING user, LEX_STRING host,
20432042
thd->security_ctx= &thd->main_security_ctx;
20442043
#endif
20452044
DBUG_RETURN(FALSE);
2046-
}
2045+
}
20472046

20482047

20492048
/*

sql/event_data_objects.h

+1-19
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,6 @@ class Event_queue_element : public Event_basic
127127

128128
bool
129129
update_timing_fields(THD *thd);
130-
131-
static void *operator new(size_t size)
132-
{
133-
void *p;
134-
DBUG_ENTER("Event_queue_element::new(size)");
135-
p= my_malloc(size, MYF(0));
136-
DBUG_PRINT("info", ("alloc_ptr: 0x%lx", (long) p));
137-
DBUG_RETURN(p);
138-
}
139-
140-
static void operator delete(void *ptr, size_t size)
141-
{
142-
DBUG_ENTER("Event_queue_element::delete(ptr,size)");
143-
DBUG_PRINT("enter", ("free_ptr: 0x%lx", (long) ptr));
144-
TRASH(ptr, size);
145-
my_free((gptr) ptr, MYF(0));
146-
DBUG_VOID_RETURN;
147-
}
148130
};
149131

150132

@@ -206,7 +188,7 @@ class Event_job_data : public Event_basic
206188
compile(THD *thd, MEM_ROOT *mem_root);
207189
private:
208190
int
209-
get_fake_create_event(THD *thd, String *buf);
191+
get_fake_create_event(String *buf);
210192

211193
Event_job_data(const Event_job_data &); /* Prevent use of these */
212194
void operator=(Event_job_data &);

sql/event_db_repository.cc

+12-12
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const TABLE_FIELD_W_TYPE event_table_fields[ET_FIELD_COUNT] =
142142
EVEX_GENERAL_ERROR Bad data
143143
EVEX_GET_FIELD_FAILED Field count does not match. table corrupted?
144144
145-
DESCRIPTION
145+
DESCRIPTION
146146
Used both when an event is created and when it is altered.
147147
*/
148148

@@ -178,7 +178,7 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
178178
/*
179179
Change the SQL_MODE only if body was present in an ALTER EVENT and of course
180180
always during CREATE EVENT.
181-
*/
181+
*/
182182
if (et->body.str)
183183
{
184184
fields[ET_FIELD_SQL_MODE]->store((longlong)thd->variables.sql_mode, TRUE);
@@ -237,7 +237,7 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
237237
fields[ET_FIELD_TRANSIENT_INTERVAL]->set_null();
238238
fields[ET_FIELD_STARTS]->set_null();
239239
fields[ET_FIELD_ENDS]->set_null();
240-
240+
241241
TIME time;
242242
my_tz_UTC->gmt_sec_to_TIME(&time, et->execute_at);
243243

@@ -253,7 +253,7 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
253253
this is an error if the action is create. something is borked
254254
*/
255255
}
256-
256+
257257
((Field_timestamp *)fields[ET_FIELD_MODIFIED])->set_time();
258258

259259
if (et->comment.str)
@@ -323,12 +323,12 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table,
323323
ret= copy_event_to_schema_table(thd, schema_table, event_table);
324324
if (ret == 0)
325325
ret= event_table->file->index_next_same(event_table->record[0],
326-
key_buf, key_len);
326+
key_buf, key_len);
327327
} while (ret == 0);
328328
}
329329
DBUG_PRINT("info", ("Scan finished. ret=%d", ret));
330330
}
331-
event_table->file->ha_index_end();
331+
event_table->file->ha_index_end();
332332
/* ret is guaranteed to be != 0 */
333333
if (ret == HA_ERR_END_OF_FILE || ret == HA_ERR_KEY_NOT_FOUND)
334334
DBUG_RETURN(FALSE);
@@ -489,7 +489,7 @@ Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type,
489489
check_parse_params()
490490
thd Thread context
491491
parse_data Event's data
492-
492+
493493
RETURN VALUE
494494
FALSE OK
495495
TRUE Error (reported)
@@ -535,7 +535,7 @@ check_parse_params(THD *thd, Event_parse_data *parse_data)
535535
0 OK
536536
EVEX_GENERAL_ERROR Failure
537537
538-
DESCRIPTION
538+
DESCRIPTION
539539
Creates an event. Relies on mysql_event_fill_row which is shared with
540540
::update_event. The name of the event is inside "et".
541541
*/
@@ -630,7 +630,7 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
630630
handle it here
631631
*/
632632
if ((ret= mysql_event_fill_row(thd, table, parse_data, FALSE)))
633-
goto err;
633+
goto err;
634634

635635
/* Close active transaction only if We are going to modify disk */
636636
if (end_active_trans(thd))
@@ -647,7 +647,7 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
647647
(void) mysql_change_db(thd, old_db.str, 1);
648648
/*
649649
This statement may cause a spooky valgrind warning at startup
650-
inside init_key_cache on my system (ahristov, 2006/08/10)
650+
inside init_key_cache on my system (ahristov, 2006/08/10)
651651
*/
652652
close_thread_tables(thd);
653653
DBUG_RETURN(FALSE);
@@ -914,14 +914,14 @@ Event_db_repository::drop_schema_events(THD *thd, LEX_STRING schema)
914914
*/
915915

916916
void
917-
Event_db_repository::drop_events_by_field(THD *thd,
917+
Event_db_repository::drop_events_by_field(THD *thd,
918918
enum enum_events_table_field field,
919919
LEX_STRING field_value)
920920
{
921921
int ret= 0;
922922
TABLE *table= NULL;
923923
READ_RECORD read_record_info;
924-
DBUG_ENTER("Event_db_repository::drop_events_by_field");
924+
DBUG_ENTER("Event_db_repository::drop_events_by_field");
925925
DBUG_PRINT("enter", ("field=%d field_value=%s", field, field_value.str));
926926

927927
if (open_event_table(thd, TL_WRITE, &table))

sql/event_db_repository.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Event_db_repository
6262
update_event(THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname,
6363
LEX_STRING *new_name);
6464

65-
bool
65+
bool
6666
drop_event(THD *thd, LEX_STRING db, LEX_STRING name, bool drop_if_exists);
6767

6868
void
@@ -98,5 +98,5 @@ class Event_db_repository
9898
Event_db_repository(const Event_db_repository &);
9999
void operator=(Event_db_repository &);
100100
};
101-
101+
102102
#endif /* _EVENT_DB_REPOSITORY_H_ */

sql/event_queue.cc

+7-17
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@
3232
#define LOCK_QUEUE_DATA() lock_data(SCHED_FUNC, __LINE__)
3333
#define UNLOCK_QUEUE_DATA() unlock_data(SCHED_FUNC, __LINE__)
3434

35-
struct event_queue_param
36-
{
37-
THD *thd;
38-
Event_queue *queue;
39-
pthread_mutex_t LOCK_loaded;
40-
pthread_cond_t COND_loaded;
41-
bool loading_finished;
42-
};
43-
44-
4535
/*
4636
Compares the execute_at members of two Event_queue_element instances.
4737
Used as callback for the prioritized queue when shifting
@@ -62,7 +52,7 @@ struct event_queue_param
6252
execute_at.second_part is not considered during comparison
6353
*/
6454

65-
static int
55+
static int
6656
event_queue_element_compare_q(void *vptr, byte* a, byte *b)
6757
{
6858
my_time_t lhs = ((Event_queue_element *)a)->execute_at;
@@ -183,7 +173,7 @@ Event_queue::deinit_queue()
183173
}
184174

185175

186-
/*
176+
/**
187177
Adds an event to the queue.
188178
189179
SYNOPSIS
@@ -209,7 +199,7 @@ Event_queue::create_event(THD *thd, Event_queue_element *new_element)
209199
LOCK_QUEUE_DATA();
210200
queue_insert_safe(&queue, (byte *) new_element);
211201
dbug_dump_queue(thd->query_start());
212-
pthread_cond_broadcast(&COND_queue_state);
202+
pthread_cond_broadcast(&COND_queue_state);
213203
UNLOCK_QUEUE_DATA();
214204
}
215205
DBUG_VOID_RETURN;
@@ -256,7 +246,7 @@ Event_queue::update_event(THD *thd, LEX_STRING dbname, LEX_STRING name,
256246
{
257247
DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element));
258248
queue_insert_safe(&queue, (byte *) new_element);
259-
pthread_cond_broadcast(&COND_queue_state);
249+
pthread_cond_broadcast(&COND_queue_state);
260250
}
261251

262252
dbug_dump_queue(thd->query_start());
@@ -287,7 +277,7 @@ Event_queue::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name)
287277
find_n_remove_event(dbname, name);
288278
dbug_dump_queue(thd->query_start());
289279
UNLOCK_QUEUE_DATA();
290-
280+
291281
/*
292282
We don't signal here because the scheduler will catch the change
293283
next time it wakes up.
@@ -309,7 +299,7 @@ Event_queue::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name)
309299
310300
RETURN VALUE
311301
>=0 Number of dropped events
312-
302+
313303
NOTE
314304
Expected is the caller to acquire lock on LOCK_event_queue
315305
*/
@@ -341,7 +331,7 @@ Event_queue::drop_matching_events(THD *thd, LEX_STRING pattern,
341331
i++;
342332
}
343333
/*
344-
We don't call pthread_cond_broadcast(&COND_queue_state);
334+
We don't call pthread_cond_broadcast(&COND_queue_state);
345335
If we remove the top event:
346336
1. The queue is empty. The scheduler will wake up at some time and
347337
realize that the queue is empty. If create_event() comes inbetween

sql/event_queue.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Event_queue
3434

3535
bool
3636
init_queue(THD *thd);
37-
37+
3838
void
3939
deinit_queue();
4040

0 commit comments

Comments
 (0)