expression: implement vectorized evaluation for builtinPasswordSig (#12754)
This commit is contained in:
@ -15,6 +15,7 @@ package expression
|
||||
|
||||
import (
|
||||
"github.com/pingcap/errors"
|
||||
"github.com/pingcap/parser/auth"
|
||||
"github.com/pingcap/tidb/types"
|
||||
"github.com/pingcap/tidb/util/chunk"
|
||||
"github.com/pingcap/tidb/util/encrypt"
|
||||
@ -163,11 +164,37 @@ func (b *builtinAesEncryptSig) vecEvalString(input *chunk.Chunk, result *chunk.C
|
||||
}
|
||||
|
||||
func (b *builtinPasswordSig) vectorized() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *builtinPasswordSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error {
|
||||
return errors.Errorf("not implemented")
|
||||
n := input.NumRows()
|
||||
buf, err := b.bufAllocator.get(types.ETString, n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer b.bufAllocator.put(buf)
|
||||
if err := b.args[0].VecEvalString(b.ctx, input, buf); err != nil {
|
||||
return err
|
||||
}
|
||||
result.ReserveString(n)
|
||||
for i := 0; i < n; i++ {
|
||||
if buf.IsNull(i) {
|
||||
result.AppendString("")
|
||||
continue
|
||||
}
|
||||
pass := buf.GetString(i)
|
||||
if len(pass) == 0 {
|
||||
result.AppendString("")
|
||||
continue
|
||||
}
|
||||
// We should append a warning here because function "PASSWORD" is deprecated since MySQL 5.7.6.
|
||||
// See https://dev.mysql.com/doc/refman/5.7/en/encryption-functions.html#function_password
|
||||
b.ctx.GetSessionVars().StmtCtx.AppendWarning(errDeprecatedSyntaxNoReplacement.GenWithStackByArgs("PASSWORD"))
|
||||
|
||||
result.AppendString(auth.EncodePassword(pass))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *builtinSHA1Sig) vectorized() bool {
|
||||
|
||||
@ -31,8 +31,10 @@ var vecBuiltinEncryptionCases = map[string][]vecExprBenchCase{
|
||||
ast.RandomBytes: {},
|
||||
ast.UncompressedLength: {},
|
||||
ast.SHA1: {},
|
||||
ast.PasswordFunc: {},
|
||||
ast.SHA2: {},
|
||||
ast.PasswordFunc: {
|
||||
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&randLenStrGener{10, 20}}},
|
||||
},
|
||||
ast.SHA2: {},
|
||||
ast.Encode: {
|
||||
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString}},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user