Hi Sergei,
commit eb7d6304a2aa168e09d48f6884dadf8c9f868feb Author: Sergei Krivonos <sergei.krivonos@mariadb.com> Date: Mon Nov 15 01:37:04 2021 +0200
do not output empty subqueries in traces
This reads as if the trace can have an empty clause describing a subquery. This is very confusing. Actually, the patch removes potential empty "subqueries" arrays. Do you have a testcase for this? I'm trying to find one with grep -rn -A1 '"subqueries"' mysql-test/{main,suite} and I can't.
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 499b6dbc97a..9a9bf786d62 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -25,6 +25,8 @@ #include "opt_range.h" #include "sql_expression_cache.h"
+#include <algorithm> + Is this needed? It seems to work without it.
+ bool Explain_node::has_json_printable_connection_objects(Explain_query *query) const + { + auto n= children.elements(); + if (n) + { + for (; n--;) + { Why such a convoluted loop inside an if statement? Can you make the code simpler by using
for (n=0; n < children.elements(); n++) { if (is_connection_printable_in_json(children.at(i)->connection_type)) return true; } return false; ?
+ auto node= query->get_node(children.at(n)); + /* Derived tables are printed inside Explain_table_access objects */ + + if (!is_connection_printable_in_json(node->connection_type)) + continue; + + return true; + } + } + return false; + }
BR Sergei -- Sergei Petrunia, Software Developer MariaDB Corporation | Skype: sergefp | Blog: http://petrunia.net