-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
VReplication: Handle SQL NULL and JSON 'null' correctly for JSON columns #13944
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e00bf81
Update vcopier unit test
mattlord 6b1500b
Add vplayer unit test
mattlord 1d616b0
Quote null/true/false top level string literals
mattlord 51d4eb2
Fix pt1
mattlord 20515f5
Handle JSON type being SQL NULL
mattlord 62b6b92
Fixup unit tests
mattlord 1129479
Add another comment
mattlord 35133b7
Fix TestMarshalJSONToSQL
mattlord 25c3c4f
Fix vplayer side
mattlord 945a332
Fix vplayer unit test
mattlord ed7617d
Minor improvements after self review
mattlord dea13b2
Enhance e2e test with more null json values that fail without this PR
rohit-nayak-ps 1a1e807
Move top level true/false/null literal handling to CAST(_utf8mb4'lite…
mattlord 726b8ab
Move top level true/false/null literal handling to CAST(_utf8mb4'lite…
mattlord 75cba90
Update true/false literal handling in unit tests
mattlord 1842c99
Nitty nit
mattlord 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 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 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 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 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 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is semantically incorrect. The goal is that JSON marshaling also returns a JSON type from the expression, but it does not for this. It kinda works though because on insert now MySQL casts, but that's an implementation side-effect for
vreplication
, not something generic.I think this should be
CAST('null' as JSON)
(instead ofCAST(null as JSON)
), which should also work I think and returns a JSON type for the expression:Given the MySQL documentation, I think we also should change the serialization for
true
/false
as a toplevel value, and also quote that with a single'
to match the behavior for how we implementnull
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbussink I agree. And that's what I tried first, but then it became clear that there was another issue (and CONVERT is what we were previously using here):
This seems to lead us to treating it subsequently as a binary blob. If you think that's another internal bug then I can track that down too. And if you might have any ideas... 🙂
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing for 'true' and 'false' as well — the issue I noted above is not specific to 'null'. I had initially tried to treat true/false/null the same way (as you suggested above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that mean it needs
CAST(CONVERT('null' using utf8mb4) as JSON)
, or syntactically different but semantically the same,CAST(_utf8mb4'null' as JSON)
. I know that's messy, but I think that's what needed to be correct.That it's otherwise binary is due to vreplication using the
binary
collation and we need to make sure then that inputs are encoding agnostic / explicit about it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @dbussink ! That makes sense. I can see that we use the
_utf8mb4'literal'
syntax throughout our JSON handling so I switched to that and it's working as expected.