[Commits] Rev 3492: Fix for MDEV-459: DNAMES: column_list returns an empty string if at least one column has a symbolic name in file:///home/bell/maria/bzr/work-maria-5.5-dnames/

sanja at montyprogram.com sanja at montyprogram.com
Mon Aug 20 22:44:11 EEST 2012


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

------------------------------------------------------------
revno: 3492
revision-id: sanja at montyprogram.com-20120820194408-c916mkt05iraidyf
parent: sanja at montyprogram.com-20120820141022-uihihx5sx0fbqgef
committer: sanja at montyprogram.com
branch nick: work-maria-5.5-dnames
timestamp: Mon 2012-08-20 22:44:08 +0300
message:
  Fix for MDEV-459: DNAMES: column_list returns an empty string if at least one column has a symbolic name
-------------- next part --------------
=== modified file 'mysql-test/r/dyncol.result'
--- a/mysql-test/r/dyncol.result	2012-08-20 14:10:22 +0000
+++ b/mysql-test/r/dyncol.result	2012-08-20 19:44:08 +0000
@@ -1467,7 +1467,7 @@ column_list(column_add(column_create("a"
 
 select column_list(column_add(column_create("a", 1), "a", ""));
 column_list(column_add(column_create("a", 1), "a", ""))
-
+`a`
 select hex(column_add("", "a", 1));
 hex(column_add("", "a", 1))
 0401000100010000006102

=== modified file 'mysys/ma_dyncol.c'
--- a/mysys/ma_dyncol.c	2012-08-13 09:06:07 +0000
+++ b/mysys/ma_dyncol.c	2012-08-20 19:44:08 +0000
@@ -1979,27 +1979,27 @@ dynamic_column_list_str(DYNAMIC_COLUMN *
        i < header.column_count;
        i++, read+= header.entry_size)
   {
+    LEX_STRING tmp;
     if (header.format == DYNCOL_FMT_NUM)
     {
       uint nm= uint2korr(read);
-      LEX_STRING str;
-      str.str= my_malloc(6, MYF(0));
-      if (!str.str)
+      tmp.str= my_malloc(6, MYF(0));
+      if (!tmp.str)
         return ER_DYNCOL_RESOURCE;
-      str.length= snprintf(str.str, 6, "%u", nm);
-
-      /* Insert can't never fail as it's pre-allocated above */
-      (void) insert_dynamic(array_of_lexstr, (uchar *)&str);
+      tmp.length= snprintf(tmp.str, 6, "%u", nm);
     }
     else
     {
-      LEX_STRING str;
-      str.length= read[0];
-      str.str= strndup((const char *)header.nmpool + uint2korr(read + 1),
-                       str.length);
-      if(!str.str)
+      tmp.length= read[0];
+      tmp.str= my_malloc(tmp.length + 1, MYF(0));
+      if(!tmp.str)
         return ER_DYNCOL_RESOURCE;
+      memcpy(tmp.str, (const void *)header.nmpool + uint2korr(read + 1),
+             tmp.length);
+      tmp.str[tmp.length]= '\0'; // just for safety
     }
+    /* Insert can't never fail as it's pre-allocated above */
+    (void) insert_dynamic(array_of_lexstr, (uchar *)&tmp);
   }
   return ER_DYNCOL_OK;
 }



More information about the commits mailing list