Skip to content

Commit

Permalink
Fix bug: double free in Top Operator (#21339)
Browse files Browse the repository at this point in the history
Fix bug: double free in Top Operator

Approved by: @badboynt1, @aressu1985
  • Loading branch information
ouyuanning authored Jan 26, 2025
1 parent 6109699 commit b30a0ab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/sql/colexec/top/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ func (ctr *container) reset(proc *process.Process) {
}

if ctr.buildBat != nil {
ctr.buildBat.Clean(proc.Mp())
//should not clean ctr.buildBat, because ctr.buildBat's value from PreOperator or ctr.executorsForOrderColumn.Eval
// PreOperator or ctr.executorsForOrderColumn will clean them
ctr.buildBat = nil
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/distributed/cases/prepare/prepare.result
Original file line number Diff line number Diff line change
Expand Up @@ -641,4 +641,16 @@ internal error: table 'tb_delete_opt_to_truncate' has been changed, please reset
set session delete_opt_to_truncate = 123;
internal error: convert to the system variable bool type failed
drop table tb_delete_opt_to_truncate;
drop table if exists t1;
create table t1 (a bigint not null auto_increment, b int, primary key(a));
insert into t1(b) values (1),(2),(3);
prepare s1 from select * from t1 where a = ? order by a limit 1 for update;
set @a=1;
execute s1 using @a;
a b
1 1
set @a=2;
execute s1 using @a;
a b
2 2
drop database prepare_test_2;
8 changes: 8 additions & 0 deletions test/distributed/cases/prepare/prepare.test
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,14 @@ execute st_delete_opt_to_truncate;
set session delete_opt_to_truncate = 123;

drop table tb_delete_opt_to_truncate;
drop table if exists t1;
create table t1 (a bigint not null auto_increment, b int, primary key(a));
insert into t1(b) values (1),(2),(3);
prepare s1 from select * from t1 where a = ? order by a limit 1 for update;
set @a=1;
execute s1 using @a;
set @a=2;
execute s1 using @a;
drop database prepare_test_2;


Expand Down

0 comments on commit b30a0ab

Please sign in to comment.