diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-08-08 17:12:32 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-08-08 17:12:32 +0200 |
commit | 1d480419822b53c840de54542c1d1a0851dbe2c8 (patch) | |
tree | 629aabba2d52741b4075c3e345396bd989516cb2 /sql/item_cmpfunc.cc | |
parent | 3ebbfd88a0360938e3a5a480265beb2a71b1268a (diff) | |
parent | 4f54c219e7c73072d7eff1e81e0f51dc1ff47509 (diff) | |
download | mariadb-git-1d480419822b53c840de54542c1d1a0851dbe2c8.tar.gz |
Merge branch '10.6' into 10.7
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 9123bd96d5e..c202a32c3be 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -318,7 +318,18 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item, field_item->field_type() != MYSQL_TYPE_YEAR) return 1; - if ((*item)->can_eval_in_optimize()) + /* + Replace (*item) with its value if the item can be computed. + + Do not replace items that contain aggregate functions: + There can be such items that are constants, e.g. COLLATION(AVG(123)), + but this function is called at Name Resolution phase. + Removing aggregate functions may confuse query plan generation code, e.g. + the optimizer might conclude that the query doesn't need to do grouping + at all. + */ + if ((*item)->can_eval_in_optimize() && + !(*item)->with_sum_func()) { TABLE *table= field->table; MY_BITMAP *old_maps[2] = { NULL, NULL }; @@ -780,7 +791,9 @@ int Arg_comparator::compare_e_string() { String *res1,*res2; res1= (*a)->val_str(&value1); + DBUG_ASSERT((res1 == NULL) == (*a)->null_value); res2= (*b)->val_str(&value2); + DBUG_ASSERT((res2 == NULL) == (*b)->null_value); if (!res1 || !res2) return MY_TEST(res1 == res2); return MY_TEST(sortcmp(res1, res2, compare_collation()) == 0); |