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: check max_allowed_packet constraint for function insert (… #7528

Merged
merged 3 commits into from
Aug 29, 2018

Conversation

eurekaka
Copy link
Contributor

What problem does this PR solve?

Return NULL and a warning when the result of function insert exceeds max_allowed_packet.

Before this PR, SELECT INSERT('abc', 1, -1, 'abcd'); would return result 'abcd' even if @@global.max_allowed_packet is set 3.

After this PR:

mysql> select @@max_allowed_packet;
+----------------------+
| @@max_allowed_packet |
+----------------------+
| 3                    |
+----------------------+
1 row in set (0.00 sec)

mysql> select insert('abc', 1, -1, 'abc');
+-----------------------------+
| insert('abc', 1, -1, 'abc') |
+-----------------------------+
| abc                         |
+-----------------------------+
1 row in set (0.00 sec)

mysql> select insert('abc', 1, -1, 'abcd');
+------------------------------+
| insert('abc', 1, -1, 'abcd') |
+------------------------------+
| NULL                         |
+------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+-----------------------------------------------------------------------+
| Level   | Code | Message                                                               |
+---------+------+-----------------------------------------------------------------------+
| Warning | 1301 | Result of insert() was larger than max_allowed_packet (3) - truncated |
+---------+------+-----------------------------------------------------------------------+
1 row in set (0.00 sec)

What is changed and how it works?

  • check result length in valString method of builtinInsertSig and builtinInsertBinarySig against max_allowed_packet;

Check List

Tests

  • Unit test

Related changes

  • Need to be included in the release note

@zz-jason zz-jason added type/bugfix This PR fixes a bug. component/expression type/2.0 cherry-pick status/LGT1 Indicates that a PR has LGTM 1. labels Aug 29, 2018
@zz-jason
Copy link
Member

LGTM
@XuHuaiyu @lamxTyler PTAL

@zz-jason
Copy link
Member

/run-all-tests tidb-test=release-2.0 tikv=release-2.0 pd=release-2.0

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

@eurekaka
Copy link
Contributor Author

/run-unit-test tidb-test=release-2.0 tikv=release-2.0 pd=release-2.0

@zz-jason
Copy link
Member

/run-unit-test

@alivxxx
Copy link
Contributor

alivxxx commented Aug 29, 2018

/run-all-tests tidb-test=release-2.0 tikv=release-2.0 pd=release-2.0

@shenli shenli added status/LGT2 Indicates that a PR has LGTM 2. status/all tests passed and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 29, 2018
@shenli shenli merged commit 9d09f1d into pingcap:release-2.0 Aug 29, 2018
@eurekaka eurekaka deleted the release-2.0 branch August 30, 2018 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression 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.

5 participants