summaryrefslogtreecommitdiff
path: root/sql/strfunc.cc
diff options
context:
space:
mode:
authorbar@mysql.com <>2004-10-25 17:51:26 +0500
committerbar@mysql.com <>2004-10-25 17:51:26 +0500
commit217d83a69fca9baec8f164dcfba170a0c1f87fae (patch)
tree7a9462068baaf8b0e98b30d9e65951269bac98e5 /sql/strfunc.cc
parente4be287771a616f2988c17ea2b3910be7ff01aea (diff)
downloadmariadb-git-217d83a69fca9baec8f164dcfba170a0c1f87fae.tar.gz
Bug#6202: ENUMs are not case sensitive even if declared BINARY
Diffstat (limited to 'sql/strfunc.cc')
-rw-r--r--sql/strfunc.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index d00e57df5a1..ea67a5a4343 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -117,6 +117,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
SYNOPSIS