Skip to content
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

Revert "expression: support NO_ZERO_DATE sql_mode" #16740

Merged
merged 2 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions expression/builtin_cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func (b *builtinCastIntAsTimeSig) evalTime(row chunk.Row) (res types.Time, isNul
}
res, err = types.ParseTimeFromNum(b.ctx.GetSessionVars().StmtCtx, val, b.tp.Tp, int8(b.tp.Decimal))
if err != nil {
return types.ZeroTime, true, HandleInvalidTimeError(b.ctx, err)
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
if b.tp.Tp == mysql.TypeDate {
// Truncate hh:mm:ss part if the type is Date.
Expand Down Expand Up @@ -841,7 +841,7 @@ func (b *builtinCastRealAsTimeSig) evalTime(row chunk.Row) (types.Time, bool, er
sc := b.ctx.GetSessionVars().StmtCtx
res, err := types.ParseTime(sc, fv, b.tp.Tp, int8(b.tp.Decimal))
if err != nil {
return types.ZeroTime, true, HandleInvalidTimeError(b.ctx, err)
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
if b.tp.Tp == mysql.TypeDate {
// Truncate hh:mm:ss part if the type is Date.
Expand Down Expand Up @@ -1007,7 +1007,7 @@ func (b *builtinCastDecimalAsTimeSig) evalTime(row chunk.Row) (res types.Time, i
sc := b.ctx.GetSessionVars().StmtCtx
res, err = types.ParseTimeFromFloatString(sc, string(val.ToString()), b.tp.Tp, int8(b.tp.Decimal))
if err != nil {
return types.ZeroTime, true, HandleInvalidTimeError(b.ctx, err)
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
if b.tp.Tp == mysql.TypeDate {
// Truncate hh:mm:ss part if the type is Date.
Expand Down Expand Up @@ -1223,7 +1223,7 @@ func (b *builtinCastStringAsTimeSig) evalTime(row chunk.Row) (res types.Time, is
sc := b.ctx.GetSessionVars().StmtCtx
res, err = types.ParseTime(sc, val, b.tp.Tp, int8(b.tp.Decimal))
if err != nil {
return types.ZeroTime, true, HandleInvalidTimeError(b.ctx, err)
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
if b.tp.Tp == mysql.TypeDate {
// Truncate hh:mm:ss part if the type is Date.
Expand Down Expand Up @@ -1277,7 +1277,7 @@ func (b *builtinCastTimeAsTimeSig) evalTime(row chunk.Row) (res types.Time, isNu

sc := b.ctx.GetSessionVars().StmtCtx
if res, err = res.Convert(sc, b.tp.Tp); err != nil {
return types.ZeroTime, true, HandleInvalidTimeError(b.ctx, err)
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
res, err = res.RoundFrac(sc, int8(b.tp.Decimal))
if b.tp.Tp == mysql.TypeDate {
Expand Down Expand Up @@ -1544,7 +1544,7 @@ func (b *builtinCastDurationAsTimeSig) evalTime(row chunk.Row) (res types.Time,
sc := b.ctx.GetSessionVars().StmtCtx
res, err = val.ConvertToTime(sc, b.tp.Tp)
if err != nil {
return types.ZeroTime, true, HandleInvalidTimeError(b.ctx, err)
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
res, err = res.RoundFrac(sc, int8(b.tp.Decimal))
return res, false, err
Expand Down Expand Up @@ -1668,7 +1668,7 @@ func (b *builtinCastJSONAsTimeSig) evalTime(row chunk.Row) (res types.Time, isNu
sc := b.ctx.GetSessionVars().StmtCtx
res, err = types.ParseTime(sc, s, b.tp.Tp, int8(b.tp.Decimal))
if err != nil {
return types.ZeroTime, true, HandleInvalidTimeError(b.ctx, err)
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
if b.tp.Tp == mysql.TypeDate {
// Truncate hh:mm:ss part if the type is Date.
Expand Down
14 changes: 7 additions & 7 deletions expression/builtin_cast_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (b *builtinCastIntAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk.
}
tm, err := types.ParseTimeFromNum(stmt, i64s[i], b.tp.Tp, fsp)
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
}
result.SetNull(i, true)
Expand Down Expand Up @@ -482,7 +482,7 @@ func (b *builtinCastJSONAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk
}
tm, err := types.ParseTime(stmtCtx, s, b.tp.Tp, fsp)
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
}
result.SetNull(i, true)
Expand Down Expand Up @@ -524,7 +524,7 @@ func (b *builtinCastRealAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk
}
tm, err := types.ParseTime(stmt, strconv.FormatFloat(f64s[i], 'f', -1, 64), b.tp.Tp, fsp)
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
}
result.SetNull(i, true)
Expand Down Expand Up @@ -601,7 +601,7 @@ func (b *builtinCastDurationAsTimeSig) vecEvalTime(input *chunk.Chunk, result *c
duration.Fsp = fsp
tm, err := duration.ConvertToTime(stmtCtx, b.tp.Tp)
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
}
result.SetNull(i, true)
Expand Down Expand Up @@ -1360,7 +1360,7 @@ func (b *builtinCastDecimalAsTimeSig) vecEvalTime(input *chunk.Chunk, result *ch
}
tm, err := types.ParseTimeFromFloatString(stmt, string(decimals[i].ToString()), b.tp.Tp, fsp)
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
}
result.SetNull(i, true)
Expand Down Expand Up @@ -1430,7 +1430,7 @@ func (b *builtinCastTimeAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk
}
res, err := times[i].Convert(stmt, b.tp.Tp)
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
}
result.SetNull(i, true)
Expand Down Expand Up @@ -1636,7 +1636,7 @@ func (b *builtinCastStringAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chu
}
tm, err := types.ParseTime(stmtCtx, buf.GetString(i), b.tp.Tp, fsp)
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
}
result.SetNull(i, true)
Expand Down
4 changes: 2 additions & 2 deletions expression/builtin_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ func (b *builtinGreatestTimeSig) evalString(row chunk.Row) (_ string, isNull boo
}
t, err = types.ParseDatetime(sc, v)
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return v, true, err
}
continue
Expand Down Expand Up @@ -800,7 +800,7 @@ func (b *builtinLeastTimeSig) evalString(row chunk.Row) (res string, isNull bool
}
t, err = types.ParseDatetime(sc, v)
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return v, true, err
} else if !findInvalidTime {
res = v
Expand Down
4 changes: 2 additions & 2 deletions expression/builtin_compare_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ func (b *builtinGreatestTimeSig) vecEvalString(input *chunk.Chunk, result *chunk
}
argTime, err = types.ParseDatetime(sc, result.GetString(i))
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
}
continue
Expand Down Expand Up @@ -739,7 +739,7 @@ func (b *builtinLeastTimeSig) vecEvalString(input *chunk.Chunk, result *chunk.Co
}
argTime, err = types.ParseDatetime(sc, result.GetString(i))
if err != nil {
if err = HandleInvalidTimeError(b.ctx, err); err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
} else if !findInvalidTime[i] {
invalidValue[i] = result.GetString(i)
Expand Down
Loading