summaryrefslogtreecommitdiff
path: root/sql/strfunc.cc
diff options
context:
space:
mode:
authorbar@mysql.com <>2004-12-21 17:12:27 +0400
committerbar@mysql.com <>2004-12-21 17:12:27 +0400
commit57ec14d939438086faeffce6d316ad463bd164b9 (patch)
tree08f36b11c00064e38be98e5ac2f6e7587f8d8a13 /sql/strfunc.cc
parentecd85b1836ebfbb9a548526a658956ea8ba4cfd5 (diff)
downloadmariadb-git-57ec14d939438086faeffce6d316ad463bd164b9.tar.gz
Bug#7302: UCS2 data in ENUM field get truncated when new column is added
Diffstat (limited to 'sql/strfunc.cc')
-rw-r--r--sql/strfunc.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index 8ab6992a63a..3ad6b1155d1 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -170,6 +170,43 @@ uint find_type2(TYPELIB *typelib, const char *x, uint length, CHARSET_INFO *cs)
/*
+ Un-hex all elements in a typelib
+
+ SYNOPSIS
+ unhex_type2()
+ interval TYPELIB (struct of pointer to values + lengths + count)
+
+ NOTES
+
+ RETURN
+ N/A
+*/
+
+void unhex_type2(TYPELIB *interval)
+{
+ for (uint pos= 0; pos < interval->count; pos++)
+ {
+ char *from, *to;
+ for (from= to= (char*) interval->type_names[pos]; *from; )
+ {
+ /*
+ Note, hexchar_to_int(*from++) doesn't work
+ one some compilers, e.g. IRIX. Looks like a compiler
+ bug in inline functions in combination with arguments
+ that have a side effect. So, let's use from[0] and from[1]
+ and increment 'from' by two later.
+ */
+
+ *to++= (char) (hexchar_to_int(from[0]) << 4) +
+ hexchar_to_int(from[1]);
+ from+= 2;
+ }
+ interval->type_lengths[pos] /= 2;
+ }
+}
+
+
+/*
Check if the first word in a string is one of the ones in TYPELIB
SYNOPSIS