diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-04-22 14:01:58 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-04-22 14:01:58 +0400 |
commit | 279b50b4eb69f882510f069e79715c38dc13355e (patch) | |
tree | 115d0e09a5906c1673781fe7a3eba8556846ce6a /sql/item.h | |
parent | f4b27400185bab217da11f8781eebb09a8502304 (diff) | |
download | mariadb-git-279b50b4eb69f882510f069e79715c38dc13355e.tar.gz |
MDEV-14041 Server crashes in String::length on queries with functions and ROLLUP
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sql/item.h b/sql/item.h index 4b93d3f9164..5c432887ed9 100644 --- a/sql/item.h +++ b/sql/item.h @@ -663,6 +663,45 @@ protected: SEL_TREE *get_mm_tree_for_const(RANGE_OPT_PARAM *param); Field *create_tmp_field(bool group, TABLE *table, uint convert_int_length); + /* Helper methods, to get an Item value from another Item */ + double val_real_from_item(Item *item) + { + DBUG_ASSERT(fixed == 1); + double value= item->val_real(); + null_value= item->null_value; + return value; + } + longlong val_int_from_item(Item *item) + { + DBUG_ASSERT(fixed == 1); + longlong value= item->val_int(); + null_value= item->null_value; + return value; + } + String *val_str_from_item(Item *item, String *str) + { + DBUG_ASSERT(fixed == 1); + String *res= item->val_str(str); + if (res) + res->set_charset(collation.collation); + if ((null_value= item->null_value)) + res= NULL; + return res; + } + my_decimal *val_decimal_from_item(Item *item, my_decimal *decimal_value) + { + DBUG_ASSERT(fixed == 1); + my_decimal *value= item->val_decimal(decimal_value); + if ((null_value= item->null_value)) + value= NULL; + return value; + } + bool get_date_from_item(Item *item, MYSQL_TIME *ltime, ulonglong fuzzydate) + { + bool rc= item->get_date(ltime, fuzzydate); + null_value= MY_TEST(rc || item->null_value); + return rc; + } /* This method is used if the item was not null but convertion to TIME/DATE/DATETIME failed. We return a zero date if allowed, |