-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 from_base64 function. #7409
Merged
zz-jason
merged 8 commits into
pingcap:master
from
supernan1994:feature/maxAllowPacketFromBase64
Aug 17, 2018
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e57f80f
expression: handle max_allowed_packet warnings for from_base64 function.
sisterdong 6bfb98f
Merge branch 'master' of https://github.com/pingcap/tidb into feature…
sisterdong c3c34ff
remove println
sisterdong 1376628
Merge branch 'master' of https://github.com/pingcap/tidb into feature…
sisterdong 42d0c96
replace magic num with const
sisterdong ca98355
check isNull by one assert
sisterdong 4bc3890
Merge branch 'master' of https://github.com/pingcap/tidb into feature…
sisterdong 36d4c41
check isNull by one assert
sisterdong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1609,6 +1609,62 @@ func (s *testEvaluatorSuite) TestFromBase64(c *C) { | |
} | ||
} | ||
|
||
func (s *testEvaluatorSuite) TestFromBase64Sig(c *C) { | ||
colTypes := []*types.FieldType{ | ||
{Tp: mysql.TypeVarchar}, | ||
} | ||
|
||
tests := []struct { | ||
args string | ||
expect string | ||
isNil bool | ||
maxAllowPacket uint64 | ||
}{ | ||
{string("YWJj"), string("abc"), false, 3}, | ||
{string("YWJj"), "", true, 2}, | ||
{ | ||
string("QUJDREVGR0hJSkt\tMTU5PUFFSU1RVVld\nYWVphYmNkZ\rWZnaGlqa2xt bm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLw=="), | ||
string("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), | ||
false, | ||
70, | ||
}, | ||
{ | ||
string("QUJDREVGR0hJSkt\tMTU5PUFFSU1RVVld\nYWVphYmNkZ\rWZnaGlqa2xt bm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLw=="), | ||
"", | ||
true, | ||
69, | ||
}, | ||
} | ||
|
||
args := []Expression{ | ||
&Column{Index: 0, RetType: colTypes[0]}, | ||
} | ||
|
||
for _, test := range tests { | ||
resultType := &types.FieldType{Tp: mysql.TypeVarchar, Flen: mysql.MaxBlobWidth} | ||
base := baseBuiltinFunc{args: args, ctx: s.ctx, tp: resultType} | ||
fromBase64 := &builtinFromBase64Sig{base, test.maxAllowPacket} | ||
|
||
input := chunk.NewChunkWithCapacity(colTypes, 1) | ||
input.AppendString(0, test.args) | ||
res, isNull, err := fromBase64.evalString(input.GetRow(0)) | ||
c.Assert(err, IsNil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if test.isNil { | ||
c.Assert(isNull, IsTrue) | ||
|
||
warnings := s.ctx.GetSessionVars().StmtCtx.GetWarnings() | ||
c.Assert(len(warnings), Equals, 1) | ||
lastWarn := warnings[len(warnings)-1] | ||
c.Assert(terror.ErrorEqual(errWarnAllowedPacketOverflowed, lastWarn.Err), IsTrue) | ||
s.ctx.GetSessionVars().StmtCtx.SetWarnings([]stmtctx.SQLWarn{}) | ||
|
||
} else { | ||
c.Assert(isNull, IsFalse) | ||
} | ||
c.Assert(res, Equals, test.expect) | ||
} | ||
} | ||
|
||
func (s *testEvaluatorSuite) TestInsert(c *C) { | ||
tests := []struct { | ||
args []interface{} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How about
n/4*3
, then the above validation can be removed?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.
when
n%4 > 4/3
,n/4*3
is not equal ton*3/4
.mysql calculates decode length by
n*3/4
, I think we'd better use the same formula.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.
ok