summaryrefslogtreecommitdiff
path: root/sql/my_json_writer.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2015-04-12 04:48:42 +0300
committerSergei Petrunia <psergey@askmonty.org>2015-04-12 04:48:42 +0300
commit4938b822634b173c0d7ef882f721b553b223fadd (patch)
treef7fc465829170e1afb3816e940e4b8304502ff28 /sql/my_json_writer.cc
parent66ff1632f53ef2378c2f2546e0716547ee5d3217 (diff)
downloadmariadb-git-4938b822634b173c0d7ef882f721b553b223fadd.tar.gz
MDEV-7836: ANALYZE FORMAT=JSON should provide info about GROUP/ORDER BY
Provide basic info about sorting/grouping done by the queries.
Diffstat (limited to 'sql/my_json_writer.cc')
-rw-r--r--sql/my_json_writer.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc
index 7a3dc776093..e97db210da7 100644
--- a/sql/my_json_writer.cc
+++ b/sql/my_json_writer.cc
@@ -130,6 +130,27 @@ void Json_writer::add_ll(longlong val)
}
+/* Add a memory size, printing in Kb, Kb, Gb if necessary */
+void Json_writer::add_size(longlong val)
+{
+ char buf[64];
+ if (val < 1024)
+ my_snprintf(buf, sizeof(buf), "%ld", val);
+ else if (val < 1024*1024*16)
+ {
+ /* Values less than 16MB are specified in KB for precision */
+ size_t len= my_snprintf(buf, sizeof(buf), "%ld", val/1024);
+ strcpy(buf + len, "Kb");
+ }
+ else
+ {
+ size_t len= my_snprintf(buf, sizeof(buf), "%ld", val/(1024*1024));
+ strcpy(buf + len, "Mb");
+ }
+ add_str(buf);
+}
+
+
void Json_writer::add_double(double val)
{
char buf[64];