Skip to content

Commit

Permalink
Bug#35846221: Assertion Failure in /mysql-8.0.34/sql/field.cc:7119
Browse files Browse the repository at this point in the history
Problem is due to missing implementation of
Item_func_make_set::fix_after_pullout(), which makes this particular
MAKE_SET function be regarded as const and may thus be evaluated
during resolving.

Fixed by implementing a proper fix_after_pullout() function.

Change-Id: I7094869588ce4133c4a925e1a237a37866a5bb3c
(cherry picked from commit a9f0b388adeef837811fdba2bce2e4ba5b06863b)
  • Loading branch information
roylyseng authored and suhgoel committed Dec 12, 2023
1 parent cc214c1 commit 3cd7cd2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
30 changes: 30 additions & 0 deletions sql/item_strfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3310,6 +3310,36 @@ void Item_func_make_set::fix_length_and_dec()
with_sum_func= with_sum_func || item->with_sum_func;
}

bool Item_func_make_set::fix_fields(THD *thd, Item **ref) {
assert(!fixed);
if (!item->fixed && item->fix_fields(thd, &item)) {
return true;
}
if (item->check_cols(1)) {
return true;
}
if (Item_func::fix_fields(thd, ref)) {
return true;
}
if (item->maybe_null) {
maybe_null = true;
}

used_tables_cache|= item->used_tables();
not_null_tables_cache|= item->not_null_tables();
const_item_cache&= item->const_item();

return false;
}

void Item_func_make_set::fix_after_pullout(st_select_lex *parent_select,
st_select_lex *removed_select) {
Item_func::fix_after_pullout(parent_select, removed_select);
item->fix_after_pullout(parent_select, removed_select);
used_tables_cache|= item->used_tables();
not_null_tables_cache|= item->not_null_tables();
const_item_cache&= item->const_item();
}

void Item_func_make_set::update_used_tables()
{
Expand Down
12 changes: 3 additions & 9 deletions sql/item_strfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -834,15 +834,9 @@ class Item_func_make_set :public Item_str_func

virtual bool itemize(Parse_context *pc, Item **res);
String *val_str(String *str);
bool fix_fields(THD *thd, Item **ref)
{
assert(fixed == 0);
bool res= ((!item->fixed && item->fix_fields(thd, &item)) ||
item->check_cols(1) ||
Item_func::fix_fields(thd, ref));
maybe_null|= item->maybe_null;
return res;
}
bool fix_fields(THD *thd, Item **ref);
void fix_after_pullout(st_select_lex *parent_select,
st_select_lex *removed_select);
void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &fields);
void fix_length_and_dec();
Expand Down

0 comments on commit 3cd7cd2

Please sign in to comment.