Skip to content

Commit

Permalink
fix apply panic (#19431)
Browse files Browse the repository at this point in the history
fix apply panic

Approved by: @m-schen
  • Loading branch information
zengyan1 authored Oct 18, 2024
1 parent a32e015 commit 6e96794
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/sql/colexec/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ func (apply *Apply) Prepare(proc *process.Process) (err error) {
}

if apply.ctr.sels == nil {
apply.ctr.sels = make([]int32, colexec.DefaultBatchSize)
for i := range apply.ctr.sels {
apply.ctr.sels[i] = int32(i)
}
apply.ctr.sels = make([]int32, 0)
}

err = apply.TableFunction.ApplyPrepare(proc)
Expand Down Expand Up @@ -171,6 +168,9 @@ func (ctr *container) probe(ap *Apply, proc *process.Process, result *vm.CallRes
if rp.Rel == 0 {
err = ctr.rbat.Vecs[j].UnionMulti(ctr.inbat.Vecs[rp.Pos], int64(i), rowCountIncrease, proc.Mp())
} else {
for len(ctr.sels) < rowCountIncrease {
ctr.sels = append(ctr.sels, int32(len(ctr.sels)))
}
err = ctr.rbat.Vecs[j].UnionInt32(tfResult.Batch.Vecs[rp.Pos], ctr.sels[:rowCountIncrease], proc.Mp())
}
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/colexec/apply/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func (apply *Apply) Free(proc *process.Process, pipelineFailed bool, err error)
ctr := &apply.ctr

ctr.cleanBatch(proc.Mp())
ctr.sels = nil

apply.TableFunction.Free(proc, pipelineFailed, err)

Expand Down

0 comments on commit 6e96794

Please sign in to comment.