Commit f612e1c2 authored by Sergei Golubchik's avatar Sergei Golubchik Committed by Rucha Deodhar

MDEV-26182 fixes for --ps

* invoke parent's cleanup()
* don't reinit memroot, if already inited (causes memory leak)

also move free_root() from destructor to cleanup() to not accumulate
allocations from prepare and multiple executes
parent 49088c91
......@@ -5207,7 +5207,8 @@ bool Item_func_json_array_intersect::fix_length_and_dec(THD *thd)
Scan value uses the hash table to get the intersection of two arrays.
*/
init_alloc_root(PSI_NOT_INSTRUMENTED, &hash_root, 1024, 0, MYF(0));
if (!root_inited)
init_alloc_root(PSI_NOT_INSTRUMENTED, &hash_root, 1024, 0, MYF(0));
root_inited= true;
if (json_read_value(&je1) || je1.value_type != JSON_VALUE_ARRAY ||
......@@ -5360,7 +5361,8 @@ bool Item_func_json_object_filter_keys::fix_length_and_dec(THD *thd)
json_scan_start(&je2, js2->charset(),(const uchar *) js2->ptr(),
(const uchar *) js2->ptr() + js2->length());
init_alloc_root(PSI_NOT_INSTRUMENTED, &hash_root, 1024, 0, MYF(0));
if (!root_inited)
init_alloc_root(PSI_NOT_INSTRUMENTED, &hash_root, 1024, 0, MYF(0));
root_inited= true;
if (json_read_value(&je2) || je2.value_type != JSON_VALUE_ARRAY ||
......
......@@ -902,11 +902,9 @@ class Item_func_json_array_intersect: public Item_str_func
{ return get_item_copy<Item_func_json_array_intersect>(thd, this); }
void cleanup() override
{
Item_str_func::cleanup();
if (hash_inited)
my_hash_free(&items);
}
~Item_func_json_array_intersect()
{
if (root_inited)
free_root(&hash_root, MYF(0));
}
......@@ -934,11 +932,9 @@ class Item_func_json_object_filter_keys: public Item_str_func
void cleanup() override
{
Item_str_func::cleanup();
if (hash_inited)
my_hash_free(&items);
}
~Item_func_json_object_filter_keys()
{
if (root_inited)
free_root(&hash_root, MYF(0));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment