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; } ;