[Commits] Rev 3493: Fix for MDEV-461: DNAMES: column names do not work with non-trivial encodings. in file:///home/bell/maria/bzr/work-maria-5.5-dnames/

sanja at montyprogram.com sanja at montyprogram.com
Tue Aug 21 10:30:06 EEST 2012


At file:///home/bell/maria/bzr/work-maria-5.5-dnames/

------------------------------------------------------------
revno: 3493
revision-id: sanja at montyprogram.com-20120821073006-p9qfcqz4qibo3jgo
parent: sanja at montyprogram.com-20120820194408-c916mkt05iraidyf
committer: sanja at montyprogram.com
branch nick: work-maria-5.5-dnames
timestamp: Tue 2012-08-21 10:30:06 +0300
message:
  Fix for MDEV-461: DNAMES: column names do not work with non-trivial encodings.
  
  Exists lacked string convertion (added).
-------------- next part --------------
=== modified file 'mysql-test/r/dyncol_koi8.result'
--- a/mysql-test/r/dyncol_koi8.result	2012-08-13 09:06:07 +0000
+++ b/mysql-test/r/dyncol_koi8.result	2012-08-21 07:30:06 +0000
@@ -6,4 +6,10 @@ set names utf8;
 select hex(column_create("????????", 1212));
 hex(column_create("????????", 1212))
 040100080008000000D0B0D0B4D18BD0BD7809
+#
+# MDEV-461: DNAMES: column names do not work with non-trivial encodings
+#
+select column_exists(column_create('???','value'),'???');
+column_exists(column_create('???','value'),'???')
+1
 set names default;

=== modified file 'mysql-test/t/dyncol_koi8.test'
--- a/mysql-test/t/dyncol_koi8.test	2012-08-13 09:06:07 +0000
+++ b/mysql-test/t/dyncol_koi8.test	2012-08-21 07:30:06 +0000
@@ -6,4 +6,8 @@ set names koi8r;
 select hex(column_create("????", 1212));
 set names utf8;
 select hex(column_create("????????", 1212));
+--echo #
+--echo # MDEV-461: DNAMES: column names do not work with non-trivial encodings
+--echo #
+select column_exists(column_create('???','value'),'???');
 set names default;

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2012-08-13 09:06:07 +0000
+++ b/sql/item_cmpfunc.cc	2012-08-21 07:30:06 +0000
@@ -6051,7 +6051,8 @@ Item* Item_equal::get_first(JOIN_TAB *co
 
 longlong Item_func_dyncol_exists::val_int()
 {
-  char buff[STRING_BUFFER_USUAL_SIZE], nmstrbuf[11];
+  char buff[STRING_BUFFER_USUAL_SIZE], nmstrbuf[11],
+       *alloc_buff= NULL;
   String tmp(buff, sizeof(buff), &my_charset_bin),
          nmbuf(nmstrbuf, sizeof(nmstrbuf), system_charset_info);
   DYNAMIC_COLUMN col;
@@ -6065,8 +6066,31 @@ longlong Item_func_dyncol_exists::val_in
   else
   {
     String *nm= args[1]->val_str(&nmbuf);
-    buf.str= (char *) nm->ptr();
-    buf.length= nm->length();
+    if (my_charset_same(nm->charset(), &my_charset_utf8_general_ci))
+    {
+      buf.str= (char *) nm->ptr();
+      buf.length= nm->length();
+    }
+    else
+    {
+      uint strlen;
+      uint dummy_errors;
+      alloc_buff= (char *)sql_alloc((strlen= nm->length() *
+                                     my_charset_utf8_general_ci.mbmaxlen + 1));
+      if (alloc_buff)
+      {
+        buf.length=
+          copy_and_convert(alloc_buff, strlen, &my_charset_utf8_general_ci,
+                               nm->ptr(), nm->length(), nm->charset(),
+                               &dummy_errors);
+        buf.str= alloc_buff;
+      }
+      else
+      {
+        buf.length= 0;
+        buf.str= NULL;
+      }
+    }
     name= &buf;
   }
   str= args[0]->val_str(&tmp);
@@ -6078,6 +6102,8 @@ longlong Item_func_dyncol_exists::val_in
   rc= ((name == NULL) ?
        dynamic_column_exists(&col, (uint) num) :
        dynamic_column_exists_str(&col, name));
+  if (alloc_buff)
+    my_free(alloc_buff);
   if (rc < 0)
   {
     dynamic_column_error_message(rc);



More information about the commits mailing list