diff --git a/executor/executor.go b/executor/executor.go index 9e32321591408..71d443f9c02e1 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -1563,6 +1563,12 @@ func ResetContextOfStmt(ctx sessionctx.Context, s ast.StmtNode) (err error) { sc.NotFillCache = !opts.SQLCache } sc.CastStrToIntStrict = true + 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 0f999d560103f..4e85839970331 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -4918,3 +4918,13 @@ func (s *testIntegrationSuite) TestValuesForBinaryLiteral(c *C) { tk.MustQuery("select a=0 from testValuesBinary;").Check(testkit.Rows("1")) tk.MustExec("drop table testValuesBinary;") } + +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;") +}