diff --git a/executor/executor_test.go b/executor/executor_test.go index 7546057ebc838..9ef7f77009cc3 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -6688,3 +6688,22 @@ func TestIssue51324(t *testing.T) { tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1364 Field 'a' doesn't have a default value", "Warning 1364 Field 'b' doesn't have a default value", "Warning 1364 Field 'c' doesn't have a default value", "Warning 1364 Field 'd' doesn't have a default value")) tk.MustQuery("select * from t order by id").Check(testkit.Rows("13 0 0", "21 1 0 1", "22 1 0 1")) } + +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", + "", + )) + tk.MustQuery("show warnings").Check(testkit.Rows( + "Warning 1292 Incorrect time value: '120120519090607'", + "Warning 1105 ", + )) +} diff --git a/executor/show.go b/executor/show.go index a029227c39713..0ce741bd1945d 100644 --- a/executor/show.go +++ b/executor/show.go @@ -1833,7 +1833,11 @@ func (e *ShowExec) fetchShowWarnings(errOnly bool) error { sqlErr := terror.ToSQLError(x) e.appendRow([]interface{}{w.Level, int64(sqlErr.Code), sqlErr.Message}) default: - e.appendRow([]interface{}{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