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

*: panic guard for warnings (#54043) #54369

Merged
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
6 changes: 5 additions & 1 deletion pkg/executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,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
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 @@ -4453,3 +4453,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 <nil> <nil> 0 0", "21 1 <nil> 0 1", "22 1 <nil> 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",
"<nil>",
))
tk.MustQuery("show warnings").Check(testkit.Rows(
"Warning 1292 Incorrect time value: '120120519090607'",
"Warning 1105 ",
))
}