[Commits] 4dc2b6b7180: MDEV-18479, post fix after merge to 10.1

Sergei Petrunia psergey at askmonty.org
Fri May 31 12:47:15 EEST 2019


revision-id: 4dc2b6b7180991e27c5a7d9cad1273791c14a6b5 (mariadb-10.1.39-53-g4dc2b6b7180)
parent(s): a8abbeb66376bb990da685c9492abec8b4d623f3
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2019-05-31 12:47:15 +0300
message:

MDEV-18479, post fix after merge to 10.1

Make the EXPLAIN [FORMAT=JSON] print very large #rows values properly,
as unsigned int64.

---
 mysql-test/r/derived_view.result | 14 +++++++-------
 sql/my_json_writer.cc            |  7 +++++++
 sql/my_json_writer.h             |  1 +
 sql/sql_explain.cc               |  8 ++++----
 4 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result
index 4320aec430e..f3c7c66a240 100644
--- a/mysql-test/r/derived_view.result
+++ b/mysql-test/r/derived_view.result
@@ -2953,13 +2953,13 @@ id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	p10	ALL	NULL	NULL	NULL	NULL	550	Using where; Using join buffer (incremental, BNL join)
 1	PRIMARY	<derived17>	ALL	NULL	NULL	NULL	NULL	50328437500000	Using where; Using join buffer (incremental, BNL join)
 1	PRIMARY	<derived14>	ALL	NULL	NULL	NULL	NULL	27680640625000000	Using where; Using join buffer (incremental, BNL join)
-1	PRIMARY	<derived9>	ALL	NULL	NULL	NULL	NULL	-3222391729959550976	Using where; Using join buffer (incremental, BNL join)
-1	PRIMARY	<derived10>	ALL	NULL	NULL	NULL	NULL	-3222391729959550976	Using where; Using join buffer (incremental, BNL join)
-1	PRIMARY	<derived11>	ALL	NULL	NULL	NULL	NULL	-3222391729959550976	Using where; Using join buffer (incremental, BNL join)
-1	PRIMARY	<derived12>	ALL	NULL	NULL	NULL	NULL	-3222391729959550976	Using where; Using join buffer (incremental, BNL join)
-1	PRIMARY	<derived13>	ALL	NULL	NULL	NULL	NULL	-3222391729959550976	Using where; Using join buffer (incremental, BNL join)
-1	PRIMARY	<derived15>	ALL	NULL	NULL	NULL	NULL	-3222391729959550976	Using where; Using join buffer (incremental, BNL join)
-1	PRIMARY	<derived16>	ALL	NULL	NULL	NULL	NULL	-3222391729959550976	Using where; Using join buffer (incremental, BNL join)
+1	PRIMARY	<derived9>	ALL	NULL	NULL	NULL	NULL	15224352343750000640	Using where; Using join buffer (incremental, BNL join)
+1	PRIMARY	<derived10>	ALL	NULL	NULL	NULL	NULL	15224352343750000640	Using where; Using join buffer (incremental, BNL join)
+1	PRIMARY	<derived11>	ALL	NULL	NULL	NULL	NULL	15224352343750000640	Using where; Using join buffer (incremental, BNL join)
+1	PRIMARY	<derived12>	ALL	NULL	NULL	NULL	NULL	15224352343750000640	Using where; Using join buffer (incremental, BNL join)
+1	PRIMARY	<derived13>	ALL	NULL	NULL	NULL	NULL	15224352343750000640	Using where; Using join buffer (incremental, BNL join)
+1	PRIMARY	<derived15>	ALL	NULL	NULL	NULL	NULL	15224352343750000640	Using where; Using join buffer (incremental, BNL join)
+1	PRIMARY	<derived16>	ALL	NULL	NULL	NULL	NULL	15224352343750000640	Using where; Using join buffer (incremental, BNL join)
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (incremental, BNL join)
 1	PRIMARY	<derived8>	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (incremental, BNL join)
 17	DERIVED	t2	system	NULL	NULL	NULL	NULL	1	
diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc
index 72b000df639..22c66ba7a34 100644
--- a/sql/my_json_writer.cc
+++ b/sql/my_json_writer.cc
@@ -129,6 +129,13 @@ void Json_writer::add_ll(longlong val)
   add_unquoted_str(buf);
 }
 
+void Json_writer::add_ull(ulonglong val)
+{
+  char buf[64];
+  my_snprintf(buf, sizeof(buf), "%llu", val);
+  add_unquoted_str(buf);
+}
+
 
 /* Add a memory size, printing in Kb, Kb, Gb if necessary */
 void Json_writer::add_size(longlong val)
diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h
index 349a1f380da..ffee6db4c03 100644
--- a/sql/my_json_writer.h
+++ b/sql/my_json_writer.h
@@ -108,6 +108,7 @@ class Json_writer
   void add_str(const String &str);
 
   void add_ll(longlong val);
+  void add_ull(ulonglong val);
   void add_size(longlong val);
   void add_double(double val);
   void add_bool(bool val);
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index c8576136069..2fa4b2cb3ae 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1223,7 +1223,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
   if (rows_set)
   {
     item_list.push_back(new (mem_root)
-                        Item_int(thd, (longlong) (ulonglong) rows,
+                        Item_int(thd, (ulonglong) rows,
                                  MY_INT64_NUM_DECIMAL_DIGITS),
                         mem_root);
   }
@@ -1601,7 +1601,7 @@ void Explain_table_access::print_explain_json(Explain_query *query,
   
   /* `rows` */
   if (rows_set)
-    writer->add_member("rows").add_ll(rows);
+    writer->add_member("rows").add_ull(rows);
 
   /* `r_rows` */
   if (is_analyze)
@@ -2239,7 +2239,7 @@ void Explain_update::print_explain_json(Explain_query *query,
   }
   
   /* `rows` */
-  writer->add_member("rows").add_ll(rows);
+  writer->add_member("rows").add_ull(rows);
 
 
   if (mrr_type.length() != 0)
@@ -2268,7 +2268,7 @@ void Explain_update::print_explain_json(Explain_query *query,
           r_rows= 0;
         r_filtered= buf_tracker.get_filtered_after_where() * 100.0;
       }
-      writer->add_member("r_rows").add_ll(r_rows);
+      writer->add_member("r_rows").add_ull(r_rows);
       writer->add_member("r_filtered").add_double(r_filtered);
     }
     else /* Not doing buffering */


More information about the commits mailing list