From 1a13dbff0175d74a0304d23b0d9e5624a982db74 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 5 Jan 2023 15:43:14 +0200 Subject: [PATCH] MDEV-30327 Client crashes in print_last_query_cost Fixed by calling init_pager() before tee_fprintf() --- client/mysql.cc | 3 +++ mysql-test/main/mysql.result | 3 +++ mysql-test/main/mysql.test | 11 ++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index a39bf36c016..9971410c0d8 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -4217,7 +4217,10 @@ static void print_last_query_cost() cur= mysql_fetch_row(result); if (strtod(cur[1], &end) != 0.0) + { + init_pager(); tee_fprintf(PAGER, "%s: %s\n\n", cur[0], cur[1]); + } end: mysql_free_result(result); diff --git a/mysql-test/main/mysql.result b/mysql-test/main/mysql.result index 0b91b513b17..1792f09d3ac 100644 --- a/mysql-test/main/mysql.result +++ b/mysql-test/main/mysql.result @@ -637,3 +637,6 @@ drop table t1; WARNING: option '--enable-cleartext-plugin' is obsolete. 1 1 +# +# MDEV-30327 Client crashes in print_last_query_cost +# diff --git a/mysql-test/main/mysql.test b/mysql-test/main/mysql.test index 0f41add821a..5aa130f8a4c 100644 --- a/mysql-test/main/mysql.test +++ b/mysql-test/main/mysql.test @@ -709,10 +709,19 @@ drop table t1; --echo # --exec $MYSQL -NHe "select 1 as a" - # # Test obsolete option --enable-cleartext-plugin # This should proceed with a warning # --echo --exec $MYSQL test --enable-cleartext-plugin -e "select 1" + +--echo # +--echo # MDEV-30327 Client crashes in print_last_query_cost +--echo # + +--disable_query_log +--disable_result_log +--exec $MYSQL --show-query-costs --port=$MASTER_MYPORT -e "show tables in mysql like 'foo'" +--enable_result_log +--enable_query_log