From 47595ec49907a9e3b10e9bc15edf30bd0608963b Mon Sep 17 00:00:00 2001 From: Prathamesh Hukkeri Date: Wed, 5 Aug 2026 16:04:48 +0530 Subject: [PATCH] MDEV-40122: `+DEFAULT` is not a valid value for master_heartbeat_period MDEV-28302 changed the grammar for master_heartbeat_period to accept DEFAULT (via num_or_default), while MDEV-38454 added an opt_plus to allow numeric values with an explicit `+` sign. The combination made the rule `opt_plus num_or_default`, which also accepted `+DEFAULT`, equivalent to `= DEFAULT`. Move the opt_plus under num_or_default's definition, so that `+` may only precede a numeric literal, and DEFAULT is a separate alternative. Now `master_heartbeat_period= +DEFAULT` is a syntax error again, while `= +45` and `= DEFAULT` are both accepted. --- mysql-test/main/change_master_default.result | 5 +++++ mysql-test/main/change_master_default.test | 9 +++++++++ sql/sql_yacc.yy | 8 ++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/change_master_default.result b/mysql-test/main/change_master_default.result index 71d76cca8182a..865361e670c31 100644 --- a/mysql-test/main/change_master_default.result +++ b/mysql-test/main/change_master_default.result @@ -258,6 +258,11 @@ master_ssl_crlpath using_gtid Slave_Pos master_retry_count 100000 slave_heartbeat_period 60.000 +# +# MDEV-40122: `+DEFAULT` is not a valid value for master_heartbeat_period +# +CHANGE MASTER TO master_heartbeat_period= +DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DEFAULT' at line 1 # Clean-up DROP PROCEDURE show_defaultable_fields; RESET SLAVE 'unset' ALL; diff --git a/mysql-test/main/change_master_default.test b/mysql-test/main/change_master_default.test index 971013dc3feed..37c937533f443 100644 --- a/mysql-test/main/change_master_default.test +++ b/mysql-test/main/change_master_default.test @@ -138,6 +138,15 @@ FROM information_schema.slave_status ORDER BY connection_name; --query_vertical CALL show_defaultable_fields() +--echo # +--echo # MDEV-40122: `+DEFAULT` is not a valid value for master_heartbeat_period +--echo # + +# The `+` prefix may only precede a numeric literal, not `DEFAULT` +--error ER_PARSE_ERROR +CHANGE MASTER TO master_heartbeat_period= +DEFAULT; + + --echo # Clean-up DROP PROCEDURE show_defaultable_fields; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 83f8edd72630a..ac0ecd9054082 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2423,14 +2423,14 @@ master_def: { mi->master_ssl_crlpath= path; }; } - | MASTER_HEARTBEAT_PERIOD_SYM '=' opt_plus num_or_default + | MASTER_HEARTBEAT_PERIOD_SYM '=' num_or_default { - if ($4) + if ($3) { uint32_t milliseconds; bool overprecise; auto decimal_buf= my_decimal(), - *decimal= $4->val_decimal(&decimal_buf); + *decimal= $3->val_decimal(&decimal_buf); DBUG_ASSERT(decimal); if (Master_info_file::Heartbeat_period_value::from_decimal( milliseconds, *decimal, overprecise @@ -2490,7 +2490,7 @@ master_use_gtid_enum: | DEFAULT { $$= enum_master_use_gtid::DEFAULT; } ; num_or_default: - NUM_literal { DBUG_ASSERT($$); } + opt_plus NUM_literal { DBUG_ASSERT($$); } | DEFAULT { $$= nullptr; } ;