-
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 for cast_as_binary #8014
Conversation
conflicts needs be resolved @zz-jason |
/run-all-tests |
ddl/session_pool.go
Outdated
@@ -44,6 +45,7 @@ func (sg *sessionPool) get() (sessionctx.Context, error) { | |||
ctx := resource.(sessionctx.Context) | |||
ctx.GetSessionVars().SetStatusFlag(mysql.ServerStatusAutocommit, true) | |||
ctx.GetSessionVars().InRestrictedSQL = true | |||
ctx.GetSessionVars().GetSystemVar(variable.MaxAllowedPacket) |
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.
Remove this line.
/run-common-test |
@@ -936,6 +936,9 @@ func (s *testIntegrationSuite) TestStringBuiltin(c *C) { | |||
result = tk.MustQuery("select a,b,concat_ws(',',a,b) from t") | |||
result.Check(testkit.Rows("114.57011441 38.04620115 114.57011441,38.04620115", | |||
"-38.04620119 38.04620115 -38.04620119,38.04620115")) | |||
|
|||
result = tk.MustQuery("SELECT CAST('a' AS BINARY(67108865));") | |||
result.Check(testkit.Rows("<nil>")) |
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.
check the result of show warnings
here?
/run-common-test |
/run-common-test |
@@ -1021,7 +1034,25 @@ func (b *builtinCastStringAsStringSig) evalString(row chunk.Row) (res string, is | |||
return res, isNull, errors.Trace(err) | |||
} | |||
sc := b.ctx.GetSessionVars().StmtCtx | |||
|
|||
// isTooLarge := uint64(len(res)) > b.maxAllowedPacket || (b.tp.Flen != types.UnspecifiedLength && uint64(b.tp.Flen) > b.maxAllowedPacket) |
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.
Remove them?
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.
PTAL @zz-jason
@@ -1021,7 +1034,25 @@ func (b *builtinCastStringAsStringSig) evalString(row chunk.Row) (res string, is | |||
return res, isNull, errors.Trace(err) | |||
} | |||
sc := b.ctx.GetSessionVars().StmtCtx | |||
|
|||
// isTooLarge := uint64(len(res)) > b.maxAllowedPacket || (b.tp.Flen != types.UnspecifiedLength && uint64(b.tp.Flen) > b.maxAllowedPacket) |
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.
PTAL @zz-jason
if err != nil { | ||
return nil, errors.Trace(err) | ||
} | ||
sig = &builtinCastStringAsStringSig{bf, maxAllowedPacket} |
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.
Could these be extracted into a function?
duplicated with #8768, close it now. |
What problem does this PR solve?
This PR fixes the incorrect result of the sql:
Result of TiDB:
Result of MySQL:
What is changed and how it works?
handle max allowed packet in the
cast_as_binary
function.Check List
Tests
Related changes
This change is