Below is the list of changes that have just been committed into a local
5.0 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1958 05/09/05 18:20:56 bar@stripped +3 -0
Bug#10504
Character set does not support traditional mode
ctype_utf8.result, ctype_utf8.test:
adding test case.
item_strfunc.cc:
Result string of the function CHAR()
is now checked to be well-formed.
Warning/error is generated in the case of
a bad string, depending on sql_mode.
mysql-test/r/ctype_utf8.result
1.71 05/09/05 18:19:43 bar@stripped +15 -0
adding test case.
mysql-test/t/ctype_utf8.test
1.67 05/09/05 18:19:36 bar@stripped +12 -0
adding test case.
sql/item_strfunc.cc
1.252 05/09/05 18:18:34 bar@stripped +55 -0
Bug#10504
Character set does not support traditional mode
Result string is now checked to be well-formed.
Warning/error is generated, depending on sql_mode.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: bar
# Host: bar.intranet.mysql.r18.ru
# Root: /usr/home/bar/mysql-5.0
--- 1.251/sql/item_strfunc.cc 2005-09-01 03:24:03 +05:00
+++ 1.252/sql/item_strfunc.cc 2005-09-05 18:18:34 +05:00
@@ -1952,6 +1952,34 @@
}
+/*
+ Return hex string
+
+ SYNOPSIS
+ strhexcpy()
+ to target
+ from source
+ length source length
+
+ DESCRIPTION
+ Copies hex representation of "from" string into "to" string.
+ "to" is NUL terminred.
+ "to" must be at least (length * 2 + 1) bytes long.
+*/
+
+
+static void hexncpy(char *to, const char *from, uint length)
+{
+ const char *end;
+ for (end= from + length ; from < end ; from++)
+ {
+ *to++= _dig_vec_upper[((unsigned char) *from) >> 4];
+ *to++= _dig_vec_upper[((unsigned char) *from) & 0x0F];
+ }
+ *to= '\0';
+}
+
+
String *Item_func_char::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@@ -1980,6 +2008,33 @@
}
str->set_charset(collation.collation);
str->realloc(str->length()); // Add end 0 (for Purify)
+
+ /* Check whether we got a well-formed string */
+ CHARSET_INFO *cs= collation.collation;
+ int well_formed_error;
+ uint wlen= cs->cset->well_formed_len(cs,
+ str->ptr(), str->ptr() + str->length(),
+ str->length(), &well_formed_error);
+ if (wlen < str->length())
+ {
+ THD *thd= current_thd;
+ char hexbuf[7];
+ enum MYSQL_ERROR::enum_warning_level level;
+ uint diff= str->length() - wlen;
+ set_if_smaller(diff, 3);
+ hexncpy(hexbuf, str->ptr() + wlen, diff);
+ if (thd->variables.sql_mode &
+ (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))
+ {
+ level= MYSQL_ERROR::WARN_LEVEL_ERROR;
+ null_value= 1;
+ str= 0;
+ }
+ else
+ level= MYSQL_ERROR::WARN_LEVEL_WARN;
+ push_warning_printf(thd, level, ER_INVALID_CHARACTER_STRING,
+ ER(ER_INVALID_CHARACTER_STRING), cs->csname, hexbuf);
+ }
return str;
}
--- 1.70/mysql-test/r/ctype_utf8.result 2005-08-29 22:15:37 +05:00
+++ 1.71/mysql-test/r/ctype_utf8.result 2005-09-05 18:19:43 +05:00
@@ -1023,3 +1023,18 @@
xxx
yyy
DROP TABLE t1;
+set names utf8;
+select char(0xd1,0x8f);
+char(0xd1,0x8f)
+я
+select char(0xff,0x8f);
+char(0xff,0x8f)
+Warnings:
+Warning 1300 Invalid utf8 character string: 'FF8F'
+set sql_mode=traditional;
+select char(0xff,0x8f);
+char(0xff,0x8f)
+NULL
+Warnings:
+Error 1300 Invalid utf8 character string: 'FF8F'
--- 1.66/mysql-test/t/ctype_utf8.test 2005-08-29 22:15:47 +05:00
+++ 1.67/mysql-test/t/ctype_utf8.test 2005-09-05 18:19:36 +05:00
@@ -857,3 +857,15 @@
SELECT DISTINCT id FROM t1 ORDER BY id;
DROP TABLE t1;
+
+#
+# Bugs#10504: Character set does not support traditional mode
+#
+set names utf8;
+# correct value
+select char(0xd1,0x8f);
+# incorrect value: return with warning
+select char(0xff,0x8f);
+# incorrect value in strict mode: return NULL with "Error" level warning
+set sql_mode=traditional;
+select char(0xff,0x8f);
| Thread |
|---|
| • bk commit into 5.0 tree (bar:1.1958) BUG#10504 | bar | 5 Sep |