MDEV-32733: Two JSON related tests running in PS mode fail on server built...
MDEV-32733: Two JSON related tests running in PS mode fail on server built with -DWITH_PROTECT_STATEMENT_MEMROOT=YES The tests main.func_json and json.json_no_table fail on server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT=YES by the reason that a memory is allocated on the statement's memory root on the second execution of a query that uses the function json_contains_path(). The reason that a memory is allocated on second execution of a prepared statement that ivokes the function json_contains_path() is that a memory allocated on every call of the method Item_json_str_multipath::fix_fields To fix the issue, memory allocation should be done only once on first call of the method Item_json_str_multipath::fix_fields. Simmilar issue take place inside the method Item_func_json_contains_path::fix_fields. Both methods are modified to make memory allocation only once on its first execution and later re-use the allocated memory. Before this patch the memory referenced by the pointers stored in the array tmp_paths were released by the method Item_func_json_contains_path::cleanup that is called on finishing execution of a prepared statement. Now that memory allocation performed inside the method Item_json_str_multipath::fix_fields is done only once, the item clean up has degenerate form and can be delegated to the cleanup() method of the base class and memory deallocation can be performed in the destructor.
Showing
Please register or sign in to comment