mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Merge 10.6 into 10.7
This commit is contained in:
@@ -260,6 +260,10 @@ static int json_nice(json_engine_t *je, String *nice_js,
|
||||
static const char *comma= ", ", *colon= "\": ";
|
||||
uint comma_len, colon_len;
|
||||
int first_value= 1;
|
||||
int value_size = 0;
|
||||
int curr_state= -1;
|
||||
int64_t value_len= 0;
|
||||
String curr_str{};
|
||||
|
||||
nice_js->length(0);
|
||||
nice_js->set_charset(je->s.cs);
|
||||
@@ -286,6 +290,7 @@ static int json_nice(json_engine_t *je, String *nice_js,
|
||||
|
||||
do
|
||||
{
|
||||
curr_state= je->state;
|
||||
switch (je->state)
|
||||
{
|
||||
case JST_KEY:
|
||||
@@ -333,17 +338,23 @@ handle_value:
|
||||
if (append_simple(nice_js, je->value_begin,
|
||||
je->value_end - je->value_begin))
|
||||
goto error;
|
||||
|
||||
|
||||
curr_str.copy((const char *)je->value_begin,
|
||||
je->value_end - je->value_begin, je->s.cs);
|
||||
value_len= je->value_end - je->value_begin;
|
||||
first_value= 0;
|
||||
if (value_size != -1)
|
||||
value_size++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mode == Item_func_json_format::DETAILED &&
|
||||
depth > 0 &&
|
||||
depth > 0 && !(curr_state != JST_KEY) &&
|
||||
append_tab(nice_js, depth, tab_size))
|
||||
goto error;
|
||||
nice_js->append((je->value_type == JSON_VALUE_OBJECT) ? "{" : "[", 1);
|
||||
first_value= 1;
|
||||
value_size= (je->value_type == JSON_VALUE_OBJECT) ? -1: 0;
|
||||
depth++;
|
||||
}
|
||||
|
||||
@@ -352,11 +363,27 @@ handle_value:
|
||||
case JST_OBJ_END:
|
||||
case JST_ARRAY_END:
|
||||
depth--;
|
||||
if (mode == Item_func_json_format::DETAILED &&
|
||||
if (mode == Item_func_json_format::DETAILED && (value_size > 1 || value_size == -1) &&
|
||||
append_tab(nice_js, depth, tab_size))
|
||||
goto error;
|
||||
|
||||
if (mode == Item_func_json_format::DETAILED &&
|
||||
value_size == 1 && je->state != JST_OBJ_END)
|
||||
{
|
||||
for (auto i = 0; i < value_len; i++)
|
||||
{
|
||||
nice_js->chop();
|
||||
}
|
||||
for (auto i = 0; i < (depth + 1) * tab_size + 1; i++)
|
||||
{
|
||||
nice_js->chop();
|
||||
}
|
||||
nice_js->append(curr_str);
|
||||
}
|
||||
|
||||
nice_js->append((je->state == JST_OBJ_END) ? "}": "]", 1);
|
||||
first_value= 0;
|
||||
value_size= -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Reference in New Issue
Block a user