Commit f3aea476 authored by unknown's avatar unknown

WL #1034 update

- fix problem with too long identifier name


sql/event.cc:
  report an error when identifier too long
sql/event_priv.h:
  name the enum
  fix truncation problem
sql/share/errmsg.txt:
  new error message
sql/sql_yacc.yy:
  remove debug info and whitespace
parent 8ba78896
......@@ -211,6 +211,11 @@ evex_db_find_event_aux(THD *thd, const LEX_STRING dbname,
table the row to fill out
et Event's data
Returns
0 - ok
EVEX_GENERAL_ERROR - bad data
EVEX_GET_FIELD_FAILED - field count does not match. table corrupted?
DESCRIPTION
Used both when an event is created and when it is altered.
*/
......@@ -218,6 +223,8 @@ evex_db_find_event_aux(THD *thd, const LEX_STRING dbname,
static int
evex_fill_row(THD *thd, TABLE *table, event_timed *et, my_bool is_update)
{
enum evex_table_field field_num;
DBUG_ENTER("evex_fill_row");
if (table->s->fields != EVEX_FIELD_COUNT)
......@@ -229,10 +236,13 @@ evex_fill_row(THD *thd, TABLE *table, event_timed *et, my_bool is_update)
DBUG_PRINT("info", ("dbname.len=%d",et->dbname.length));
DBUG_PRINT("info", ("name.len=%d",et->name.length));
table->field[EVEX_FIELD_DB]->
store(et->dbname.str, et->dbname.length, system_charset_info);
table->field[EVEX_FIELD_NAME]->
store(et->name.str, et->name.length, system_charset_info);
if (table->field[field_num= EVEX_FIELD_DB]->
store(et->dbname.str, et->dbname.length, system_charset_info))
goto trunc_err;
if (table->field[field_num= EVEX_FIELD_NAME]->
store(et->name.str, et->name.length, system_charset_info))
goto trunc_err;
table->field[EVEX_FIELD_ON_COMPLETION]->set_notnull();
table->field[EVEX_FIELD_ON_COMPLETION]->store((longlong)et->on_completion);
......@@ -243,8 +253,9 @@ evex_fill_row(THD *thd, TABLE *table, event_timed *et, my_bool is_update)
// ToDo: Andrey. How to use users current charset?
if (et->body.str)
table->field[EVEX_FIELD_BODY]->
store(et->body.str, et->body.length, system_charset_info);
if (table->field[field_num= EVEX_FIELD_BODY]->
store(et->body.str, et->body.length, system_charset_info))
goto trunc_err;
if (et->starts.year)
{
......@@ -290,10 +301,14 @@ evex_fill_row(THD *thd, TABLE *table, event_timed *et, my_bool is_update)
((Field_timestamp *)table->field[EVEX_FIELD_MODIFIED])->set_time();
if (et->comment.length)
table->field[EVEX_FIELD_COMMENT]->
store(et->comment.str, et->comment.length, system_charset_info);
if (table->field[field_num= EVEX_FIELD_COMMENT]->
store(et->comment.str, et->comment.length, system_charset_info))
goto trunc_err;
DBUG_RETURN(0);
DBUG_RETURN(0);
trunc_err:
my_error(ER_EVENT_DATA_TOO_LONG, MYF(0));
DBUG_RETURN(EVEX_GENERAL_ERROR);
}
......@@ -353,11 +368,21 @@ db_create_event(THD *thd, event_timed *et, my_bool create_if_not,
restore_record(table, s->default_values); // Get default values for fields
if (et->name.length > table->field[EVEX_FIELD_NAME]->field_length)
if (system_charset_info->cset->numchars(system_charset_info, et->dbname.str,
et->dbname.str + et->dbname.length)
> EVEX_DB_FIELD_LEN)
{
my_error(ER_TOO_LONG_IDENT, MYF(0), et->dbname.str);
goto err;
}
if (system_charset_info->cset->numchars(system_charset_info, et->name.str,
et->name.str + et->name.length)
> EVEX_DB_FIELD_LEN)
{
my_error(ER_TOO_LONG_IDENT, MYF(0), et->name.str);
goto err;
}
if (et->body.length > table->field[EVEX_FIELD_BODY]->field_length)
{
my_error(ER_TOO_LONG_BODY, MYF(0), et->name.str);
......
......@@ -24,7 +24,7 @@
#define UNLOCK_MUTEX_AND_BAIL_OUT(__mutex, __label) \
{ VOID(pthread_mutex_unlock(&__mutex)); goto __label; }
enum
enum evex_table_field
{
EVEX_FIELD_DB = 0,
EVEX_FIELD_NAME,
......@@ -42,9 +42,10 @@ enum
EVEX_FIELD_ON_COMPLETION,
EVEX_FIELD_COMMENT,
EVEX_FIELD_COUNT /* a cool trick to count the number of fields :) */
};
} ;
#define EVEX_DB_FIELD_LEN 64
#define EVEX_NAME_FIELD_LEN 64
int
my_time_compare(TIME *a, TIME *b);
......
......@@ -5751,3 +5751,5 @@ ER_EVENT_COMPILE_ERROR
eng "Error during compilation of event's body"
ER_EVENT_SAME_NAME
eng "Same old and new event name"
ER_EVENT_DATA_TOO_LONG
eng "Data for column '%s' too long"
......@@ -4275,10 +4275,8 @@ alter:
sql_command is set here because some rules in ev_sql_stmt
can overwrite it
*/
printf("5=%d 6=%d 7=%d 8=%d 9=%d 10=%d", $<ulong_num>5 , $<ulong_num>6 , $<ulong_num>7 ,
$<ulong_num>8 , $<ulong_num>9 , $<ulong_num>10);
if (!($<ulong_num>5 || $<ulong_num>6 || $<ulong_num>7 ||
$<ulong_num>8 || $<ulong_num>9 || $<ulong_num>10))
$<ulong_num>8 || $<ulong_num>9 || $<ulong_num>10))
{
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
......
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