Skip to content

Commit

Permalink
executor: fix unexpected error in union stmt. (#16073) (#16137)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Apr 9, 2020
1 parent 792ce6c commit d82cf4c
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 @@ -1542,6 +1542,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 @@ -4920,6 +4920,16 @@ func (s *testIntegrationSuite) TestValuesForBinaryLiteral(c *C) {
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;")
}

func (s *testIntegrationSuite) TestCacheRefineArgs(c *C) {
tk := testkit.NewTestKit(c, s.store)
orgEnable := plannercore.PreparedPlanCacheEnabled()
Expand Down

0 comments on commit d82cf4c

Please sign in to comment.