diff --git a/executor/executor.go b/executor/executor.go index a2853f3cec2e2..baee88e78d760 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -1610,6 +1610,12 @@ func ResetContextOfStmt(ctx sessionctx.Context, s ast.StmtNode) (err error) { sc.Priority = opts.Priority sc.NotFillCache = !opts.SQLCache } + case *ast.UnionStmt: + sc.InSelectStmt = true + sc.OverflowAsWarning = true + sc.TruncateAsWarning = true + sc.IgnoreZeroInDate = true + sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode() case *ast.ShowStmt: sc.IgnoreTruncate = true sc.IgnoreZeroInDate = true diff --git a/expression/integration_test.go b/expression/integration_test.go index ba065b81c1d65..5470ab9839889 100755 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -5971,3 +5971,13 @@ func (s *testIntegrationSuite) TestNegativeZeroForHashJoin(c *C) { tk.MustExec("drop TABLE t0;") tk.MustExec("drop table t1;") } + +func (s *testIntegrationSuite) TestIssue15790(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test;") + tk.MustExec("CREATE TABLE t0(c0 INT);") + tk.MustExec("INSERT INTO t0(c0) VALUES (0);") + tk.MustQuery("SELECT * FROM t0 WHERE -10000000000000000000 | t0.c0 UNION SELECT * FROM t0;").Check(testkit.Rows("0")) + tk.MustQuery("SELECT * FROM t0 WHERE -10000000000000000000 | t0.c0 UNION all SELECT * FROM t0;").Check(testkit.Rows("0", "0")) + tk.MustExec("drop table t0;") +}