summaryrefslogtreecommitdiff
path: root/sql/strfunc.cc
diff options
context:
space:
mode:
authorunknown <andrey@example.com>2006-10-10 17:59:46 +0200
committerunknown <andrey@example.com>2006-10-10 17:59:46 +0200
commit92b3a32b50f113da22233b8c6393d6242bb11437 (patch)
tree828347a6db607f7b6ebcc868a1c497c7c41ba7a8 /sql/strfunc.cc
parenta7f8da2904525096fd6cf9c7999ce087ee4d9d4d (diff)
downloadmariadb-git-92b3a32b50f113da22233b8c6393d6242bb11437.tar.gz
Remove direct mapping of enum interval_type to mysql.event.interval_field
This decoupling allows in further versions of MySQL enum interval_type to be reordered without this affecting any backward compatibility in the events code. This changeset doesn't change any exposed behavior but makes events' code more durable to changes outside of their code base. To the reviewer: There is no regression test included as it is impossible to construct one with the current infrastructure which can test it. To test the code one has create and event, then change the order of enum interval_type in my_time.h, update sql/time.cc, recompile the server and run it with scheduler running. include/my_time.h: Add a reminder to keep enum interval_type and interval_type_to_name in sync sql/event_data_objects.cc: When loading from disk don't use the integer value of mysql.event.interval_field because it could be different of the values of enum interval_type, if the latter is reordered in a later version of MySQL. Loaded from disk is the string value which is then resolved against interval_type_to_name to get the exact enum value we need for Event_queue_element::interval. sql/event_db_repository.cc: Use interval_type_to_name from sql/time.cc during storage thus decoupling the value stored on disk (the enum) from the integer representation in memory. interval_type can be changed and as long as interval_type_to_name is kept in sync correct values will be saved to disk. sql/mysql_priv.h: add proto of find_string_in_array sql/strfunc.cc: Add a function for searching a LEX_STRING in an array of LEX_STRINGs
Diffstat (limited to 'sql/strfunc.cc')
-rw-r--r--sql/strfunc.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index 2525703172f..ef769a5b16e 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -312,3 +312,33 @@ outp:
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;
+}