Commit 6d019443 authored by kroki/tomash@moonlight.intranet's avatar kroki/tomash@moonlight.intranet

Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.1

into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.1-bug21354
parents 2f0363de 1e339e3b
...@@ -100,6 +100,8 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to); ...@@ -100,6 +100,8 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
/* /*
The following must be sorted so that simple intervals comes first. The following must be sorted so that simple intervals comes first.
(get_interval_value() depends on this) (get_interval_value() depends on this)
When updating this enum please update
LEX_STRING interval_type_to_name[] in sql/time.cc
*/ */
enum interval_type enum interval_type
......
...@@ -886,14 +886,29 @@ Event_queue_element::load_from_row(TABLE *table) ...@@ -886,14 +886,29 @@ Event_queue_element::load_from_row(TABLE *table)
goto error; goto error;
/* /*
In DB the values start from 1 but enum interval_type starts We load the interval type from disk as string and then map it to
from 0 an integer. This decouples the values of enum interval_type
and values actually stored on disk. Therefore the type can be
reordered without risking incompatibilities of data between versions.
*/ */
if (!table->field[ET_FIELD_TRANSIENT_INTERVAL]->is_null()) if (!table->field[ET_FIELD_TRANSIENT_INTERVAL]->is_null())
interval= (interval_type) ((ulonglong) {
table->field[ET_FIELD_TRANSIENT_INTERVAL]->val_int() - 1); int i;
else char buff[MAX_FIELD_WIDTH];
interval= (interval_type) 0; String str(buff, sizeof(buff), &my_charset_bin);
LEX_STRING tmp;
table->field[ET_FIELD_TRANSIENT_INTERVAL]->val_str(&str);
if (!(tmp.length= str.length()))
goto error;
tmp.str= str.c_ptr_safe();
i= find_string_in_array(interval_type_to_name, &tmp, system_charset_info);
if (i < 0)
goto error;
interval= (interval_type) i;
}
table->field[ET_FIELD_LAST_EXECUTED]->get_date(&last_executed, table->field[ET_FIELD_LAST_EXECUTED]->get_date(&last_executed,
TIME_NO_ZERO_DATE); TIME_NO_ZERO_DATE);
......
...@@ -188,11 +188,11 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et, ...@@ -188,11 +188,11 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
fields[ET_FIELD_INTERVAL_EXPR]->store((longlong)et->expression, TRUE); fields[ET_FIELD_INTERVAL_EXPR]->store((longlong)et->expression, TRUE);
fields[ET_FIELD_TRANSIENT_INTERVAL]->set_notnull(); fields[ET_FIELD_TRANSIENT_INTERVAL]->set_notnull();
/*
In the enum (C) intervals start from 0 but in mysql enum valid values fields[ET_FIELD_TRANSIENT_INTERVAL]->
start from 1. Thus +1 offset is needed! store(interval_type_to_name[et->interval].str,
*/ interval_type_to_name[et->interval].length,
fields[ET_FIELD_TRANSIENT_INTERVAL]->store((longlong)et->interval+1, TRUE); scs);
fields[ET_FIELD_EXECUTE_AT]->set_null(); fields[ET_FIELD_EXECUTE_AT]->set_null();
......
...@@ -1481,6 +1481,8 @@ uint find_type2(TYPELIB *lib, const char *find, uint length, CHARSET_INFO *cs); ...@@ -1481,6 +1481,8 @@ uint find_type2(TYPELIB *lib, const char *find, uint length, CHARSET_INFO *cs);
void unhex_type2(TYPELIB *lib); void unhex_type2(TYPELIB *lib);
uint check_word(TYPELIB *lib, const char *val, const char *end, uint check_word(TYPELIB *lib, const char *val, const char *end,
const char **end_of_word); const char **end_of_word);
int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
CHARSET_INFO *cs);
bool is_keyword(const char *name, uint len); bool is_keyword(const char *name, uint len);
......
...@@ -312,3 +312,33 @@ outp: ...@@ -312,3 +312,33 @@ outp:
return (uint32) (to - to_start); return (uint32) (to - to_start);
} }
/*
Searches for a LEX_STRING in an LEX_STRING array.
SYNOPSIS
find_string_in_array()
heap The array
needle The string to search for
NOTE
The last LEX_STRING in the array should have str member set to NULL
RETURN VALUES
-1 Not found
>=0 Ordinal position
*/
int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
CHARSET_INFO * const cs)
{
const LEX_STRING *pos;
for (pos= haystack; pos->str; pos++)
if (!cs->coll->strnncollsp(cs, (uchar *) pos->str, pos->length,
(uchar *) needle->str, needle->length, 0))
{
return (pos - haystack);
}
return -1;
}
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