Skip to content

Commit

Permalink
executor: fix unexpected error in union stmt. (#16073) (#16138)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Apr 9, 2020
1 parent b210564 commit 370a12f
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 @@ -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
Expand Down
10 changes: 10 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;")
}

0 comments on commit 370a12f

Please sign in to comment.