Commit b9c48170 authored by unknown's avatar unknown

Merge mysql.com:/home/ram/work/b32559/b32559.5.0

into  mysql.com:/home/ram/work/b32559/b32559.5.1


mysql-test/r/func_misc.result:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
mysql-test/t/func_misc.test:
  manual merge.
parents 18489d10 ba974f83
...@@ -212,6 +212,13 @@ test ...@@ -212,6 +212,13 @@ test
SELECT NAME_CONST('test', 'test'); SELECT NAME_CONST('test', 'test');
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 End of 5.0 tests
select connection_id() > 0; select connection_id() > 0;
connection_id() > 0 connection_id() > 0
......
...@@ -213,6 +213,17 @@ SELECT NAME_CONST('test', 1.0); ...@@ -213,6 +213,17 @@ SELECT NAME_CONST('test', 1.0);
SELECT NAME_CONST('test', -1.0); SELECT NAME_CONST('test', -1.0);
SELECT NAME_CONST('test', 'test'); SELECT NAME_CONST('test', 'test');
#
# 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 --echo End of 5.0 tests
# #
......
...@@ -1240,7 +1240,17 @@ bool Item_name_const::is_null() ...@@ -1240,7 +1240,17 @@ bool Item_name_const::is_null()
Item::Type Item_name_const::type() const Item::Type Item_name_const::type() const
{ {
return value_item->type(); /*
As
1. one can try to create the Item_name_const passing non-constant
arguments, although it's incorrect and
2. the type() method can be called before the fix_fields() to get
type information for a further type cast, e.g.
if (item->type() == FIELD_ITEM)
((Item_field *) item)->...
we return NULL_ITEM in the case to avoid wrong casting.
*/
return valid_args ? value_item->type() : NULL_ITEM;
} }
......
...@@ -1242,11 +1242,13 @@ class Item_name_const : public Item ...@@ -1242,11 +1242,13 @@ class Item_name_const : public Item
{ {
Item *value_item; Item *value_item;
Item *name_item; Item *name_item;
bool valid_args;
public: public:
Item_name_const(Item *name_arg, Item *val): Item_name_const(Item *name_arg, Item *val):
value_item(val), name_item(name_arg) value_item(val), name_item(name_arg)
{ {
if(!value_item->basic_const_item()) if (!(valid_args= name_item->basic_const_item() &
value_item->basic_const_item()))
my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST"); my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
Item::maybe_null= TRUE; Item::maybe_null= TRUE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment