Skip to content

Commit

Permalink
*: panic guard for warnings (#54043)
Browse files Browse the repository at this point in the history
close #48756
  • Loading branch information
xhebox authored Jul 1, 2024
1 parent affb6a4 commit 3c46a1e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,11 @@ func (e *ShowExec) fetchShowWarnings(errOnly bool) error {
sqlErr := terror.ToSQLError(x)
e.appendRow([]any{w.Level, int64(sqlErr.Code), sqlErr.Message})
default:
e.appendRow([]any{w.Level, int64(mysql.ErrUnknown), warn.Error()})
var err string
if warn != nil {
err = warn.Error()
}
e.appendRow([]any{w.Level, int64(mysql.ErrUnknown), err})
}
}
return nil
Expand Down
19 changes: 19 additions & 0 deletions pkg/executor/test/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2928,3 +2928,22 @@ func TestDecimalDivPrecisionIncrement(t *testing.T) {
tk.MustExec("set div_precision_increment = 10")
tk.MustQuery("select avg(a/b) from t").Check(testkit.Rows("1.21428571428571428550"))
}

func TestIssue48756(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("CREATE TABLE t (id INT, a VARBINARY(20), b BIGINT)")
tk.MustExec(`INSERT INTO t VALUES(1, _binary '2012-05-19 09:06:07', 20120519090607),
(1, _binary '2012-05-19 09:06:07', 20120519090607),
(2, _binary '12012-05-19 09:06:07', 120120519090607),
(2, _binary '12012-05-19 09:06:07', 120120519090607)`)
tk.MustQuery("SELECT SUBTIME(BIT_OR(b), '1 1:1:1.000002') FROM t GROUP BY id").Sort().Check(testkit.Rows(
"2012-05-18 08:05:05.999998",
"<nil>",
))
tk.MustQuery("show warnings").Check(testkit.Rows(
"Warning 1292 Incorrect time value: '120120519090607'",
"Warning 1105 ",
))
}

0 comments on commit 3c46a1e

Please sign in to comment.