Skip to content

Commit c2e746c

Browse files
author
Chaithra Gopalareddy
committed
Bug#35686058: Crashing the MySQL server
This is duplicate of Bug#35284734. Back porting that bugfix to 8.0. Reference count for items created by IN to EXISTS transformation was not correct because of which there was a problem. With this patch we correct it. Change-Id: Ie470a47486d1d549ef299b4e28ac5dcc234aff9a
1 parent b080e7d commit c2e746c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

sql/item_cmpfunc.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,21 @@ bool Arg_comparator::compare_null_values() {
20542054
return result;
20552055
}
20562056

2057+
void Item_bool_func::set_created_by_in2exists() {
2058+
m_created_by_in2exists = true;
2059+
// When a condition is created by IN to EXISTS transformation,
2060+
// it re-uses the expressions that are part of the query. As a
2061+
// result we need to increment the reference count
2062+
// for these expressions.
2063+
WalkItem(this, enum_walk::PREFIX | enum_walk::SUBQUERY, [](Item *inner_item) {
2064+
// Reference counting matters only for referenced items.
2065+
if (inner_item->type() == REF_ITEM) {
2066+
down_cast<Item_ref *>(inner_item)->ref_item()->increment_ref_count();
2067+
}
2068+
return false;
2069+
});
2070+
}
2071+
20572072
const char *Item_bool_func::bool_transform_names[10] = {"is true",
20582073
"is false",
20592074
"is null",

sql/item_cmpfunc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ class Item_bool_func : public Item_int_func {
329329
}
330330
uint decimal_precision() const override { return 1; }
331331
bool created_by_in2exists() const override { return m_created_by_in2exists; }
332-
void set_created_by_in2exists() { m_created_by_in2exists = true; }
332+
void set_created_by_in2exists();
333333

334334
static const char *bool_transform_names[10];
335335
/**

0 commit comments

Comments
 (0)