[Commits] Rev 3491: Fix for MDEV-458 DNAMES: Server crashes on using an unquoted string as a dynamic column name in file:///home/bell/maria/bzr/work-maria-5.5-dnames/

sanja at montyprogram.com sanja at montyprogram.com
Mon Aug 20 17:10:25 EEST 2012


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

------------------------------------------------------------
revno: 3491
revision-id: sanja at montyprogram.com-20120820141022-uihihx5sx0fbqgef
parent: elenst at ubuntu11.home-20120813090607-jtuq5p0umts16h5h
committer: sanja at montyprogram.com
branch nick: work-maria-5.5-dnames
timestamp: Mon 2012-08-20 17:10:22 +0300
message:
  Fix for MDEV-458 DNAMES: Server crashes on using an unquoted string as a dynamic column name
  
  In case of error in chcking arguments do not try to get its parameters.
-------------- next part --------------
=== modified file 'mysql-test/r/dyncol.result'
--- a/mysql-test/r/dyncol.result	2012-08-13 09:06:07 +0000
+++ b/mysql-test/r/dyncol.result	2012-08-20 14:10:22 +0000
@@ -1339,6 +1339,7 @@ hex(COLUMN_CREATE(0, 0.0 as decimal))
 # test of symbolic names
 #
 # creation test (names)
+set names utf8;
 select hex(column_create("????????", 1212));
 hex(column_create("????????", 1212))
 040100080008000000D0B0D0B4D18BD0BD7809
@@ -1357,7 +1358,9 @@ hex(column_create("1212", 2, 3, 3))
 select hex(column_create("1212", 2, "????????", 1, 3, 3));
 hex(column_create("1212", 2, "????????", 1, 3, 3))
 0403000D000100000004010008080500103331323132D0B0D0B4D18BD0BD060402
+set names default;
 # fetching column test (names)
+set names utf8;
 select column_get(column_create("????????", 1212), "????????" as int);
 column_get(column_create("????????", 1212), "????????" as int)
 1212
@@ -1379,7 +1382,9 @@ NULL
 select column_get(column_create("1212", 2, "????????", 1, 3, 3), "4" as int);
 column_get(column_create("1212", 2, "????????", 1, 3, 3), "4" as int)
 NULL
+set names default;
 # column existance test (names)
+set names utf8;
 select column_exists(column_create("????????", 1212), "????????");
 column_exists(column_create("????????", 1212), "????????")
 1
@@ -1404,6 +1409,7 @@ column_exists(column_create("1212", 2, "
 select column_exists(column_create("1212", 2, "????????", 1, 3, 3), "4");
 column_exists(column_create("1212", 2, "????????", 1, 3, 3), "4")
 0
+set names default;
 # column changing test (names)
 select hex(column_add(column_create(1, "AAA"), "b", "BBB"));
 hex(column_add(column_create(1, "AAA"), "b", "BBB"))
@@ -1499,3 +1505,9 @@ hex(column_delete(column_create("a", 1),
 select hex(column_delete("", "a"));
 hex(column_delete("", "a"))
 
+#
+# MDEV-458 DNAMES: Server crashes on using an unquoted string
+# as a dynamic column name
+#
+select COLUMN_CREATE(color, "black");
+ERROR 42S22: Unknown column 'color' in 'field list'

=== modified file 'mysql-test/t/dyncol.test'
--- a/mysql-test/t/dyncol.test	2012-08-13 09:06:07 +0000
+++ b/mysql-test/t/dyncol.test	2012-08-20 14:10:22 +0000
@@ -621,3 +621,10 @@ select hex(column_delete(column_create("
 select hex(column_delete(column_create("a", 1 as integer, "b", 2 as integer, "c", 3 as integer), "a", "b", "c", "e"));
 select hex(column_delete(column_create("a", 1), "a"));
 select hex(column_delete("", "a"));
+
+--echo #
+--echo # MDEV-458 DNAMES: Server crashes on using an unquoted string
+--echo # as a dynamic column name
+--echo #
+--error ER_BAD_FIELD_ERROR
+select COLUMN_CREATE(color, "black");

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2012-08-13 09:06:07 +0000
+++ b/sql/item_strfunc.cc	2012-08-20 14:10:22 +0000
@@ -3771,20 +3771,23 @@ bool Item_func_dyncol_create::fix_fields
 {
   uint i;
   bool res= Item_func::fix_fields(thd, ref); // no need Item_str_func here
-  vals= (DYNAMIC_COLUMN_VALUE *) alloc_root(thd->mem_root,
-                                            sizeof(DYNAMIC_COLUMN_VALUE) *
-                                            (arg_count / 2));
-  for (i= 0; i + 1 < arg_count && args[i]->result_type() == INT_RESULT; i+= 2);
-  if (i + 1 < arg_count)
+  if (!res)
   {
-    names= TRUE;
-  }
+    vals= (DYNAMIC_COLUMN_VALUE *) alloc_root(thd->mem_root,
+                                              sizeof(DYNAMIC_COLUMN_VALUE) *
+                                              (arg_count / 2));
+    for (i= 0; i + 1 < arg_count && args[i]->result_type() == INT_RESULT; i+= 2);
+    if (i + 1 < arg_count)
+    {
+      names= TRUE;
+    }
 
-  keys= (uchar *) alloc_root(thd->mem_root,
-                             (sizeof(LEX_STRING) > sizeof(uint) ?
-                              sizeof(LEX_STRING) :
-                              sizeof(uint)) *
-                             (arg_count / 2));
+    keys= (uchar *) alloc_root(thd->mem_root,
+                               (sizeof(LEX_STRING) > sizeof(uint) ?
+                                sizeof(LEX_STRING) :
+                                sizeof(uint)) *
+                               (arg_count / 2));
+  }
   return res || vals == 0 || keys == 0;
 }
 



More information about the commits mailing list