summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2021-12-09 16:49:40 +0300
committerSergei Petrunia <psergey@askmonty.org>2021-12-09 16:49:40 +0300
commitc88e37ff857a83387c4d86829fbaf2e277e4cf9f (patch)
treee24cc4fb24a448a32fae9fb11a132112d0bba411
parent1e8bcbd0a0bfa07052e9458830672ea215c8664a (diff)
downloadmariadb-git-c88e37ff857a83387c4d86829fbaf2e277e4cf9f.tar.gz
MDEV-27204: [ERROR] Json_writer: a member name was expected, Assertion `got_namebb-10.8-MDEV-27204-v2
[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).
-rw-r--r--mysql-test/main/explain_json.result85
-rw-r--r--mysql-test/main/explain_json.test10
-rw-r--r--sql/sql_explain.cc4
3 files changed, 86 insertions, 13 deletions
diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result
index 35f2d11c8b6..810ececc65c 100644
--- a/mysql-test/main/explain_json.result
+++ b/mysql-test/main/explain_json.result
@@ -842,20 +842,22 @@ EXPLAIN
}
},
{
- "duplicates_removal": {
- "block-nl-join": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 10,
- "filtered": 100
- },
- "buffer_type": "flat",
- "buffer_size": "206",
- "join_type": "BNL",
- "attached_condition": "t1.b = t2.b and t1.a = t2.a"
+ "duplicates_removal": [
+ {
+ "block-nl-join": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 10,
+ "filtered": 100
+ },
+ "buffer_type": "flat",
+ "buffer_size": "206",
+ "join_type": "BNL",
+ "attached_condition": "t1.b = t2.b and t1.a = t2.a"
+ }
}
- }
+ ]
}
]
}
@@ -1941,3 +1943,60 @@ EXPLAIN
}
}
drop table t1;
+#
+# MDEV-27204: [ERROR] Json_writer: a member name was expected, Assertion `got_name == named_item_expected()' failed
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+explain FORMAT=JSON
+SELECT * FROM t1 t0
+WHERE t0.a IN (SELECT t2.a FROM t1 t2 WHERE t0.a IN (SELECT t3.a FROM t1 t3));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "t0",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ }
+ },
+ {
+ "duplicates_removal": [
+ {
+ "block-nl-join": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ },
+ "buffer_type": "flat",
+ "buffer_size": "152",
+ "join_type": "BNL",
+ "attached_condition": "t2.a = t0.a"
+ }
+ },
+ {
+ "block-nl-join": {
+ "table": {
+ "table_name": "t3",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ },
+ "buffer_type": "incremental",
+ "buffer_size": "109",
+ "join_type": "BNL",
+ "attached_condition": "t3.a = t0.a"
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
+DROP TABLE t1;
diff --git a/mysql-test/main/explain_json.test b/mysql-test/main/explain_json.test
index cfbc0cfa10c..3767939d3e3 100644
--- a/mysql-test/main/explain_json.test
+++ b/mysql-test/main/explain_json.test
@@ -419,3 +419,13 @@ explain format=json select * from t1 order by a desc, b desc;
explain format=json select * from t1 order by a desc, b ;
drop table t1;
+--echo #
+--echo # MDEV-27204: [ERROR] Json_writer: a member name was expected, Assertion `got_name == named_item_expected()' failed
+--echo #
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+explain FORMAT=JSON
+SELECT * FROM t1 t0
+WHERE t0.a IN (SELECT t2.a FROM t1 t2 WHERE t0.a IN (SELECT t3.a FROM t1 t3));
+DROP TABLE t1;
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 44654dc2e3d..4fd4e6d3b77 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1100,12 +1100,16 @@ print_explain_json_interns(Explain_query *query,
{
writer->start_object();
writer->add_member("duplicates_removal");
+ writer->start_array();
}
join_tabs[i]->print_explain_json(query, writer, is_analyze);
if (join_tabs[i]->end_dups_weedout)
+ {
+ writer->end_array();
writer->end_object();
+ }
}
} // "nested_loop"
print_explain_json_for_children(query, writer, is_analyze);