revision-id: fe3739639c587e4df425672924ed2b0aa5bd5480 (mariadb-10.3.6-106-gfe3739639c5) parent(s): ead9a34a3e934f607c2ea7a6c68f7f6d9d29b5bd author: Varun Gupta committer: Varun Gupta timestamp: 2018-08-17 00:50:30 +0530 message: Fixed ASAN failure for the test main.func_misc. For Item name_const , we should never do typecast it to Item_field because we always expect it to be a constant value. So instead of checking the type() its better to introduce a function in the Item class get_item_field, which would return the item_field object for the item which have type of FIELD_ITEM --- sql/item.h | 2 ++ sql/sql_yacc.yy | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/item.h b/sql/item.h index c013781f30f..6f1f70c3cc7 100644 --- a/sql/item.h +++ b/sql/item.h @@ -881,6 +881,7 @@ 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(); @@ -3261,6 +3262,7 @@ 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() diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index cf894325ba5..1fb3041d523 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -297,7 +297,7 @@ LEX::set_system_variable(enum enum_var_type var_type, if (spcont && sysvar == Sys_autocommit_ptr) sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; - if (val && val->type() == Item::FIELD_ITEM && + if (val && val->get_item_field() && ((Item_field*)val)->table_name) { my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), sysvar->name.str);