summaryrefslogtreecommitdiff
path: root/sql/opt_histogram_json.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2022-02-07 08:44:32 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2022-02-07 08:44:32 +0100
commit307b2991d61ff6734d858bdb211a88d1c8607a36 (patch)
tree35aee16dadbf2e0ea66ae0a92535bc29235e43bd /sql/opt_histogram_json.cc
parent34564587f4cc2065fefcc4cc80a96975bcdfcfd7 (diff)
downloadmariadb-git-307b2991d61ff6734d858bdb211a88d1c8607a36.tar.gz
Fix JSON statistics time format and added tests for it and server version.mariadb-10.8.1
Diffstat (limited to 'sql/opt_histogram_json.cc')
-rw-r--r--sql/opt_histogram_json.cc19
1 files changed, 5 insertions, 14 deletions
diff --git a/sql/opt_histogram_json.cc b/sql/opt_histogram_json.cc
index a749bc27e6e..6458059e5fe 100644
--- a/sql/opt_histogram_json.cc
+++ b/sql/opt_histogram_json.cc
@@ -178,22 +178,13 @@ private:
void append_histogram_params()
{
char buf[128];
+ String str(buf, sizeof(buf), system_charset_info);
+ THD *thd= current_thd;
+ timeval tv= {thd->query_start(), 0}; // we do not need microseconds
- time_t cur_time_t= my_time(0);
- struct tm curtime;
- localtime_r(&cur_time_t, &curtime);
-
- my_snprintf(buf, sizeof(buf), "%d-%02d-%02d %2d:%02d:%02d %s",
- curtime.tm_year + 1900,
- curtime.tm_mon+1,
- curtime.tm_mday,
- curtime.tm_hour,
- curtime.tm_min,
- curtime.tm_sec,
- system_time_zone);
-
+ Timestamp(tv).to_datetime(thd).to_string(&str, 0);
writer.add_member("target_histogram_size").add_ull(hist_width);
- writer.add_member("collected_at").add_str(buf);
+ writer.add_member("collected_at").add_str(str.ptr());
writer.add_member("collected_by").add_str(server_version);
}
/*