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 : fix bug in insert select union select. #13632

Merged
merged 9 commits into from
Nov 20, 2019

Conversation

AilinKid
Copy link
Contributor

@AilinKid AilinKid commented Nov 20, 2019

What problem does this PR solve?

In TiDB:

create table bug (a varchar(100));

insert into bug select  ifnull(JSON_UNQUOTE(JSON_EXTRACT('[{"amount":2000,"feeAmount":0,"merchantNo":"20190430140319679394","shareBizCode":"20160311162_SECOND"}]', '$[0].merchantNo')),'') merchant_no union SELECT '20180531557' merchant_no;

Result:

ERROR 1406 (22001) : Data Too Long, field len 11, data len 20

Expected execute successfully!

What is changed and how it works?

This problem comes from jsonUnquoteFunction function.
We should fill the Flen in jsonUnquoteFunctionClass.getFunction().
Cause return type string is an element set (maybe autowrapped as an array) of whole json, so here we set the flen with mysql.MaxFieldVarCharLength.

Check List

Tests

  • Unit test
  • Integration test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • fix bug in insert select union select, resulting from data too long.

@AilinKid AilinKid requested a review from a team as a code owner November 20, 2019 08:46
@ghost ghost requested review from qw4990 and XuHuaiyu and removed request for a team November 20, 2019 08:46
@AilinKid AilinKid added component/expression type/bugfix This PR fixes a bug. and removed status/DNM labels Nov 20, 2019
@codecov
Copy link

codecov bot commented Nov 20, 2019

Codecov Report

Merging #13632 into master will decrease coverage by 0.4331%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #13632        +/-   ##
================================================
- Coverage   80.3499%   79.9168%   -0.4332%     
================================================
  Files           473        473                
  Lines        118117     115664      -2453     
================================================
- Hits          94907      92435      -2472     
- Misses        15857      15966       +109     
+ Partials       7353       7263        -90

@AilinKid
Copy link
Contributor Author

/run-unit-test

@AilinKid
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@sre-bot
Copy link
Contributor

sre-bot commented Nov 21, 2019

cherry pick to release-3.0 failed

@sre-bot
Copy link
Contributor

sre-bot commented Nov 21, 2019

cherry pick to release-2.1 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants