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

Merged
merged 4 commits into from
Jul 1, 2024
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 @@ -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})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but why is there an empty warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, maybe we can open a new issue? We should be able to track the source by 1105 code.

}
}
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 ",
))
}