List:Internals« Previous MessageNext Message »
From:bar Date:November 7 2005 8:34am
Subject:bk commit into 5.0 tree (bar:1.1973) BUG#14146
View as plain text  
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.1973 05/11/07 12:34:19 bar@stripped +4 -0
    Bug#14146 CHAR(...USING ...) and CONVERT(CHAR(...) USING...) produce different results
  ctype_utf8.result, ctype_utf8.test:
    Adding test case.
  item_strfunc.cc:
  item_strfunc.h:
    Moving the well formed checking code into a method,
    to reuse in several Item_func_xxx. Reusing the new
    method in Item_func_char and Item_func_charset_conv.
  

  mysql-test/r/ctype_utf8.result
    1.83 05/11/07 12:32:21 bar@stripped +10 -0
    Adding test case.

  mysql-test/t/ctype_utf8.test
    1.77 05/11/07 12:32:16 bar@stripped +5 -1
    Adding test case.

  sql/item_strfunc.cc
    1.259 05/11/07 12:32:04 bar@stripped +34 -29
    Moving the well formed checking code into a method,
    to reuse in several Item_func_xxx.

  sql/item_strfunc.h
    1.100 05/11/07 12:30:58 bar@stripped +1 -0
    Bug#14146 CHAR(...USING ...) and CONVERT(CHAR(...) USING...) produce different results
    Moving the well formed checking code into a method,
    to reuse in several Item_func_xxx.

# 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.b14146

--- 1.258/sql/item_strfunc.cc	2005-10-13 15:09:35 +05:00
+++ 1.259/sql/item_strfunc.cc	2005-11-07 12:32:04 +04:00
@@ -48,6 +48,38 @@
 }
 
 
+String *Item_str_func::check_well_formed_result(String *str)
+{
+  /* Check whether we got a well-formed string */
+  CHARSET_INFO *cs= str->charset();
+  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);
+    octet2hex(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;
+}
+
+
 double Item_str_func::val_real()
 {
   DBUG_ASSERT(fixed == 1);
@@ -1984,34 +2016,7 @@
   }
   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);
-    octet2hex(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;
+  return check_well_formed_result(str);
 }
 
 
@@ -2320,7 +2325,7 @@
   }
   null_value= str_value.copy(arg->ptr(),arg->length(),arg->charset(),
                              conv_charset, &dummy_errors);
-  return null_value ? 0 : &str_value;
+  return null_value ? 0 : check_well_formed_result(&str_value);
 }
 
 void Item_func_conv_charset::fix_length_and_dec()

--- 1.99/sql/item_strfunc.h	2005-10-21 16:50:24 +05:00
+++ 1.100/sql/item_strfunc.h	2005-11-07 12:30:58 +04:00
@@ -35,6 +35,7 @@
   double val_real();
   enum Item_result result_type () const { return STRING_RESULT; }
   void left_right_max_length();
+  String *check_well_formed_result(String *str);
 };
 
 class Item_func_md5 :public Item_str_func

--- 1.82/mysql-test/r/ctype_utf8.result	2005-10-21 16:57:50 +05:00
+++ 1.83/mysql-test/r/ctype_utf8.result	2005-11-07 12:32:21 +04:00
@@ -1095,6 +1095,11 @@
 Warnings:
 Warning	1300	Invalid utf8 character string: 'FF8F'
+select convert(char(0xff,0x8f) using utf8);
+convert(char(0xff,0x8f) using utf8)
+Warnings:
+Warning	1300	Invalid utf8 character string: 'FF8F'
 set sql_mode=traditional;
 select char(0xff,0x8f using utf8);
 char(0xff,0x8f using utf8)
@@ -1116,6 +1121,11 @@
 NULL
 Warnings:
 Error	1300	Invalid utf8 character string: 'FD'
+select convert(char(0xff,0x8f) using utf8);
+convert(char(0xff,0x8f) using utf8)
+NULL
+Warnings:
+Error	1300	Invalid utf8 character string: 'FF8F'
 select hex(convert(char(2557 using latin1) using utf8));
 hex(convert(char(2557 using latin1) using utf8))
 09C3BD

--- 1.76/mysql-test/t/ctype_utf8.test	2005-10-21 16:46:50 +05:00
+++ 1.77/mysql-test/t/ctype_utf8.test	2005-11-07 12:32:16 +04:00
@@ -884,7 +884,9 @@
 DROP TABLE t1;
 
 #
-#  Bugs#10504: Character set does not support traditional mode
+#  Bug#10504: Character set does not support traditional mode
+#  Bug#14146: CHAR(...USING ...) and CONVERT(CHAR(...) USING...)
+#             produce different results
 #
 set names utf8;
 # correct value
@@ -894,12 +896,14 @@
 select char(53647 using utf8);
 # incorrect value: return with warning
 select char(0xff,0x8f using utf8);
+select convert(char(0xff,0x8f) using utf8);
 # incorrect value in strict mode: return NULL with "Error" level warning
 set sql_mode=traditional;
 select char(0xff,0x8f using utf8);
 select char(195 using utf8);
 select char(196 using utf8);
 select char(2557 using utf8);
+select convert(char(0xff,0x8f) using utf8);
 
 #
 # Check convert + char + using
Thread
bk commit into 5.0 tree (bar:1.1973) BUG#14146bar7 Nov