Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram 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-11-26 14:36:57+04:00, ramil@stripped +4 -0
Fix for bug #32559: connection hangs on query with name_const
Problem: passing a non-constant name to the NAME_CONST function results in a crash.
Fix: check the NAME_CONST name argument;
introduce and use new Item::real_type() method to check the item type before a type cast.
mysql-test/r/func_misc.result@stripped, 2007-11-26 14:36:55+04:00, ramil@stripped +7 -0
Fix for bug #32559: connection hangs on query with name_const
- test result.
mysql-test/t/func_misc.test@stripped, 2007-11-26 14:36:55+04:00, ramil@stripped +11 -1
Fix for bug #32559: connection hangs on query with name_const
- test case.
sql/item.h@stripped, 2007-11-26 14:36:55+04:00, ramil@stripped +4 -1
Fix for bug #32559: connection hangs on query with name_const
- Item::real_type() intruduced, which is an equivalent to Item::type()
for all items exept Item_name_const (maybe similar changes required
for some other items). The method is usefull then an item type cast is needed.
- NAME_CONST name argument checked for invariability.
sql/set_var.h@stripped, 2007-11-26 14:36:55+04:00, ramil@stripped +1 -1
Fix for bug #32559: connection hangs on query with name_const
- use the real_type() method instead of type() to obtain the value argument
type, in order not to mis-cast it (as, for example, Item_name_const::type()
returns its argument type).
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 14:36:00 +05:00
+++ b/mysql-test/r/func_misc.result 2007-11-26 14:36:55 +04:00
@@ -207,4 +207,11 @@ test
SELECT NAME_CONST('test', 'test');
test
test
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (), (), ();
+SELECT NAME_CONST(a, '1') FROM t1;
+ERROR HY000: Incorrect arguments to NAME_CONST
+SET INSERT_ID= NAME_CONST(a, a);
+ERROR HY000: Incorrect arguments to NAME_CONST
+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 14:36:00 +05:00
+++ b/mysql-test/t/func_misc.test 2007-11-26 14:36:55 +04:00
@@ -204,5 +204,15 @@ SELECT NAME_CONST('test', 1.0);
SELECT NAME_CONST('test', -1.0);
SELECT NAME_CONST('test', 'test');
---echo End of 5.0 tests
+#
+# Bug #32559: connection hangs on query with name_const
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (), (), ();
+--error ER_WRONG_ARGUMENTS
+SELECT NAME_CONST(a, '1') FROM t1;
+--error ER_WRONG_ARGUMENTS
+SET INSERT_ID= NAME_CONST(a, a);
+DROP TABLE t1;
+--echo End of 5.0 tests
diff -Nrup a/sql/item.h b/sql/item.h
--- a/sql/item.h 2007-11-10 23:44:11 +04:00
+++ b/sql/item.h 2007-11-26 14:36:55 +04:00
@@ -529,6 +529,7 @@ public:
virtual Item_result cast_to_int_type() const { return result_type(); }
virtual enum_field_types field_type() const;
virtual enum Type type() const =0;
+ virtual enum Type real_type() const { return type(); }
/* valXXX methods must return NULL or 0 or 0.0 if null_value is set. */
/*
Return double precision floating point representation of item.
@@ -1115,7 +1116,8 @@ public:
Item_name_const(Item *name_arg, Item *val):
value_item(val), name_item(name_arg)
{
- if(!value_item->basic_const_item())
+ if (!name_item->basic_const_item() ||
+ !value_item->basic_const_item())
my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
Item::maybe_null= TRUE;
}
@@ -1123,6 +1125,7 @@ public:
bool fix_fields(THD *, Item **);
enum Type type() const;
+ enum Type real_type() const { return FUNC_ITEM; }
double val_real();
longlong val_int();
String *val_str(String *sp);
diff -Nrup a/sql/set_var.h b/sql/set_var.h
--- a/sql/set_var.h 2007-10-25 15:02:23 +05:00
+++ b/sql/set_var.h 2007-11-26 14:36:55 +04:00
@@ -904,7 +904,7 @@ public:
If the set value is a field, change it to a string to allow things like
SET table_type=MYISAM;
*/
- if (value_arg && value_arg->type() == Item::FIELD_ITEM)
+ if (value_arg && value_arg->real_type() == Item::FIELD_ITEM)
{
Item_field *item= (Item_field*) value_arg;
if (!(value=new Item_string(item->field_name,
| Thread |
|---|
| • bk commit into 5.0 tree (ramil:1.2579) BUG#32559 | ramil | 26 Nov |