Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
The functions mem_root_dynamic_array_resize_and_set_val (include/my_sys.h) starts with following code:
static inline int mem_root_dynamic_array_resize_and_set_val(MEM_ROOT_DYNAMIC_ARRAY *array, |
const void *element, size_t idx) |
{
|
if (array->malloc_flags & MY_BUFFER_NO_RESIZE) |
return TRUE; |
|
|
if (idx >= array->max_element) |
{
|
if (mem_root_allocate_dynamic(array->mem_root, array, idx)) |
return 1; |
array->elements++;
|
}
|
...
|
The very first two lines returns TRUE (failure) when array is of fixed size.
In the Columnstore we have to use dynamic arrays with fixed size buffers when calling json_normalize. The normalization process then calls mem_root_dynamic_array_resize_and_set_val and this function with valid index and value arguments and it fails to set the value. The incorrect (unset) value then read by other parts of program resulting in crash.
A better code variant would be like this:
static inline int mem_root_dynamic_array_resize_and_set_val(MEM_ROOT_DYNAMIC_ARRAY *array, |
const void *element, size_t idx) |
{
|
if (idx >= array->max_element) |
{
|
if (array->malloc_flags & MY_BUFFER_NO_RESIZE) |
return TRUE; |
|
|
if (mem_root_allocate_dynamic(array->mem_root, array, idx)) |
return 1; |
array->elements++;
|
}
|
...
|
Here we fail only when index is too big. This particular code change allows Columnstore to use json_normalize function without problems.
Attachments
Issue Links
- blocks
-
MCOL-6685 basic.func_json_equals and basic.func_json_exists fails with Community server 12.3.3 and 13.1
-
- Confirmed
-