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: handle max_allowed_packet warnings for repeat function. #7181

Merged
merged 9 commits into from
Aug 17, 2018
Merged

expression: handle max_allowed_packet warnings for repeat function. #7181

merged 9 commits into from
Aug 17, 2018

Conversation

hhu-cc
Copy link
Contributor

@hhu-cc hhu-cc commented Jul 30, 2018

What have you changed? (mandatory)

Return NULL and a warning when the result of repeat exceeds max_allowed_packetbs.

Before this PR:

tidb> SELECT repeat('h', 18446744073709551617);
+-----------------------------------+
| repeat('h', 18446744073709551617) |
+-----------------------------------+
| NULL                              |
+-----------------------------------+
1 row in set, 1 warning (0.00 sec)

tidb> show warnings;
+---------+------+-----------------------------------------------------------+
| Level   | Code | Message                                                   |
+---------+------+-----------------------------------------------------------+
| Warning | 1292 | Truncated incorrect DECIMAL value: '18446744073709551617' |
+---------+------+-----------------------------------------------------------+
1 row in set (0.00 sec)

After this PR:

tidb> SELECT repeat('h', 18446744073709551617);
+-----------------------------------+
| repeat('h', 18446744073709551617) |
+-----------------------------------+
| NULL                              |
+-----------------------------------+
1 row in set, 2 warnings (2.43 sec)

tidb> show warnings;
+---------+------+------------------------------------------------------------------------------+
| Level   | Code | Message                                                                      |
+---------+------+------------------------------------------------------------------------------+
| Warning | 1292 | Truncated incorrect DECIMAL value: '18446744073709551617'                    |
| Warning | 1301 | Result of repeat() was larger than max_allowed_packet (67108864) - truncated |
+---------+------+------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

What is the type of the changes? (mandatory)

Bug fix (non-breaking change which fixes an issue)

How has this PR been tested? (mandatory)

  • unit test
  • explain test

Does this PR affect documentation (docs/docs-cn) update? (mandatory)

No

Does this PR affect tidb-ansible update? (mandatory)

No

Does this PR need to be added to the release notes? (mandatory)

Yes

release note:

Return `NULL` when the result of function `REPEAT` is larger than `max_allowed_packet`

Refer to a related PR or issue link (optional)

to #7153

Benchmark result if necessary (optional)

Add a few positive/negative examples (optional)

@sre-bot
Copy link
Contributor

sre-bot commented Jul 30, 2018

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@CLAassistant
Copy link

CLAassistant commented Jul 30, 2018

CLA assistant check
All committers have signed the CLA.

@hhu-cc
Copy link
Contributor Author

hhu-cc commented Jul 30, 2018

/run-all-tests

@zz-jason
Copy link
Member

@hhxcc Thanks for your contributing! It seems that this PR is blocked by #7171.
@XuHuaiyu PTAL

@shenli shenli added the contribution This PR is from a community contributor. label Jul 30, 2018
@zz-jason
Copy link
Member

@hhxcc, #7171 has been merged into the master branch now, please merge master and resolve conflicts 😄

@hhu-cc
Copy link
Contributor Author

hhu-cc commented Jul 31, 2018

/run-all-tests

@hhu-cc
Copy link
Contributor Author

hhu-cc commented Jul 31, 2018

@zz-jason ok, thanks for notify.

@hhu-cc
Copy link
Contributor Author

hhu-cc commented Jul 31, 2018

/run-all-tests

1 similar comment
@hhu-cc
Copy link
Contributor Author

hhu-cc commented Jul 31, 2018

/run-all-tests

zz-jason
zz-jason previously approved these changes Aug 6, 2018
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM
@XuHuaiyu PTAL

@zz-jason
Copy link
Member

zz-jason commented Aug 6, 2018

/run-unit-test

@zz-jason
Copy link
Member

zz-jason commented Aug 8, 2018

@hhxcc There are so many irrelevant changes, I think you may need to do some code clean work.

@hhu-cc
Copy link
Contributor Author

hhu-cc commented Aug 10, 2018

@zz-jason sorry for that , I have already fixed it.

@zz-jason
Copy link
Member

LGTM
@XuHuaiyu PTAL

@zz-jason zz-jason added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 10, 2018
@@ -575,6 +582,7 @@ func (b *builtinRepeatSig) evalString(row chunk.Row) (d string, isNull bool, err
if isNull || err != nil {
return "", isNull, errors.Trace(err)
}
byteLength := len(str)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that this is rune length, not byte length?
I think we need to add some test cased for multi-byte characters, like Chinese character.

Copy link
Contributor Author

@hhu-cc hhu-cc Aug 13, 2018

Choose a reason for hiding this comment

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

Len of String will return the byte length, you can check it on https://golang.org/pkg/builtin/#len .
I have added some test of Chinese character.

@@ -398,6 +398,53 @@ func (s *testEvaluatorSuite) TestRepeat(c *C) {
c.Assert(v.GetString(), Equals, "")
}

func (s *testEvaluatorSuite) TestRepeatSig(c *C) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you refine the test?
Maybe you can keep style with another tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

@crazycs520 crazycs520 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
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 17, 2018
@zz-jason
Copy link
Member

/run-all-tests

@zz-jason zz-jason merged commit 2fbd5e7 into pingcap:master Aug 17, 2018
@zz-jason
Copy link
Member

@hhxcc It would be great if you can cherrypick this PR to the release-2.0 😄

@hhu-cc
Copy link
Contributor Author

hhu-cc commented Aug 19, 2018

@zz-jason ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression contribution This PR is from a community contributor. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants