MDEV-39223 Reversed executable comments incorrectly written in binlog#4885
Open
tonychen2001 wants to merge 1 commit intoMariaDB:mainfrom
Open
MDEV-39223 Reversed executable comments incorrectly written in binlog#4885tonychen2001 wants to merge 1 commit intoMariaDB:mainfrom
tonychen2001 wants to merge 1 commit intoMariaDB:mainfrom
Conversation
When a reversed executable comment (/*!!version */ or /*M!!version */) is not executed on the master (server version >= specified version), the binlog writer only neutralized the second '!' to a space, leaving `/*! command */`, an executable comment. The slave would then try to execute the comment body as SQL and fail with a parse error. Fix: in the non-executed path, also replace the first '!' with a space so the SQL becomes /* (a plain comment). The restore path for unclosed comments also restores both '!' characters. Added rpl_reversed_comments.test mirroring rpl_conditional_comments.test with reversed equivalents for all forward comment replication test cases: mix of applied/not-applied, prepared statements, unclosed comments, nested comments, delimiter edge case, and MariaDB-specific /*M!! syntax. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
gkodinov
reviewed
Apr 1, 2026
Member
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for fixing this so fast! This is a preliminary review.
LGTM.
Please stand by for the final review.
gkodinov
approved these changes
Apr 1, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This addresses an issue introduced in #4724.
When a reversed executable comment (/*!!version */ or /*M!!version */)
is not executed on the master (server version >= specified version),
the binlog writer only neutralized the second '!' to a space, leaving
/*! command */, an executable comment. The slave would then try toexecute the comment body as SQL and fail with a parse error.
Fix: in the non-executed path, also replace the first '!' with a space so the
SQL becomes /* (a plain comment). The restore path for unclosed comments also
restores both '!' characters.
How can this PR be tested?
Added rpl_reversed_comments.test mirroring rpl_conditional_comments.test
with equivalent test cases:
Basing the PR against the correct MariaDB version
Copyright
All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.