From 217d83a69fca9baec8f164dcfba170a0c1f87fae Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Mon, 25 Oct 2004 17:51:26 +0500 Subject: Bug#6202: ENUMs are not case sensitive even if declared BINARY --- sql/strfunc.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'sql/strfunc.cc') diff --git a/sql/strfunc.cc b/sql/strfunc.cc index d00e57df5a1..ea67a5a4343 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -116,6 +116,47 @@ uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match) } +/* + Find a string in a list of strings according to collation + + SYNOPSIS + find_type2() + lib TYPELIB (struct of pointer to values + count) + x String to find + length String length + cs Character set + collation to use for comparison + + NOTES + + RETURN + 0 No matching value + >0 Offset+1 in typelib for matched string +*/ + +uint find_type2(TYPELIB *typelib, const char *x, uint length, CHARSET_INFO *cs) +{ + int find,pos,findpos; + const char *j; + DBUG_ENTER("find_type2"); + DBUG_PRINT("enter",("x: '%s' lib: 0x%lx",x,typelib)); + + if (!typelib->count) + { + DBUG_PRINT("exit",("no count")); + DBUG_RETURN(0); + } + LINT_INIT(findpos); + for (find=0, pos=0 ; (j=typelib->type_names[pos]) ; pos++) + { + if (!my_strnncoll(cs, (const uchar*) x, length, + (const uchar*) j, typelib->type_lengths[pos])) + DBUG_RETURN(pos+1); + } + DBUG_PRINT("exit",("Couldn't find type")); + DBUG_RETURN(0); +} /* find_type */ + + /* Check if the first word in a string is one of the ones in TYPELIB -- cgit v1.2.1