Skip to content

Commit

Permalink
exec: avoid calling ResetInternalBatch twice
Browse files Browse the repository at this point in the history
The hashJoiner was calling Next recursively, resulting in resetting
hj.prober.batch twice, which could lead to corruption (by unsetting
selection vectors or nulls).

Release note: None
  • Loading branch information
asubiotto committed Sep 10, 2019
1 parent e4da4b3 commit 2f9f441
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/sql/exec/hashjoiner.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,20 @@ func (hj *hashJoinEqOp) Init() {

func (hj *hashJoinEqOp) Next(ctx context.Context) coldata.Batch {
hj.prober.batch.ResetInternalBatch()
return hj.nextInternal(ctx)
}

func (hj *hashJoinEqOp) nextInternal(ctx context.Context) coldata.Batch {
switch hj.runningState {
case hjBuilding:
hj.build(ctx)
return hj.Next(ctx)
return hj.nextInternal(ctx)
case hjProbing:
hj.prober.exec(ctx)

if hj.prober.batch.Length() == 0 && hj.builder.spec.outer {
hj.initEmitting()
return hj.Next(ctx)
return hj.nextInternal(ctx)
}
return hj.prober.batch
case hjEmittingUnmatched:
Expand Down

0 comments on commit 2f9f441

Please sign in to comment.