Skip to content

Commit

Permalink
executor: fix pipelined window invalid memory address (#30418) (#30460)
Browse files Browse the repository at this point in the history
close #30326
  • Loading branch information
ti-srebot committed Feb 22, 2022
1 parent d139c62 commit 01f72bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion executor/pipelined_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (e *PipelinedWindowExec) getRowsInPartition(ctx context.Context) (err error
var drained, samePartition bool
drained, err = e.fetchChild(ctx)
if err != nil {
err = errors.Trace(err)
return errors.Trace(err)
}
// we return immediately to use a combination of true newPartition but 0 in e.rowToConsume to indicate the data source is drained,
if drained {
Expand Down
12 changes: 12 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10548,3 +10548,15 @@ func (s *testIntegrationSuite) TestIssue29513(c *C) {
tk.MustQuery("select '123' union select cast(a as char) from t;").Sort().Check(testkit.Rows("123", "45678"))
tk.MustQuery("select '123' union select cast(a as char(2)) from t;").Sort().Check(testkit.Rows("123", "45"))
}

func (s *testIntegrationSuite) TestIssue30326(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t;")
tk.MustExec("create table t(a int);")
tk.MustExec("insert into t values(1),(1),(2),(2);")
tk.MustExec("set tidb_window_concurrency = 1;")
err := tk.QueryToErr("select (FIRST_VALUE(1) over (partition by v.a)) as c3 from (select a from t where t.a = (select a from t t2 where t.a = t2.a)) as v;")
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "[executor:1242]Subquery returns more than 1 row")
}

0 comments on commit 01f72bf

Please sign in to comment.