From c043187846f911eb1095d28e4cbf58b1c0e65292 Mon Sep 17 00:00:00 2001 From: Geng Tian Date: Wed, 28 Jan 2026 20:06:23 +0000 Subject: [PATCH] MDEV-38454 CHANGE MASTER TO master_heartbeat_period does not accept numbers with `+` sign Fixed parser inconsistency where CHANGE MASTER TO master_heartbeat_period rejected numeric values with an explicit '+' sign, while other parameters like master_connect_retry accepted them. The issue was in sql/sql_yacc.yy where master_heartbeat_period used NUM_literal (which doesn't accept '+'), while other parameters used ulong_num (which includes opt_plus). Solution: Added opt_plus before NUM_literal in the master_heartbeat_period grammar rule, making it consistent with other numeric parameters. Added test case to verify: - master_heartbeat_period=+60 now works (was broken) - master_heartbeat_period=60 still works (backward compatible) - Consistent behavior across all CHANGE MASTER TO numeric parameters All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- mysql-test/suite/rpl/r/mdev_38454.result | 13 +++++++++ mysql-test/suite/rpl/t/mdev_38454.test | 37 ++++++++++++++++++++++++ sql/sql_yacc.yy | 4 +-- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/rpl/r/mdev_38454.result create mode 100644 mysql-test/suite/rpl/t/mdev_38454.test diff --git a/mysql-test/suite/rpl/r/mdev_38454.result b/mysql-test/suite/rpl/r/mdev_38454.result new file mode 100644 index 0000000000000..fc848e381f037 --- /dev/null +++ b/mysql-test/suite/rpl/r/mdev_38454.result @@ -0,0 +1,13 @@ +# Testing master_connect_retry with + sign (expected to work) +CHANGE MASTER TO master_connect_retry=+60; +# Success +# Testing master_connect_retry without + sign (expected to work) +CHANGE MASTER TO master_connect_retry=60; +# Success +# Testing master_heartbeat_period with + sign (should work) +CHANGE MASTER TO master_heartbeat_period=+60; +# Testing both without + sign (should work) +CHANGE MASTER TO master_connect_retry=60; +CHANGE MASTER TO master_heartbeat_period=60; +# Success +RESET SLAVE ALL; diff --git a/mysql-test/suite/rpl/t/mdev_38454.test b/mysql-test/suite/rpl/t/mdev_38454.test new file mode 100644 index 0000000000000..8e1ce1b2dddd6 --- /dev/null +++ b/mysql-test/suite/rpl/t/mdev_38454.test @@ -0,0 +1,37 @@ +# +# MDEV-38454: CHANGE MASTER TO master_heartbeat_period does not accept numbers with `+` sign +# +# Simple test to demonstrate the parser inconsistency has been fixed +# + +# +# Test master_connect_retry with explicit + sign (should work) +# +--echo # Testing master_connect_retry with + sign (expected to work) +CHANGE MASTER TO master_connect_retry=+60; +--echo # Success + +# +# Test master_connect_retry without explicit + sign (should work) +# +--echo # Testing master_connect_retry without + sign (expected to work) +CHANGE MASTER TO master_connect_retry=60; +--echo # Success + +# +# Test master_heartbeat_period with explicit + sign (should work after fix) +# +--echo # Testing master_heartbeat_period with + sign (should work) +CHANGE MASTER TO master_heartbeat_period=+60; + +# +# Test without + sign (should work for both) +# +--echo # Testing both without + sign (should work) +CHANGE MASTER TO master_connect_retry=60; +CHANGE MASTER TO master_heartbeat_period=60; +--echo # Success + + +# Reset +RESET SLAVE ALL; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7207f28bd062a..1b7e6350a4e07 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2373,9 +2373,9 @@ master_def: Lex->mi.ssl_crlpath= $3.str; } - | MASTER_HEARTBEAT_PERIOD_SYM '=' NUM_literal + | MASTER_HEARTBEAT_PERIOD_SYM '=' opt_plus NUM_literal { - Lex->mi.heartbeat_period= (float) $3->val_real(); + Lex->mi.heartbeat_period= (float) $4->val_real(); if (unlikely(Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD) || unlikely(Lex->mi.heartbeat_period < 0.0))