Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#54043
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
xhebox authored and ti-chi-bot committed Jul 1, 2024
1 parent 4f5d583 commit 66bf00d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,15 @@ func (e *ShowExec) fetchShowWarnings(errOnly bool) error {
sqlErr := terror.ToSQLError(x)
e.appendRow([]interface{}{w.Level, int64(sqlErr.Code), sqlErr.Message})
default:
<<<<<<< HEAD
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})
>>>>>>> 3c46a1e072c (*: panic guard for warnings (#54043))
}
}
return nil
Expand Down
46 changes: 46 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,49 @@ 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"))
}
<<<<<<< HEAD
=======

func TestDecimalDivPrecisionIncrement(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t (a decimal(3,0), b decimal(3,0))")
tk.MustExec("insert into t values (8, 7), (9, 7)")
tk.MustQuery("select a/b from t").Check(testkit.Rows("1.1429", "1.2857"))

tk.MustExec("set div_precision_increment = 7")
tk.MustQuery("select a/b from t").Check(testkit.Rows("1.1428571", "1.2857143"))

tk.MustExec("set div_precision_increment = 30")
tk.MustQuery("select a/b from t").Check(testkit.Rows("1.142857142857142857142857142857", "1.285714285714285714285714285714"))

tk.MustExec("set div_precision_increment = 4")
tk.MustQuery("select avg(a) from t").Check(testkit.Rows("8.5000"))

tk.MustExec("set div_precision_increment = 4")
tk.MustQuery("select avg(a/b) from t").Check(testkit.Rows("1.21428571"))

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 ",
))
}
>>>>>>> 3c46a1e072c (*: panic guard for warnings (#54043))

0 comments on commit 66bf00d

Please sign in to comment.