-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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 pad functions #7171
Conversation
/run-all-tests |
expression/builtin_string.go
Outdated
@@ -1760,24 +1760,33 @@ func (c *lpadFunctionClass) getFunction(ctx sessionctx.Context, args []Expressio | |||
bf.tp.Flen = getFlen4LpadAndRpad(bf.ctx, args[1]) | |||
SetBinFlagOrBinStr(args[0].GetType(), bf.tp) | |||
SetBinFlagOrBinStr(args[2].GetType(), bf.tp) | |||
|
|||
valStr, _ := ctx.GetSessionVars().GetSystemVar("max_allowed_packet") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make "max_allowed_packet" a constant in sessionctx/variable/sysvar.go?
@@ -316,7 +316,7 @@ var MySQLErrName = map[uint16]string{ | |||
ErrUnknownTimeZone: "Unknown or incorrect time zone: '%-.64s'", | |||
ErrWarnInvalidTimestamp: "Invalid TIMESTAMP value in column '%s' at row %d", | |||
ErrInvalidCharacterString: "Invalid %s character string: '%.64s'", | |||
ErrWarnAllowedPacketOverflowed: "Result of %s() was larger than maxAllowedPacket (%d) - truncated", | |||
ErrWarnAllowedPacketOverflowed: "Result of %s() was larger than max_allowed_packet (%d) - truncated", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is original warning msg in mysql?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this error message comes from the mysql-server code base.
@XuHuaiyu Done, PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What have you changed? (mandatory)
Return
NULL
and a warning when the result oflpad
orrpad
exceedsmax_allowed_packetbs
.Before this PR,
select rpad('hello', 18446744073709551617, '1');
would make tidb-server panic byruntime error: makeslice: len out of range
.After this PR:
What is the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
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:
Refer to a related PR or issue link (optional)
to #7153
Benchmark result if necessary (optional)
Add a few positive/negative examples (optional)