-
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
mod: add sha2 built-in function #2914
Conversation
@zs634134578 Thanks! Please fix ci. |
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.
Thanks for your PR @zs634134578
expression/builtin_encryption.go
Outdated
if err != nil { | ||
return d, errors.Trace(err) | ||
} | ||
// SHA2 function accepts 2 parameters |
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.
Length of arguments would be checked in verifyArgs
before,
so we don't need to check it here.
expression/builtin_encryption.go
Outdated
@@ -580,9 +583,58 @@ type builtinSHA2Sig struct { | |||
baseBuiltinFunc | |||
} | |||
|
|||
// Supported hash length as the second argument |
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.
Supported hash length of SHA-2 family.
c.Assert(crypt.IsNull(), IsTrue) | ||
} | ||
} | ||
// Corner case 1: NULL input for sha2 |
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.
For 0 args, and other incorrect parameter count, MySQL will cause error:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'sha2'
TiDB will check the count of parameters here
LGTM |
LGTM |
sha2 built-in function