expression: fix unit test for builtinSysDateWithoutFspSig (#13425)

This commit is contained in:
Chengpeng Yan
2019-11-15 17:39:23 +08:00
committed by Feng Liyuan
parent 40c9f9c6e4
commit 611646770a
3 changed files with 16 additions and 6 deletions

View File

@ -1059,6 +1059,17 @@ func (s *testEvaluatorSuite) TestSysDate(c *C) {
c.Assert(err, IsNil)
n := v.GetMysqlTime()
c.Assert(n.String(), GreaterEqual, last.Format(types.TimeFormat))
baseFunc, _, input, output := genVecBuiltinFuncBenchCase(ctx, ast.Sysdate, vecExprBenchCase{retEvalType: types.ETDatetime})
resetStmtContext(s.ctx)
err = baseFunc.vecEvalTime(input, output)
c.Assert(err, IsNil)
last = time.Now()
times := output.Times()
for i := 0; i < 1024; i++ {
c.Assert(times[i].String(), GreaterEqual, last.Format(types.TimeFormat))
}
}
last := time.Now()

View File

@ -183,12 +183,8 @@ func (b *builtinSysDateWithoutFspSig) vectorized() bool {
func (b *builtinSysDateWithoutFspSig) vecEvalTime(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
loc := b.ctx.GetSessionVars().Location()
nowTs, err := getStmtTimestamp(b.ctx)
if err != nil {
return err
}
now := time.Now().In(loc)
now := nowTs.In(loc)
result.ResizeTime(n, false)
times := result.Times()
t, err := convertTimeToMysqlTime(now, 0, types.ModeHalfEven)

View File

@ -219,7 +219,10 @@ var vecBuiltinTimeCases = map[string][]vecExprBenchCase{
},
},
ast.Sysdate: {
{retEvalType: types.ETDatetime},
// Because there is a chance that a time error will cause the test to fail,
// we cannot use the vectorized test framework to test builtinSysDateWithoutFspSig.
// We test the builtinSysDateWithoutFspSig in TestSysDate function.
// {retEvalType: types.ETDatetime},
},
}