-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-8235: Expose check_slave_start_position as SQL function GTID_CHECK_POS() #4956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bd30bf6
ebb7195
7c26bf7
cf68c81
2ff319c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # | ||
| # MDEV-8235 Expose check_slave_start_position as SQL function | ||
| # | ||
| # 1. Set up some basic GTID history | ||
| CREATE TABLE t1 (a INT); | ||
| INSERT INTO t1 VALUES (1); | ||
| INSERT INTO t1 VALUES (2); | ||
| # The current GTID position is reachable | ||
| SELECT GTID_CHECK_POS('GTID_POS'); | ||
| GTID_CHECK_POS('GTID_POS') | ||
| 1 | ||
| # 2. Invalid input raises an error; NULL input returns NULL | ||
| SELECT GTID_CHECK_POS('invalid-format'); | ||
| ERROR HY000: Could not parse GTID list | ||
| SELECT GTID_CHECK_POS(NULL); | ||
| GTID_CHECK_POS(NULL) | ||
| NULL | ||
| # 3. Empty string (empty GTID list) returns 1 (trivially reachable) | ||
| SELECT GTID_CHECK_POS(''); | ||
| GTID_CHECK_POS('') | ||
| 1 | ||
| # 4. Rotate to a new binlog and purge the old one | ||
| FLUSH LOGS; | ||
| # Write a new GTID into the new (post-purge) active binlog | ||
| INSERT INTO t1 VALUES (3); | ||
| # The new position (in the current active log) is reachable | ||
| SELECT GTID_CHECK_POS('NEW_GTID_POS'); | ||
| GTID_CHECK_POS('NEW_GTID_POS') | ||
| 1 | ||
| # The old position (now in a purged log) returns 0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one fails on buildbot:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It now fails as follows on all platforms: |
||
| SELECT GTID_CHECK_POS('OLD_GTID_POS'); | ||
| GTID_CHECK_POS('OLD_GTID_POS') | ||
| 0 | ||
| # A completely fake domain/server/seqno (never existed) returns 0 | ||
| SELECT GTID_CHECK_POS('99-99-9999999'); | ||
| GTID_CHECK_POS('99-99-9999999') | ||
| 0 | ||
| # 5. A future sequence number in a known domain returns 0 | ||
| SELECT GTID_CHECK_POS('ABSENT_GTID'); | ||
| GTID_CHECK_POS('ABSENT_GTID') | ||
| 0 | ||
| # 6. Mixed list: reachable pos combined with an unknown domain returns 0 | ||
| SELECT GTID_CHECK_POS('NEW_GTID_POS,99-99-9999999'); | ||
| GTID_CHECK_POS('NEW_GTID_POS,99-99-9999999') | ||
| 0 | ||
| # 7. List with only the current reachable position returns 1 | ||
| SELECT GTID_CHECK_POS('NEW_GTID_POS'); | ||
| GTID_CHECK_POS('NEW_GTID_POS') | ||
| 1 | ||
|
gkodinov marked this conversation as resolved.
|
||
| # Cleanup | ||
| DROP TABLE t1; | ||
|
gkodinov marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| --source include/have_log_bin.inc | ||
|
|
||
| --echo # | ||
| --echo # MDEV-8235 Expose check_slave_start_position as SQL function | ||
| --echo # | ||
|
|
||
| --echo # 1. Set up some basic GTID history | ||
| CREATE TABLE t1 (a INT); | ||
| INSERT INTO t1 VALUES (1); | ||
| INSERT INTO t1 VALUES (2); | ||
|
|
||
| --echo # The current GTID position is reachable | ||
| let $pos= `SELECT @@GLOBAL.gtid_binlog_pos`; | ||
| --replace_result $pos GTID_POS | ||
| eval SELECT GTID_CHECK_POS('$pos'); | ||
|
gkodinov marked this conversation as resolved.
|
||
|
|
||
| --echo # 2. Invalid input raises an error; NULL input returns NULL | ||
| --error ER_INCORRECT_GTID_STATE | ||
| SELECT GTID_CHECK_POS('invalid-format'); | ||
| SELECT GTID_CHECK_POS(NULL); | ||
|
|
||
| --echo # 3. Empty string (empty GTID list) returns 1 (trivially reachable) | ||
| SELECT GTID_CHECK_POS(''); | ||
|
|
||
| --echo # 4. Rotate to a new binlog and purge the old one | ||
| FLUSH LOGS; | ||
| let $purge_binlogs_to= query_get_value(SHOW MASTER STATUS, File, 1); | ||
| --disable_query_log | ||
| --disable_result_log | ||
| --source include/wait_for_purge.inc | ||
| --enable_result_log | ||
| --enable_query_log | ||
|
|
||
| --echo # Write a new GTID into the new (post-purge) active binlog | ||
| INSERT INTO t1 VALUES (3); | ||
|
|
||
| --echo # The new position (in the current active log) is reachable | ||
| let $new_pos= `SELECT @@GLOBAL.gtid_binlog_pos`; | ||
| --replace_result $new_pos NEW_GTID_POS | ||
| eval SELECT GTID_CHECK_POS('$new_pos'); | ||
|
|
||
| --echo # The old position (now in a purged log) returns 0 | ||
| --replace_result $pos OLD_GTID_POS | ||
| eval SELECT GTID_CHECK_POS('$pos'); | ||
|
|
||
| --echo # A completely fake domain/server/seqno (never existed) returns 0 | ||
| SELECT GTID_CHECK_POS('99-99-9999999'); | ||
|
|
||
| --echo # 5. A future sequence number in a known domain returns 0 | ||
| let $server_id= `SELECT @@GLOBAL.server_id`; | ||
| let $absent_gtid= 0-$server_id-99999999; | ||
| --replace_result $absent_gtid ABSENT_GTID | ||
| eval SELECT GTID_CHECK_POS('$absent_gtid'); | ||
|
|
||
| --echo # 6. Mixed list: reachable pos combined with an unknown domain returns 0 | ||
| --replace_result $new_pos NEW_GTID_POS | ||
| eval SELECT GTID_CHECK_POS('$new_pos,99-99-9999999'); | ||
|
|
||
| --echo # 7. List with only the current reachable position returns 1 | ||
| --replace_result $new_pos NEW_GTID_POS | ||
| eval SELECT GTID_CHECK_POS('$new_pos'); | ||
|
|
||
| --echo # Cleanup | ||
| DROP TABLE t1; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1505,6 +1505,9 @@ class Item_func_connection_id :public Item_long_func | |
| }; | ||
|
|
||
|
|
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some more white-space only changes. |
||
|
|
||
|
|
||
| class Item_func_signed :public Item_int_func | ||
| { | ||
| public: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.