Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
111a752b
Commit
111a752b
authored
Jan 04, 2023
by
Weijun-H
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-19160 JSON_DETAILED output unnecessarily verbose
parent
fb0808c4
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
327 additions
and
279 deletions
+327
-279
mysql-test/main/func_json.result
mysql-test/main/func_json.result
+126
-0
mysql-test/main/func_json.test
mysql-test/main/func_json.test
+100
-0
mysql-test/main/opt_trace.result
mysql-test/main/opt_trace.result
+43
-175
mysql-test/main/opt_trace_index_merge.result
mysql-test/main/opt_trace_index_merge.result
+18
-84
mysql-test/main/opt_trace_ucs2.result
mysql-test/main/opt_trace_ucs2.result
+2
-7
mysql-test/main/range_notembedded.result
mysql-test/main/range_notembedded.result
+0
-1
mysql-test/suite/plugins/r/multiauth.result
mysql-test/suite/plugins/r/multiauth.result
+0
-3
sql/item_jsonfunc.cc
sql/item_jsonfunc.cc
+38
-9
No files found.
mysql-test/main/func_json.result
View file @
111a752b
...
@@ -1133,3 +1133,129 @@ DROP TABLE t1;
...
@@ -1133,3 +1133,129 @@ DROP TABLE t1;
#
#
# End of 10.4 tests
# End of 10.4 tests
#
#
#
# MDEV-19160 JSON_DETAILED output unnecessarily verbose
#
create table t200 (a text);
insert into t200 values
('{
"steps": [
{
"join_optimization": {
"select_id": 1,
"steps": [
{
"rows_estimation": [
{
"table": "t1",
"range_analysis": {
"table_scan": {
"rows": 1000,
"cost": 2e308
},
"potential_range_indexes": [
{
"index": "a_b",
"usable": true,
"key_parts": ["a", "b"]
}
],
"best_covering_index_scan": {
"index": "a_b",
"cost": 52.195,
"chosen": true
},
"setup_range_conditions": [],
"group_index_range": {
"chosen": false,
"cause": "no group by or distinct"
},
"analyzing_range_alternatives": {
"range_scan_alternatives": [
{
"index": "a_b",
"ranges": ["2 <= a <= 2 AND 4 <= b <= 4", "123"],
"rowid_ordered": true,
"using_mrr": false,
"index_only": true,
"rows": 1,
"cost": 1.1752,
"chosen": true
}
],
"analyzing_roworder_intersect": {
"cause": "too few roworder scans"
},
"analyzing_index_merge_union": [],
"test_one_line_array":["123"]
},
"chosen_range_access_summary": {
"range_access_plan": {
"type": "range_scan",
"index": "a_b",
"rows": 1,
"ranges": ["2 <= a <= 2 AND 4 <= b <= 4"]
},
"rows_for_plan": 1,
"cost_for_plan": 1.1752,
"chosen": true
}
}
},
{
"selectivity_for_indexes": [
{
"index_name": "a_b",
"selectivity_from_index": 0.001
}
],
"selectivity_for_columns": [],
"cond_selectivity": 0.001
}
]
}
]
}
},
{
"join_execution": {
"select_id": 1,
"steps": []
}
}
]
}');
select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200;
JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives'))
[
{
"range_scan_alternatives":
[
{
"index": "a_b",
"ranges":
[
"2 <= a <= 2 AND 4 <= b <= 4",
"123"
],
"rowid_ordered": true,
"using_mrr": false,
"index_only": true,
"rows": 1,
"cost": 1.1752,
"chosen": true
}
],
"analyzing_roworder_intersect":
{
"cause": "too few roworder scans"
},
"analyzing_index_merge_union":
[],
"test_one_line_array":
["123"]
}
]
select JSON_LOOSE(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200;
JSON_LOOSE(JSON_EXTRACT(a, '$**.analyzing_range_alternatives'))
[{"range_scan_alternatives": [{"index": "a_b", "ranges": ["2 <= a <= 2 AND 4 <= b <= 4", "123"], "rowid_ordered": true, "using_mrr": false, "index_only": true, "rows": 1, "cost": 1.1752, "chosen": true}], "analyzing_roworder_intersect": {"cause": "too few roworder scans"}, "analyzing_index_merge_union": [], "test_one_line_array": ["123"]}]
mysql-test/main/func_json.test
View file @
111a752b
...
@@ -718,3 +718,103 @@ DROP TABLE t1;
...
@@ -718,3 +718,103 @@ DROP TABLE t1;
--
echo
#
--
echo
#
--
echo
# End of 10.4 tests
--
echo
# End of 10.4 tests
--
echo
#
--
echo
#
--
echo
#
--
echo
# MDEV-19160 JSON_DETAILED output unnecessarily verbose
--
echo
#
create
table
t200
(
a
text
);
insert
into
t200
values
(
'{
"steps": [
{
"join_optimization": {
"select_id": 1,
"steps": [
{
"rows_estimation": [
{
"table": "t1",
"range_analysis": {
"table_scan": {
"rows": 1000,
"cost": 2e308
},
"potential_range_indexes": [
{
"index": "a_b",
"usable": true,
"key_parts": ["a", "b"]
}
],
"best_covering_index_scan": {
"index": "a_b",
"cost": 52.195,
"chosen": true
},
"setup_range_conditions": [],
"group_index_range": {
"chosen": false,
"cause": "no group by or distinct"
},
"analyzing_range_alternatives": {
"range_scan_alternatives": [
{
"index": "a_b",
"ranges": ["2 <= a <= 2 AND 4 <= b <= 4", "123"],
"rowid_ordered": true,
"using_mrr": false,
"index_only": true,
"rows": 1,
"cost": 1.1752,
"chosen": true
}
],
"analyzing_roworder_intersect": {
"cause": "too few roworder scans"
},
"analyzing_index_merge_union": [],
"test_one_line_array":["123"]
},
"chosen_range_access_summary": {
"range_access_plan": {
"type": "range_scan",
"index": "a_b",
"rows": 1,
"ranges": ["2 <= a <= 2 AND 4 <= b <= 4"]
},
"rows_for_plan": 1,
"cost_for_plan": 1.1752,
"chosen": true
}
}
},
{
"selectivity_for_indexes": [
{
"index_name": "a_b",
"selectivity_from_index": 0.001
}
],
"selectivity_for_columns": [],
"cond_selectivity": 0.001
}
]
}
]
}
},
{
"join_execution": {
"select_id": 1,
"steps": []
}
}
]
}'
);
select
JSON_DETAILED
(
JSON_EXTRACT
(
a
,
'$**.analyzing_range_alternatives'
))
from
t200
;
select
JSON_LOOSE
(
JSON_EXTRACT
(
a
,
'$**.analyzing_range_alternatives'
))
from
t200
;
mysql-test/main/opt_trace.result
View file @
111a752b
This diff is collapsed.
Click to expand it.
mysql-test/main/opt_trace_index_merge.result
View file @
111a752b
This diff is collapsed.
Click to expand it.
mysql-test/main/opt_trace_ucs2.result
View file @
111a752b
...
@@ -23,17 +23,13 @@ EXPLAIN
...
@@ -23,17 +23,13 @@ EXPLAIN
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
[
[
{
{
"range_scan_alternatives":
"range_scan_alternatives":
[
[
{
{
"index": "col1",
"index": "col1",
"ranges":
"ranges":
[
["(a) <= (col1)"],
"(a) <= (col1)"
],
"rowid_ordered": false,
"rowid_ordered": false,
"using_mrr": false,
"using_mrr": false,
"index_only": false,
"index_only": false,
...
@@ -47,8 +43,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
...
@@ -47,8 +43,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "too few roworder scans"
"cause": "too few roworder scans"
},
},
"analyzing_index_merge_union":
"analyzing_index_merge_union":
[
[]
]
}
}
]
]
drop table t1;
drop table t1;
mysql-test/main/range_notembedded.result
View file @
111a752b
...
@@ -20,7 +20,6 @@ select json_detailed(JSON_EXTRACT(trace, '$**.ranges'))
...
@@ -20,7 +20,6 @@ select json_detailed(JSON_EXTRACT(trace, '$**.ranges'))
from information_schema.optimizer_trace;
from information_schema.optimizer_trace;
json_detailed(JSON_EXTRACT(trace, '$**.ranges'))
json_detailed(JSON_EXTRACT(trace, '$**.ranges'))
[
[
[
[
"(1) <= (key1) <= (1)",
"(1) <= (key1) <= (1)",
"(2) <= (key1) <= (2)",
"(2) <= (key1) <= (2)",
...
...
mysql-test/suite/plugins/r/multiauth.result
View file @
111a752b
...
@@ -110,16 +110,13 @@ json_detailed(priv)
...
@@ -110,16 +110,13 @@ json_detailed(priv)
"authentication_string": "*7D8C3DF236D9163B6C274A9D47704BC496988460",
"authentication_string": "*7D8C3DF236D9163B6C274A9D47704BC496988460",
"auth_or":
"auth_or":
[
[
{
{
"plugin": "ed25519",
"plugin": "ed25519",
"authentication_string": "F4aF8bw7130VaRbdLCl4f/P/wkjDmgJXwWvpJ5gmsZc"
"authentication_string": "F4aF8bw7130VaRbdLCl4f/P/wkjDmgJXwWvpJ5gmsZc"
},
},
{
{
"plugin": "unix_socket"
"plugin": "unix_socket"
},
},
{
{
}
}
],
],
...
...
sql/item_jsonfunc.cc
View file @
111a752b
...
@@ -257,16 +257,22 @@ static int json_nice(json_engine_t *je, String *nice_js,
...
@@ -257,16 +257,22 @@ static int json_nice(json_engine_t *je, String *nice_js,
Item_func_json_format
::
formats
mode
,
int
tab_size
=
4
)
Item_func_json_format
::
formats
mode
,
int
tab_size
=
4
)
{
{
int
depth
=
0
;
int
depth
=
0
;
const
char
*
comma
,
*
colon
;
static
const
char
*
comma
=
", "
,
*
colon
=
"
\"
: "
;
uint
comma_len
,
colon_len
;
uint
comma_len
,
colon_len
;
int
first_value
=
1
;
int
first_value
=
1
;
int
value_size
=
0
;
DBUG_ASSERT
(
je
->
s
.
cs
==
nice_js
->
charset
());
int
curr_state
=
-
1
;
int64_t
value_len
=
0
;
String
curr_str
{};
nice_js
->
length
(
0
);
nice_js
->
set_charset
(
je
->
s
.
cs
);
nice_js
->
alloc
(
je
->
s
.
str_end
-
je
->
s
.
c_str
+
32
);
DBUG_ASSERT
(
mode
!=
Item_func_json_format
::
DETAILED
||
DBUG_ASSERT
(
mode
!=
Item_func_json_format
::
DETAILED
||
(
tab_size
>=
0
&&
tab_size
<=
TAB_SIZE_LIMIT
));
(
tab_size
>=
0
&&
tab_size
<=
TAB_SIZE_LIMIT
));
comma
=
", "
;
colon
=
"
\"
: "
;
if
(
mode
==
Item_func_json_format
::
LOOSE
)
if
(
mode
==
Item_func_json_format
::
LOOSE
)
{
{
comma_len
=
2
;
comma_len
=
2
;
...
@@ -285,6 +291,7 @@ static int json_nice(json_engine_t *je, String *nice_js,
...
@@ -285,6 +291,7 @@ static int json_nice(json_engine_t *je, String *nice_js,
do
do
{
{
curr_state
=
je
->
state
;
switch
(
je
->
state
)
switch
(
je
->
state
)
{
{
case
JST_KEY
:
case
JST_KEY
:
...
@@ -307,7 +314,7 @@ static int json_nice(json_engine_t *je, String *nice_js,
...
@@ -307,7 +314,7 @@ static int json_nice(json_engine_t *je, String *nice_js,
append_tab
(
nice_js
,
depth
,
tab_size
))
append_tab
(
nice_js
,
depth
,
tab_size
))
goto
error
;
goto
error
;
nice_js
->
append
(
"
\"
"
,
1
);
nice_js
->
append
(
'"'
);
append_simple
(
nice_js
,
key_start
,
key_end
-
key_start
);
append_simple
(
nice_js
,
key_start
,
key_end
-
key_start
);
nice_js
->
append
(
colon
,
colon_len
);
nice_js
->
append
(
colon
,
colon_len
);
}
}
...
@@ -332,17 +339,23 @@ static int json_nice(json_engine_t *je, String *nice_js,
...
@@ -332,17 +339,23 @@ static int json_nice(json_engine_t *je, String *nice_js,
if
(
append_simple
(
nice_js
,
je
->
value_begin
,
if
(
append_simple
(
nice_js
,
je
->
value_begin
,
je
->
value_end
-
je
->
value_begin
))
je
->
value_end
-
je
->
value_begin
))
goto
error
;
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
;
first_value
=
0
;
if
(
value_size
!=
-
1
)
value_size
++
;
}
}
else
else
{
{
if
(
mode
==
Item_func_json_format
::
DETAILED
&&
if
(
mode
==
Item_func_json_format
::
DETAILED
&&
depth
>
0
&&
depth
>
0
&&
!
(
curr_state
!=
JST_KEY
)
&&
append_tab
(
nice_js
,
depth
,
tab_size
))
append_tab
(
nice_js
,
depth
,
tab_size
))
goto
error
;
goto
error
;
nice_js
->
append
((
je
->
value_type
==
JSON_VALUE_OBJECT
)
?
"{"
:
"["
,
1
);
nice_js
->
append
((
je
->
value_type
==
JSON_VALUE_OBJECT
)
?
"{"
:
"["
,
1
);
first_value
=
1
;
first_value
=
1
;
value_size
=
(
je
->
value_type
==
JSON_VALUE_OBJECT
)
?
-
1
:
0
;
depth
++
;
depth
++
;
}
}
...
@@ -351,11 +364,27 @@ static int json_nice(json_engine_t *je, String *nice_js,
...
@@ -351,11 +364,27 @@ static int json_nice(json_engine_t *je, String *nice_js,
case
JST_OBJ_END
:
case
JST_OBJ_END
:
case
JST_ARRAY_END
:
case
JST_ARRAY_END
:
depth
--
;
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
))
append_tab
(
nice_js
,
depth
,
tab_size
))
goto
error
;
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
);
nice_js
->
append
((
je
->
state
==
JST_OBJ_END
)
?
"}"
:
"]"
,
1
);
first_value
=
0
;
first_value
=
0
;
value_size
=
-
1
;
break
;
break
;
default:
default:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment