diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2018-08-18 01:14:49 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2018-08-18 01:16:31 +0530 |
commit | bf1c53e9be84437ada32393bb7b4a8ff06dbf369 (patch) | |
tree | 325cca23e6bf7b5b4b0f9d050ab46f63eefc466d /sql | |
parent | 3faed09d6d7cae54d01e7a5f988c057417f9df65 (diff) | |
download | mariadb-git-bf1c53e9be84437ada32393bb7b4a8ff06dbf369.tar.gz |
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
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 5 |
2 files changed, 5 insertions, 2 deletions
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 @@ public: */ 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 @@ public: 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..bb47988e3c0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -292,13 +292,14 @@ 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 && val->type() == Item::FIELD_ITEM && - ((Item_field*)val)->table_name) + if (val && (item_field= val->get_item_field()) && + item_field->table_name) { my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), sysvar->name.str); return TRUE; |