Skip to content

Commit

Permalink
simplify the ignore zero date flag logic
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
  • Loading branch information
YangKeao committed Oct 25, 2023
1 parent bbf2ed9 commit 915c74d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,7 @@ func ResetContextOfStmt(ctx sessionctx.Context, s ast.StmtNode) (err error) {
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()).
WithIgnoreZeroInDate(!vars.SQLMode.HasNoZeroInDateMode() || !vars.StrictSQLMode ||
vars.SQLMode.HasAllowInvalidDatesMode()).
WithIgnoreZeroDateErr(!vars.SQLMode.HasNoZeroDateMode()))
WithIgnoreZeroDateErr(!vars.SQLMode.HasNoZeroDateMode() || !vars.StrictSQLMode))

case *ast.LoadDataStmt:
sc.InLoadDataStmt = true
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2038,7 +2038,7 @@ func ParseTimeFromNum(ctx Context, num int64, tp byte, fsp int) (Time, error) {
// MySQL compatibility: 0 should not be converted to null, see #11203
if num == 0 {
zt := NewTime(ZeroCoreTime, tp, DefaultFsp)
if !ctx.Flags().TruncateAsWarning() && !ctx.Flags().IgnoreZeroDateErr() {
if !ctx.Flags().IgnoreZeroDateErr() {
switch tp {
case mysql.TypeTimestamp:
return zt, ErrTruncatedWrongVal.GenWithStackByArgs(TimestampStr, "0")
Expand Down

0 comments on commit 915c74d

Please sign in to comment.