Skip to content

Commit

Permalink
executor: fix unexpected error in union stmt. (#16073)
Browse files Browse the repository at this point in the history
  • Loading branch information
wshwsh12 authored Apr 8, 2020
1 parent 38d9711 commit 96d96ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;")
}

0 comments on commit 96d96ce

Please sign in to comment.