diff --git a/pkg/executor/show.go b/pkg/executor/show.go index f84dc5404b021..2b4460ca676cd 100644 --- a/pkg/executor/show.go +++ b/pkg/executor/show.go @@ -1886,7 +1886,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 diff --git a/pkg/executor/test/executor/executor_test.go b/pkg/executor/test/executor/executor_test.go index c0591bde97465..02e37dd0ad498 100644 --- a/pkg/executor/test/executor/executor_test.go +++ b/pkg/executor/test/executor/executor_test.go @@ -2929,3 +2929,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", + "", + )) + tk.MustQuery("show warnings").Check(testkit.Rows( + "Warning 1292 Incorrect time value: '120120519090607'", + "Warning 1105 ", + )) +}