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

executor: fix json_objectagg() on varbinary type #27119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wzru
Copy link
Contributor

@wzru wzru commented Aug 11, 2021

What problem does this PR solve?

Issue Number: close #25053

Problem Summary:

drop table if exists tbl_0;
create table tbl_0 (col_2 int, col_3 varbinary(163));
insert into tbl_0 values (1,'o');
select json_objectagg( col_2, col_3 ) from tbl_0;

expected:

+--------------------------------+
| json_objectagg( col_2, col_3 ) |
+--------------------------------+
| {"1": "base64:type15:bw=="}    |
+--------------------------------+

obtained:

+--------------------------------+
| json_objectagg( col_2, col_3 ) |
+--------------------------------+
| {"1": "o"}                     |
+--------------------------------+

What is changed and how it works?

What's Changed:

func (e *jsonObjectAgg) UpdatePartialResult implementation

How it Works:

add special handling for varbinary

Check List

Tests

  • Integration test

Side effects

  • Performance regression: Consumes more CPU

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@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 release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 11, 2021
@wzru wzru changed the title fix json_objectagg() on varbinary type executor: fix json_objectagg() on varbinary type Aug 11, 2021
@pingcap pingcap deleted a comment from sre-bot Aug 11, 2021
@wzru wzru requested review from ichn-hu and guo-shaoge August 11, 2021 10:13
@ichn-hu ichn-hu mentioned this pull request Aug 11, 2021
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 15, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 19, 2021
@wzru
Copy link
Contributor Author

wzru commented Aug 19, 2021

/run-check_dev_2

@@ -109,6 +111,21 @@ func (e *jsonObjectAgg) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup
keyString = stringutil.Copy(keyString)

realVal := value.Clone().GetValue()
// Special handling for varbinary
if e.args[1].GetType().Tp == mysql.TypeVarchar && mysql.HasBinaryFlag(e.args[1].GetType().Flag) {
Copy link
Collaborator

@guo-shaoge guo-shaoge Aug 19, 2021

Choose a reason for hiding this comment

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

Looks like it's not only for json_objectagg(). json_object() also has same behavior.

mysql> select json_object( col_2, col_3 ) from tbl_0;
+-----------------------------+
| json_object( col_2, col_3 ) |
+-----------------------------+
| {"1": "base64:type15:bw=="} |
+-----------------------------+

We also need handle binary type.

mysql> select json_object( col_2, col_3 ) from tbl_0;
+------------------------------+
| json_object( col_2, col_3 )  |
+------------------------------+
| {"1": "base64:type254:bwA="} |
+------------------------------+

@ichn-hu
Copy link
Contributor

ichn-hu commented Aug 19, 2021

@wzru could you look up in mysql's doc about what is type:15?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

json_objectagg() is not compatible with MySQL on varbinary type
4 participants