Skip to content
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

json: implement json unary not with comparing to json(0) #40684

Closed
wants to merge 1 commit into from

Conversation

YangKeao
Copy link
Member

Signed-off-by: YangKeao yangkeao@chunibyo.icu

What problem does this PR solve?

Issue Number: close #40683

Problem Summary:

The behavior of unary not for json value is different between TiDB and MySQL. TiDB converts the json to double and run unary not on it. MySQL compares the JSON with json integer 0.

What is changed and how it works?

I changed the behavior to be compatible with MySQL. The only concern is that I don't know whether returning a function in other function class is expected. I only noticed the funcName is different so I added a very ugly condition to overwrite the funcName, but I'm not sure whether it will have other problems (at least, I cannot overwrite the funcName for the caller...).

Or anyone can provide better idea?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Release note

Fix the issue that unary not with comparing to json(0) is not compatible with MySQL.

Signed-off-by: YangKeao <yangkeao@chunibyo.icu>
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 18, 2023
@@ -739,6 +740,17 @@ func (c *unaryNotFunctionClass) getFunction(ctx sessionctx.Context, args []Expre
case types.ETInt:
sig = &builtinUnaryNotIntSig{bf}
sig.setPbCode(tipb.ScalarFuncSig_UnaryNotInt)
case types.ETJson:
Copy link
Contributor

Choose a reason for hiding this comment

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

why not like the other type, add a new sig builtinUnaryNotJSONSig

Copy link
Member Author

Choose a reason for hiding this comment

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

Good. I also agree add a new sig builtinUnaryNotJSONSig is better 🤝

@YangKeao
Copy link
Member Author

I'll add a new builtinUnaryNotJSONSig, but not using the eq directly.

@YangKeao YangKeao closed this Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unary not with json argument is not compatible with MySQL
3 participants