Skip to content

Commit 1a13dbf

Browse files
committed
MDEV-30327 Client crashes in print_last_query_cost
Fixed by calling init_pager() before tee_fprintf()
1 parent 8d4bccf commit 1a13dbf

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

client/mysql.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4217,7 +4217,10 @@ static void print_last_query_cost()
42174217

42184218
cur= mysql_fetch_row(result);
42194219
if (strtod(cur[1], &end) != 0.0)
4220+
{
4221+
init_pager();
42204222
tee_fprintf(PAGER, "%s: %s\n\n", cur[0], cur[1]);
4223+
}
42214224

42224225
end:
42234226
mysql_free_result(result);

mysql-test/main/mysql.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,3 +637,6 @@ drop table t1;
637637
WARNING: option '--enable-cleartext-plugin' is obsolete.
638638
1
639639
1
640+
#
641+
# MDEV-30327 Client crashes in print_last_query_cost
642+
#

mysql-test/main/mysql.test

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,10 +709,19 @@ drop table t1;
709709
--echo #
710710
--exec $MYSQL -NHe "select 1 as a"
711711

712-
713712
#
714713
# Test obsolete option --enable-cleartext-plugin
715714
# This should proceed with a warning
716715
#
717716
--echo
718717
--exec $MYSQL test --enable-cleartext-plugin -e "select 1"
718+
719+
--echo #
720+
--echo # MDEV-30327 Client crashes in print_last_query_cost
721+
--echo #
722+
723+
--disable_query_log
724+
--disable_result_log
725+
--exec $MYSQL --show-query-costs --port=$MASTER_MYPORT -e "show tables in mysql like 'foo'"
726+
--enable_result_log
727+
--enable_query_log

0 commit comments

Comments
 (0)