Skip to content

Commit f8be48b

Browse files
author
anozdrin/alik@ibm.
committed
This is the 3-rd part of patch for BUG#11986:
remove redundant "body" from Event_parse_data (use sp_head::m_body).
1 parent 1ff9121 commit f8be48b

4 files changed

Lines changed: 82 additions & 122 deletions

File tree

sql/event_data_objects.cc

Lines changed: 55 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,18 @@ Event_parse_data::Event_parse_data()
9494
:on_completion(Event_basic::ON_COMPLETION_DROP),
9595
status(Event_basic::ENABLED),
9696
do_not_create(FALSE),
97-
item_starts(NULL), item_ends(NULL), item_execute_at(NULL),
98-
starts_null(TRUE), ends_null(TRUE), execute_at_null(TRUE),
99-
item_expression(NULL), expression(0)
97+
body_changed(FALSE),
98+
item_starts(NULL), item_ends(NULL), item_execute_at(NULL),
99+
starts_null(TRUE), ends_null(TRUE), execute_at_null(TRUE),
100+
item_expression(NULL), expression(0)
100101
{
101102
DBUG_ENTER("Event_parse_data::Event_parse_data");
102103

103104
/* Actually in the parser STARTS is always set */
104105
starts= ends= execute_at= 0;
105106

106-
body.str= comment.str= NULL;
107-
body.length= comment.length= 0;
107+
comment.str= NULL;
108+
comment.length= 0;
108109

109110
DBUG_VOID_RETURN;
110111
}
@@ -137,36 +138,6 @@ Event_parse_data::init_name(THD *thd, sp_name *spn)
137138
}
138139

139140

140-
/*
141-
Set body of the event - what should be executed.
142-
143-
SYNOPSIS
144-
Event_parse_data::init_body()
145-
thd THD
146-
147-
NOTE
148-
The body is extracted by copying all data between the
149-
start of the body set by another method and the current pointer in Lex.
150-
151-
See related code in sp_head::init_strings().
152-
*/
153-
154-
void
155-
Event_parse_data::init_body(THD *thd)
156-
{
157-
DBUG_ENTER("Event_parse_data::init_body");
158-
159-
/* This method is called from within the parser, from sql_yacc.yy */
160-
DBUG_ASSERT(thd->m_lip != NULL);
161-
162-
body.length= thd->m_lip->get_cpp_ptr() - body_begin;
163-
body.str= thd->strmake(body_begin, body.length);
164-
trim_whitespace(thd->charset(), & body);
165-
166-
DBUG_VOID_RETURN;
167-
}
168-
169-
170141
/*
171142
This function is called on CREATE EVENT or ALTER EVENT. When either
172143
ENDS or AT is in the past, we are trying to create an event that
@@ -788,47 +759,43 @@ Event_timed::init()
788759
}
789760

790761

791-
/*
792-
Loads an event's body from a row from mysql.event
793-
794-
SYNOPSIS
795-
Event_job_data::load_from_row(THD *thd, TABLE *table)
796-
797-
RETURN VALUE
798-
0 OK
799-
EVEX_GET_FIELD_FAILED Error
800-
801-
NOTES
802-
This method is silent on errors and should behave like that. Callers
803-
should handle throwing of error messages. The reason is that the class
804-
should not know about how to deal with communication.
762+
/**
763+
Load an event's body from a row from mysql.event.
764+
@details This method is silent on errors and should behave like that.
765+
Callers should handle throwing of error messages. The reason is that the
766+
class should not know about how to deal with communication.
767+
768+
@return Operation status
769+
@retval FALSE OK
770+
@retval TRUE Error
805771
*/
806772

807-
int
773+
bool
808774
Event_job_data::load_from_row(THD *thd, TABLE *table)
809775
{
810776
char *ptr;
811777
uint len;
778+
LEX_STRING tz_name;
779+
812780
DBUG_ENTER("Event_job_data::load_from_row");
813781

814782
if (!table)
815-
goto error;
783+
DBUG_RETURN(TRUE);
816784

817785
if (table->s->fields < ET_FIELD_COUNT)
818-
goto error;
786+
DBUG_RETURN(TRUE);
819787

820-
LEX_STRING tz_name;
821788
if (load_string_fields(table->field,
822789
ET_FIELD_DB, &dbname,
823790
ET_FIELD_NAME, &name,
824791
ET_FIELD_BODY, &body,
825792
ET_FIELD_DEFINER, &definer,
826793
ET_FIELD_TIME_ZONE, &tz_name,
827794
ET_FIELD_COUNT))
828-
goto error;
795+
DBUG_RETURN(TRUE);
829796

830797
if (load_time_zone(thd, tz_name))
831-
goto error;
798+
DBUG_RETURN(TRUE);
832799

833800
ptr= strchr(definer.str, '@');
834801

@@ -845,29 +812,23 @@ Event_job_data::load_from_row(THD *thd, TABLE *table)
845812

846813
sql_mode= (ulong) table->field[ET_FIELD_SQL_MODE]->val_int();
847814

848-
DBUG_RETURN(0);
849-
error:
850-
DBUG_RETURN(EVEX_GET_FIELD_FAILED);
815+
DBUG_RETURN(FALSE);
851816
}
852817

853818

854-
/*
855-
Loads an event from a row from mysql.event
856-
857-
SYNOPSIS
858-
Event_queue_element::load_from_row(THD *thd, TABLE *table)
819+
/**
820+
Load an event's body from a row from mysql.event.
859821
860-
RETURN VALUE
861-
0 OK
862-
EVEX_GET_FIELD_FAILED Error
822+
@details This method is silent on errors and should behave like that.
823+
Callers should handle throwing of error messages. The reason is that the
824+
class should not know about how to deal with communication.
863825
864-
NOTES
865-
This method is silent on errors and should behave like that. Callers
866-
should handle throwing of error messages. The reason is that the class
867-
should not know about how to deal with communication.
826+
@return Operation status
827+
@retval FALSE OK
828+
@retval TRUE Error
868829
*/
869830

870-
int
831+
bool
871832
Event_queue_element::load_from_row(THD *thd, TABLE *table)
872833
{
873834
char *ptr;
@@ -877,21 +838,21 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
877838
DBUG_ENTER("Event_queue_element::load_from_row");
878839

879840
if (!table)
880-
goto error;
841+
DBUG_RETURN(TRUE);
881842

882843
if (table->s->fields < ET_FIELD_COUNT)
883-
goto error;
844+
DBUG_RETURN(TRUE);
884845

885846
if (load_string_fields(table->field,
886847
ET_FIELD_DB, &dbname,
887848
ET_FIELD_NAME, &name,
888849
ET_FIELD_DEFINER, &definer,
889850
ET_FIELD_TIME_ZONE, &tz_name,
890851
ET_FIELD_COUNT))
891-
goto error;
852+
DBUG_RETURN(TRUE);
892853

893854
if (load_time_zone(thd, tz_name))
894-
goto error;
855+
DBUG_RETURN(TRUE);
895856

896857
starts_null= table->field[ET_FIELD_STARTS]->is_null();
897858
if (!starts_null)
@@ -921,7 +882,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
921882
{
922883
if (table->field[ET_FIELD_EXECUTE_AT]->get_date(&time,
923884
TIME_NO_ZERO_DATE))
924-
goto error;
885+
DBUG_RETURN(TRUE);
925886
execute_at= sec_since_epoch_TIME(&time);
926887
}
927888

@@ -940,13 +901,13 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
940901

941902
table->field[ET_FIELD_TRANSIENT_INTERVAL]->val_str(&str);
942903
if (!(tmp.length= str.length()))
943-
goto error;
904+
DBUG_RETURN(TRUE);
944905

945906
tmp.str= str.c_ptr_safe();
946907

947908
i= find_string_in_array(interval_type_to_name, &tmp, system_charset_info);
948909
if (i < 0)
949-
goto error;
910+
DBUG_RETURN(TRUE);
950911
interval= (interval_type) i;
951912
}
952913

@@ -959,7 +920,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
959920
last_executed_changed= FALSE;
960921

961922
if ((ptr= get_field(&mem_root, table->field[ET_FIELD_STATUS])) == NullS)
962-
goto error;
923+
DBUG_RETURN(TRUE);
963924

964925
DBUG_PRINT("load_from_row", ("Event [%s] is [%s]", name.str, ptr));
965926

@@ -978,40 +939,34 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
978939
break;
979940
}
980941
if ((ptr= get_field(&mem_root, table->field[ET_FIELD_ORIGINATOR])) == NullS)
981-
goto error;
942+
DBUG_RETURN(TRUE);
982943
originator = table->field[ET_FIELD_ORIGINATOR]->val_int();
983944

984945
/* ToDo : Andrey . Find a way not to allocate ptr on event_mem_root */
985946
if ((ptr= get_field(&mem_root,
986947
table->field[ET_FIELD_ON_COMPLETION])) == NullS)
987-
goto error;
948+
DBUG_RETURN(TRUE);
988949

989950
on_completion= (ptr[0]=='D'? Event_queue_element::ON_COMPLETION_DROP:
990951
Event_queue_element::ON_COMPLETION_PRESERVE);
991952

992-
DBUG_RETURN(0);
993-
error:
994-
DBUG_RETURN(EVEX_GET_FIELD_FAILED);
953+
DBUG_RETURN(FALSE);
995954
}
996955

997956

998-
/*
999-
Loads an event from a row from mysql.event
1000-
1001-
SYNOPSIS
1002-
Event_timed::load_from_row(THD *thd, TABLE *table)
957+
/**
958+
Load an event's body from a row from mysql.event.
1003959
1004-
RETURN VALUE
1005-
0 OK
1006-
EVEX_GET_FIELD_FAILED Error
960+
@details This method is silent on errors and should behave like that.
961+
Callers should handle throwing of error messages. The reason is that the
962+
class should not know about how to deal with communication.
1007963
1008-
NOTES
1009-
This method is silent on errors and should behave like that. Callers
1010-
should handle throwing of error messages. The reason is that the class
1011-
should not know about how to deal with communication.
964+
@return Operation status
965+
@retval FALSE OK
966+
@retval TRUE Error
1012967
*/
1013968

1014-
int
969+
bool
1015970
Event_timed::load_from_row(THD *thd, TABLE *table)
1016971
{
1017972
char *ptr;
@@ -1020,12 +975,12 @@ Event_timed::load_from_row(THD *thd, TABLE *table)
1020975
DBUG_ENTER("Event_timed::load_from_row");
1021976

1022977
if (Event_queue_element::load_from_row(thd, table))
1023-
goto error;
978+
DBUG_RETURN(TRUE);
1024979

1025980
if (load_string_fields(table->field,
1026981
ET_FIELD_BODY, &body,
1027982
ET_FIELD_COUNT))
1028-
goto error;
983+
DBUG_RETURN(TRUE);
1029984

1030985

1031986
ptr= strchr(definer.str, '@');
@@ -1052,9 +1007,7 @@ Event_timed::load_from_row(THD *thd, TABLE *table)
10521007

10531008
sql_mode= (ulong) table->field[ET_FIELD_SQL_MODE]->val_int();
10541009

1055-
DBUG_RETURN(0);
1056-
error:
1057-
DBUG_RETURN(EVEX_GET_FIELD_FAILED);
1010+
DBUG_RETURN(FALSE);
10581011
}
10591012

10601013

sql/event_data_objects.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Event_basic
7777
Event_basic();
7878
virtual ~Event_basic();
7979

80-
virtual int
80+
virtual bool
8181
load_from_row(THD *thd, TABLE *table) = 0;
8282

8383
protected:
@@ -119,7 +119,7 @@ class Event_queue_element : public Event_basic
119119
Event_queue_element();
120120
virtual ~Event_queue_element();
121121

122-
virtual int
122+
virtual bool
123123
load_from_row(THD *thd, TABLE *table);
124124

125125
bool
@@ -157,7 +157,7 @@ class Event_timed : public Event_queue_element
157157
void
158158
init();
159159

160-
virtual int
160+
virtual bool
161161
load_from_row(THD *thd, TABLE *table);
162162

163163
int
@@ -176,7 +176,7 @@ class Event_job_data : public Event_basic
176176

177177
Event_job_data();
178178

179-
virtual int
179+
virtual bool
180180
load_from_row(THD *thd, TABLE *table);
181181

182182
bool
@@ -205,12 +205,11 @@ class Event_parse_data : public Sql_alloc
205205
*/
206206
bool do_not_create;
207207

208-
const char *body_begin;
208+
bool body_changed;
209209

210210
LEX_STRING dbname;
211211
LEX_STRING name;
212212
LEX_STRING definer;// combination of user and host
213-
LEX_STRING body;
214213
LEX_STRING comment;
215214

216215
Item* item_starts;
@@ -235,9 +234,6 @@ class Event_parse_data : public Sql_alloc
235234
bool
236235
check_parse_data(THD *thd);
237236

238-
void
239-
init_body(THD *thd);
240-
241237
private:
242238

243239
void

0 commit comments

Comments
 (0)