expression: sec_to_time is not compatible with MySQL when the argument is a scientific notation number (#15614)
This commit is contained in:
@ -5981,7 +5981,7 @@ func (b *builtinSecToTimeSig) evalDuration(row chunk.Row) (types.Duration, bool,
|
||||
secondDemical = float64(second) + demical
|
||||
|
||||
var dur types.Duration
|
||||
dur, err = types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, fmt.Sprintf("%s%02d:%02d:%v", negative, hour, minute, secondDemical), int8(b.tp.Decimal))
|
||||
dur, err = types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, fmt.Sprintf("%s%02d:%02d:%s", negative, hour, minute, strconv.FormatFloat(secondDemical, 'f', -1, 64)), int8(b.tp.Decimal))
|
||||
if err != nil {
|
||||
return types.Duration{}, err != nil, err
|
||||
}
|
||||
|
||||
@ -1869,7 +1869,7 @@ func (b *builtinSecToTimeSig) vecEvalDuration(input *chunk.Chunk, result *chunk.
|
||||
second = seconds % 60
|
||||
}
|
||||
secondDemical := float64(second) + demical
|
||||
duration, err := types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, fmt.Sprintf("%s%02d:%02d:%v", negative, hour, minute, secondDemical), int8(b.tp.Decimal))
|
||||
duration, err := types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, fmt.Sprintf("%s%02d:%02d:%s", negative, hour, minute, strconv.FormatFloat(secondDemical, 'f', -1, 64)), int8(b.tp.Decimal))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -4967,6 +4967,14 @@ func (s *testIntegrationSuite) TestInvalidEndingStatement(c *C) {
|
||||
assertParseErr(`drop table if exists t"`)
|
||||
}
|
||||
|
||||
func (s *testIntegrationSuite) TestIssue15613(c *C) {
|
||||
tk := testkit.NewTestKit(c, s.store)
|
||||
tk.MustQuery("select sec_to_time(1e-4)").Check(testkit.Rows("00:00:00.000100"))
|
||||
tk.MustQuery("select sec_to_time(1e-5)").Check(testkit.Rows("00:00:00.000010"))
|
||||
tk.MustQuery("select sec_to_time(1e-6)").Check(testkit.Rows("00:00:00.000001"))
|
||||
tk.MustQuery("select sec_to_time(1e-7)").Check(testkit.Rows("00:00:00.000000"))
|
||||
}
|
||||
|
||||
func (s *testIntegrationSuite) TestIssue10675(c *C) {
|
||||
tk := testkit.NewTestKit(c, s.store)
|
||||
tk.MustExec("use test")
|
||||
|
||||
Reference in New Issue
Block a user