summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <sergey@mariadb.com>2023-04-24 17:57:45 +0300
committerSergei Petrunia <sergey@mariadb.com>2023-04-25 13:47:46 +0300
commita72b2c3ffb15541520de96c29ea482f80a57f46f (patch)
treeb775b902c792d873d14e6c188026c14d2676548f
parent29fb041007285c34d9c22dbc6359a2e9b9ea32f3 (diff)
downloadmariadb-git-a72b2c3ffb15541520de96c29ea482f80a57f46f.tar.gz
MDEV-31121: ANALYZE statement produces 0 for all timings in embedded server
Timers require my_timer_init() call. It was made only in mysqld_main(). Call it also from init_embedded_server().
-rw-r--r--libmysqld/lib_sql.cc2
-rw-r--r--mysql-test/main/analyze_format_json_emb.result11
-rw-r--r--mysql-test/main/analyze_format_json_emb.test18
3 files changed, 31 insertions, 0 deletions
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 5742a8d66ef..565a722e13b 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -565,6 +565,8 @@ int init_embedded_server(int argc, char **argv, char **groups)
if (ho_error != 0)
return 1;
+ my_timer_init(&sys_timer_info);
+
if (init_common_variables())
{
mysql_server_end();
diff --git a/mysql-test/main/analyze_format_json_emb.result b/mysql-test/main/analyze_format_json_emb.result
new file mode 100644
index 00000000000..d61e205f031
--- /dev/null
+++ b/mysql-test/main/analyze_format_json_emb.result
@@ -0,0 +1,11 @@
+#
+# MDEV-31121: ANALYZE statement produces 0 for all timings in embedded serve
+#
+create table t1 (a int);
+insert into t1 values (0),(0);
+set @js='$out';
+set @out=(select json_extract(@js,'$**.query_block.r_total_time_ms'));
+select cast(json_extract(@out,'$[0]') as DOUBLE) > 0;
+cast(json_extract(@out,'$[0]') as DOUBLE) > 0
+1
+drop table t1;
diff --git a/mysql-test/main/analyze_format_json_emb.test b/mysql-test/main/analyze_format_json_emb.test
new file mode 100644
index 00000000000..dcf6f24dd8e
--- /dev/null
+++ b/mysql-test/main/analyze_format_json_emb.test
@@ -0,0 +1,18 @@
+--source include/is_embedded.inc
+--source include/big_test.inc
+
+--echo #
+--echo # MDEV-31121: ANALYZE statement produces 0 for all timings in embedded serve
+--echo #
+create table t1 (a int);
+insert into t1 values (0),(0);
+let $out=`
+analyze format=json select sleep(1+a) from t1
+`;
+
+evalp set @js='$out';
+set @out=(select json_extract(@js,'$**.query_block.r_total_time_ms'));
+select cast(json_extract(@out,'$[0]') as DOUBLE) > 0;
+
+drop table t1;
+