Skip to content

Commit c88e37f

Browse files
committed
MDEV-27204: [ERROR] Json_writer: a member name was expected, Assertion `got_name
[Adjusting Sergei Krivonos's patch] "duplicates_removal" may contain multiple elements inside it and so should have a JSON array as a value (and not object).
1 parent 1e8bcbd commit c88e37f

File tree

3 files changed

+86
-13
lines changed

3 files changed

+86
-13
lines changed

mysql-test/main/explain_json.result

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -842,20 +842,22 @@ EXPLAIN
842842
}
843843
},
844844
{
845-
"duplicates_removal": {
846-
"block-nl-join": {
847-
"table": {
848-
"table_name": "t1",
849-
"access_type": "ALL",
850-
"rows": 10,
851-
"filtered": 100
852-
},
853-
"buffer_type": "flat",
854-
"buffer_size": "206",
855-
"join_type": "BNL",
856-
"attached_condition": "t1.b = t2.b and t1.a = t2.a"
845+
"duplicates_removal": [
846+
{
847+
"block-nl-join": {
848+
"table": {
849+
"table_name": "t1",
850+
"access_type": "ALL",
851+
"rows": 10,
852+
"filtered": 100
853+
},
854+
"buffer_type": "flat",
855+
"buffer_size": "206",
856+
"join_type": "BNL",
857+
"attached_condition": "t1.b = t2.b and t1.a = t2.a"
858+
}
857859
}
858-
}
860+
]
859861
}
860862
]
861863
}
@@ -1941,3 +1943,60 @@ EXPLAIN
19411943
}
19421944
}
19431945
drop table t1;
1946+
#
1947+
# MDEV-27204: [ERROR] Json_writer: a member name was expected, Assertion `got_name == named_item_expected()' failed
1948+
#
1949+
CREATE TABLE t1 (a INT);
1950+
INSERT INTO t1 VALUES (1),(2);
1951+
explain FORMAT=JSON
1952+
SELECT * FROM t1 t0
1953+
WHERE t0.a IN (SELECT t2.a FROM t1 t2 WHERE t0.a IN (SELECT t3.a FROM t1 t3));
1954+
EXPLAIN
1955+
{
1956+
"query_block": {
1957+
"select_id": 1,
1958+
"nested_loop": [
1959+
{
1960+
"table": {
1961+
"table_name": "t0",
1962+
"access_type": "ALL",
1963+
"rows": 2,
1964+
"filtered": 100
1965+
}
1966+
},
1967+
{
1968+
"duplicates_removal": [
1969+
{
1970+
"block-nl-join": {
1971+
"table": {
1972+
"table_name": "t2",
1973+
"access_type": "ALL",
1974+
"rows": 2,
1975+
"filtered": 100
1976+
},
1977+
"buffer_type": "flat",
1978+
"buffer_size": "152",
1979+
"join_type": "BNL",
1980+
"attached_condition": "t2.a = t0.a"
1981+
}
1982+
},
1983+
{
1984+
"block-nl-join": {
1985+
"table": {
1986+
"table_name": "t3",
1987+
"access_type": "ALL",
1988+
"rows": 2,
1989+
"filtered": 100
1990+
},
1991+
"buffer_type": "incremental",
1992+
"buffer_size": "109",
1993+
"join_type": "BNL",
1994+
"attached_condition": "t3.a = t0.a"
1995+
}
1996+
}
1997+
]
1998+
}
1999+
]
2000+
}
2001+
}
2002+
DROP TABLE t1;

mysql-test/main/explain_json.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,13 @@ explain format=json select * from t1 order by a desc, b desc;
419419
explain format=json select * from t1 order by a desc, b ;
420420
drop table t1;
421421

422+
--echo #
423+
--echo # MDEV-27204: [ERROR] Json_writer: a member name was expected, Assertion `got_name == named_item_expected()' failed
424+
--echo #
425+
426+
CREATE TABLE t1 (a INT);
427+
INSERT INTO t1 VALUES (1),(2);
428+
explain FORMAT=JSON
429+
SELECT * FROM t1 t0
430+
WHERE t0.a IN (SELECT t2.a FROM t1 t2 WHERE t0.a IN (SELECT t3.a FROM t1 t3));
431+
DROP TABLE t1;

sql/sql_explain.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,12 +1100,16 @@ print_explain_json_interns(Explain_query *query,
11001100
{
11011101
writer->start_object();
11021102
writer->add_member("duplicates_removal");
1103+
writer->start_array();
11031104
}
11041105

11051106
join_tabs[i]->print_explain_json(query, writer, is_analyze);
11061107

11071108
if (join_tabs[i]->end_dups_weedout)
1109+
{
1110+
writer->end_array();
11081111
writer->end_object();
1112+
}
11091113
}
11101114
} // "nested_loop"
11111115
print_explain_json_for_children(query, writer, is_analyze);

0 commit comments

Comments
 (0)