List:Commits« Previous MessageNext Message »
From:igor Date:December 8 2007 8:37am
Subject:bk commit into 5.0 tree (igor:1.2597) BUG#27545
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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@stripped, 2007-12-07 23:36:58-08:00, igor@stripped +3 -0
  Fixed bug #27545.
  Both arguments of the function NAME_CONST must be constant expressions.
  This constraint is checked in the Item_name_const::fix_fields method. 
  Yet if the argument of the function was not a constant expression no
  error message was reported. As a result the client hanged waiting for a
  response.
  Now the function Item_name_const::fix_fields reports an error message
  when any of the additional context conditions imposed on the function
  NAME_CONST is not satisfied. 

  mysql-test/r/func_misc.result@stripped, 2007-12-07 23:36:53-08:00, igor@stripped +5 -0
    Added a test case for bug #26545.

  mysql-test/t/func_misc.test@stripped, 2007-12-07 23:36:53-08:00, igor@stripped +13 -0
    Added a test case for bug #26545.

  sql/item.cc@stripped, 2007-12-07 23:36:53-08:00, igor@stripped +7 -7
    Fixed bug #27545.
    Both arguments of the function NAME_CONST must be constant expressions.
    This constraint is checked in the Item_name_const::fix_fields method. 
    Yet if the argument of the function was not a constant expression no
    error message was reported. As a result the client hanged waiting for a
    response.
    Now the function Item_name_const::fix_fields reports an error message
    when any of the additional context conditions imposed on the function
    NAME_CONST is not satisfied. 

diff -Nrup a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
--- a/mysql-test/r/func_misc.result	2007-10-09 02:36:00 -07:00
+++ b/mysql-test/r/func_misc.result	2007-12-07 23:36:53 -08:00
@@ -207,4 +207,9 @@ test
 SELECT NAME_CONST('test', 'test');
 test
 test
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (5), (2);
+SELECT NAME_CONST(x,2) FROM (SELECT a x FROM t1) t;
+ERROR HY000: The 'NAME_CONST' syntax is reserved for purposes internal to the MySQL
server
+DROP TABLE t1;
 End of 5.0 tests
diff -Nrup a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
--- a/mysql-test/t/func_misc.test	2007-10-09 02:36:00 -07:00
+++ b/mysql-test/t/func_misc.test	2007-12-07 23:36:53 -08:00
@@ -204,5 +204,18 @@ SELECT NAME_CONST('test', 1.0);
 SELECT NAME_CONST('test', -1.0);
 SELECT NAME_CONST('test', 'test');
 
+#
+# Bug #27545: erroneous usage of NAME_CONST with a name as the first parameter 
+#             resolved against a column name of a derived table hangs the client
+#
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (5), (2);
+
+--error ER_RESERVED_SYNTAX
+SELECT NAME_CONST(x,2) FROM (SELECT a x FROM t1) t;
+
+DROP TABLE t1;
+
 --echo End of 5.0 tests
 
diff -Nrup a/sql/item.cc b/sql/item.cc
--- a/sql/item.cc	2007-11-20 09:18:20 -08:00
+++ b/sql/item.cc	2007-12-07 23:36:53 -08:00
@@ -1221,14 +1221,14 @@ bool Item_name_const::fix_fields(THD *th
   s.length(0);
 
   if (value_item->fix_fields(thd, &value_item) ||
-      name_item->fix_fields(thd, &name_item))
+      name_item->fix_fields(thd, &name_item) ||
+      !value_item->const_item() ||
+      !name_item->const_item() ||
+      !(item_name= name_item->val_str(&s))) // Can't have a NULL name 
+  {
+    my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST");
     return TRUE;
-  if (!(value_item->const_item() && name_item->const_item()))
-    return TRUE;
-
-  if (!(item_name= name_item->val_str(&s)))
-    return TRUE; /* Can't have a NULL name */
-
+  }
   set_name(item_name->ptr(), (uint) item_name->length(), system_charset_info);
   max_length= value_item->max_length;
   decimals= value_item->decimals;
Thread
bk commit into 5.0 tree (igor:1.2597) BUG#27545igor8 Dec