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

expression: do not set ParseToJSONFlag to a JSON column #8564

Merged
merged 7 commits into from Dec 12, 2018

Conversation

Projects
None yet
3 participants
@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Dec 4, 2018

What problem does this PR solve?

Do not set ParseToJSONFlag to a JSON column which can avoid the data race when another goroutine tries to read the column's flag.

What is changed and how it works?

ParseToJSONFlag is used to effect the behavior of castStringAsJSON.
If ParseToJSONFlag is set, we invoke json.ParseBinaryFromString(str) to parse this string to a JSON, where str must be a valid JSON-string (e.g. '"abc"').
Or, we use json.CreateBinary(str) to wrap this string as a JSON directly without check.

ParseToJSONFlag is introduced to resolve the compatibility of compare function and JSON-related function with MySQL.

e.g.:

json_unquote(str)    -- We use CreateBinary(str)
json_merge(str, str) -- We use ParseBinaryFromString(str)

For a JSON column, we do not need to set this flag for it.

Check List

Tests

  • No code

Code changes

  • Has exported function/method change

Side effects

N/A

Related changes

  • Need to cherry-pick to the release branch
    release-2.1 release-2.0

This change is Reviewable

@XuHuaiyu

This comment has been minimized.

Copy link
Contributor Author

XuHuaiyu commented Dec 4, 2018

/run-all-tests

Show resolved Hide resolved expression/builtin_compare.go Outdated
@XuHuaiyu

This comment has been minimized.

Copy link
Contributor Author

XuHuaiyu commented Dec 4, 2018

@winoros
Copy link
Member

winoros left a comment

lgtm

@XuHuaiyu

This comment has been minimized.

Copy link
Contributor Author

XuHuaiyu commented Dec 6, 2018

/run-common-test tidb-test=pr/676
/run-integration-common-test tidb-test=pr/676

@XuHuaiyu

This comment has been minimized.

Copy link
Contributor Author

XuHuaiyu commented Dec 6, 2018

/run-common-test
/run-integration-common-test

// Moreover, Column.RetType refers to the infoschema, if we modify
// it, data race may happen if another goroutine read from the
// infoschema at the same time.
if _, isColumn := args[i].(*Column); isColumn {

This comment has been minimized.

Copy link
@zz-jason

zz-jason Dec 6, 2018

Member

Can we extract a common function to do it? There are a lot of duplicated code and comments.

@XuHuaiyu

This comment has been minimized.

Copy link
Contributor Author

XuHuaiyu commented Dec 6, 2018

/run-common-test tidb-test=pr/676

@XuHuaiyu

This comment has been minimized.

Copy link
Contributor Author

XuHuaiyu commented Dec 12, 2018

/run-all-tests

@zz-jason
Copy link
Member

zz-jason left a comment

LGTM

@zz-jason zz-jason added status/LGT2 and removed status/LGT1 labels Dec 12, 2018

@XuHuaiyu XuHuaiyu merged commit 63e7dac into pingcap:master Dec 12, 2018

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@XuHuaiyu XuHuaiyu deleted the XuHuaiyu:copy_jsonflag branch Dec 12, 2018

XuHuaiyu added a commit to XuHuaiyu/tidb that referenced this pull request Dec 12, 2018

XuHuaiyu added a commit to XuHuaiyu/tidb that referenced this pull request Dec 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.