summaryrefslogtreecommitdiff
path: root/sql/strfunc.cc
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2004-12-21 17:12:27 +0400
committerunknown <bar@mysql.com>2004-12-21 17:12:27 +0400
commit2ba7c517a48a670cad22c1282f6a74903db80e99 (patch)
tree08f36b11c00064e38be98e5ac2f6e7587f8d8a13 /sql/strfunc.cc
parentc6b6977b9ee65258eef6f55a17fea8c68dcf1a0d (diff)
downloadmariadb-git-2ba7c517a48a670cad22c1282f6a74903db80e99.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