-
-
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
Open
ayush-jha123
wants to merge
1
commit into
MariaDB:main
Choose a base branch
from
ayush-jha123:mdev-8235-gtid-pos
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # | ||
| # 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); | ||
| # Get the current GTID position manually and verify it exists | ||
| SELECT GTID_CHECK_POS('GTID_POS'); | ||
| GTID_CHECK_POS('GTID_POS') | ||
| 1 | ||
| # 2. Verify invalid inputs | ||
| SELECT GTID_CHECK_POS('invalid-format'); | ||
| ERROR HY000: Could not parse GTID list | ||
| SELECT GTID_CHECK_POS(NULL); | ||
| GTID_CHECK_POS(NULL) | ||
| NULL | ||
| # 3. Check for a very old purged GTID | ||
| # (Simulate purging all logs) | ||
| FLUSH LOGS; | ||
| PURGE BINARY LOGS BEFORE NOW(); | ||
| # Depending on when it is executed, '0-1-1' might still be | ||
| # reachable if we haven't actually purged the very first file | ||
| # but purge binary logs before now() should remove everything | ||
| # except the active one. | ||
| # Since we want a deterministic test, let's check | ||
| # a completely fake server_id / seq_no that shouldn't exist | ||
| SELECT GTID_CHECK_POS('0-99-9999999'); | ||
| GTID_CHECK_POS('0-99-9999999') | ||
| 1 | ||
| # 4. Check for an otherwise valid GTID (right domain and server) | ||
| # that is absent (sequence number is in the future). | ||
| SELECT GTID_CHECK_POS('ABSENT_GTID'); | ||
| GTID_CHECK_POS('ABSENT_GTID') | ||
| 1 | ||
| # Cleanup | ||
| DROP TABLE t1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --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 # Get the current GTID position manually and verify it exists | ||
| 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. Verify invalid inputs | ||
| --error ER_INCORRECT_GTID_STATE | ||
| SELECT GTID_CHECK_POS('invalid-format'); | ||
| SELECT GTID_CHECK_POS(NULL); | ||
|
|
||
| --echo # 3. Check for a very old purged GTID | ||
| --echo # (Simulate purging all logs) | ||
| FLUSH LOGS; | ||
| PURGE BINARY LOGS BEFORE NOW(); | ||
|
|
||
| --echo # Depending on when it is executed, '0-1-1' might still be | ||
| --echo # reachable if we haven't actually purged the very first file | ||
| --echo # but purge binary logs before now() should remove everything | ||
| --echo # except the active one. | ||
|
|
||
| --echo # Since we want a deterministic test, let's check | ||
| --echo # a completely fake server_id / seq_no that shouldn't exist | ||
| SELECT GTID_CHECK_POS('0-99-9999999'); | ||
|
|
||
| --echo # 4. Check for an otherwise valid GTID (right domain and server) | ||
| --echo # that is absent (sequence number is in the future). | ||
| 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 # Cleanup | ||
| DROP TABLE t1; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ | |
| #include "sql_acl.h" // EXECUTE_ACL | ||
| #include "mysqld.h" // LOCK_short_uuid_generator | ||
| #include "rpl_mi.h" | ||
|
|
||
| #include "sql_time.h" | ||
| #include <m_ctype.h> | ||
| #include <hash.h> | ||
|
|
@@ -51,6 +52,7 @@ | |
| #include "debug_sync.h" | ||
| #include "sql_base.h" | ||
| #include "sql_cte.h" | ||
| #include "sql_repl.h" | ||
| #ifdef WITH_WSREP | ||
| #include "mysql/service_wsrep.h" | ||
| #endif /* WITH_WSREP */ | ||
|
|
@@ -824,6 +826,31 @@ String *Item_int_func::val_str(String *str) | |
| } | ||
|
|
||
|
|
||
| bool Item_func_gtid_check_pos::val_bool() | ||
| { | ||
| DBUG_ASSERT(fixed()); | ||
| String *gtid_str= args[0]->val_str(&tmp_value); | ||
| if ((null_value= args[0]->null_value)) | ||
| return 0; | ||
|
|
||
| #ifndef HAVE_REPLICATION | ||
| (void)gtid_str; | ||
| my_error(ER_NOT_SUPPORTED_YET, MYF(0), "GTID_CHECK_POS"); | ||
| null_value= 1; | ||
| return 0; | ||
| #else | ||
| bool is_reachable= false; | ||
| if (rpl_gtid_pos_check_reachable(gtid_str, &is_reachable)) | ||
|
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 fails to compile on buildbot (I'm assuming for the unit tests) as follows: Please have a look. |
||
| { | ||
| null_value= 1; | ||
| return 0; | ||
| } | ||
| null_value= 0; | ||
| return is_reachable; | ||
| #endif | ||
| } | ||
|
|
||
|
|
||
| bool Item_func_connection_id::fix_length_and_dec(THD *thd) | ||
| { | ||
| if (Item_long_func::fix_length_and_dec(thd)) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.