Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mysql-test/main/change_master_default.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions mysql-test/main/change_master_default.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions sql/sql_yacc.yy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankly, I’d suggest avoiding breaking num_or_default back to NUM_literal and DEFAULT cases, and instead move the opt_plus under num_or_default’s definition.
But gkodinov and vuvova have already pushed the dissolution of num_or_default.

It’s true that master_heartbeat_period is the only decimal option in CHANGE MASTER, even in the foreseeable future.
But the motivation behind the X_or_defaults (at least the other ones) is to avoid repeating the MASTER_HEARTBEAT_PERIOD_SYM part of the definition, once for the explicit value and once for DEFAULT.
The ideal design was to pass both values and DEFAULTs uniformly to the options themselves… but the path to it turned out to be a lot longer than I could cram when working on MDEV-28302.

Inlining num_or_default’s branches into master_heartbeat_period’s definition also makes a seemingly complex change in contrast to moving the opt_plus.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — opt_plus is now part of num_or_default (num_or_default := opt_plus NUM_literal | DEFAULT), and the action code in master_def stays unified. Thanks for the suggestion.

Original file line number Diff line number Diff line change
Expand Up @@ -2423,14 +2423,14 @@ master_def:
{ mi->master_ssl_crlpath= path; };
}

| MASTER_HEARTBEAT_PERIOD_SYM '=' opt_plus num_or_default
Comment thread
prathamesh04 marked this conversation as resolved.
| 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
Expand Down Expand Up @@ -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; }
;

Expand Down