Commit 2ccae65c authored by Varun Gupta's avatar Varun Gupta

Fixed ASAN failure for the test main.func_misc

Moved the checks for arguments validation of Item_name_const from the constructor
to Create_func_name_const::create_2_arg
Also reverted the fix bf1c53e9
parent 5abc79dd
......@@ -1960,25 +1960,6 @@ Item_name_const::Item_name_const(THD *thd, Item *name_arg, Item *val):
Item_fixed_hybrid(thd), value_item(val), name_item(name_arg)
{
Item::maybe_null= TRUE;
if (!name_item->basic_const_item())
goto err;
if (value_item->basic_const_item())
return; // ok
if (value_item->type() == FUNC_ITEM)
{
Item_func *value_func= (Item_func *) value_item;
if (value_func->functype() != Item_func::COLLATE_FUNC &&
value_func->functype() != Item_func::NEG_FUNC)
goto err;
if (value_func->key_item()->basic_const_item())
return; // ok
}
err:
my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
}
......
......@@ -881,7 +881,6 @@ class Item: public Value_source,
*/
String *val_str() { return val_str(&str_value); }
virtual Item_func *get_item_func() { return NULL; }
virtual Item_field *get_item_field() {return NULL;}
const MY_LOCALE *locale_from_val_str();
......@@ -3262,7 +3261,6 @@ class Item_field :public Item_ident,
longlong val_int_endpoint(bool left_endp, bool *incl_endp);
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
bool get_date_result(MYSQL_TIME *ltime,ulonglong fuzzydate);
Item_field* get_item_field() {return this;}
bool is_null() { return field->is_null(); }
void update_null_value();
void update_table_bitmaps()
......
......@@ -6103,7 +6103,26 @@ Create_func_name_const Create_func_name_const::s_singleton;
Item*
Create_func_name_const::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_name_const(thd, arg1, arg2);
if (!arg1->basic_const_item())
goto err;
if (arg2->basic_const_item())
return new (thd->mem_root) Item_name_const(thd, arg1, arg2);
if (arg2->type() == Item::FUNC_ITEM)
{
Item_func *value_func= (Item_func *) arg2;
if (value_func->functype() != Item_func::COLLATE_FUNC &&
value_func->functype() != Item_func::NEG_FUNC)
goto err;
if (!value_func->key_item()->basic_const_item())
goto err;
return new (thd->mem_root) Item_name_const(thd, arg1, arg2);
}
err:
my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
return NULL;
}
......
......@@ -292,14 +292,13 @@ LEX::set_system_variable(enum enum_var_type var_type,
Item *val)
{
set_var *setvar;
Item_field *item_field;
/* No AUTOCOMMIT from a stored function or trigger. */
if (spcont && sysvar == Sys_autocommit_ptr)
sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT;
if (val && (item_field= val->get_item_field()) &&
item_field->table_name)
if (val && val->type() == Item::FIELD_ITEM &&
((Item_field*)val)->table_name)
{
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), sysvar->name.str);
return 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