Skip to content

Commit

Permalink
Move var
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie committed Mar 18, 2024
1 parent 56141fc commit 9f30c2d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/rdbms/scan/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func (s *Scanner) Next() ([]map[string]any, error) {
return nil, err
}

wasFirstBatch := s.isFirstBatch
s.isFirstBatch = false

if len(rows) == 0 || s.primaryKeys.IsExhausted() {
s.done = true
} else {
Expand All @@ -102,15 +105,13 @@ func (s *Scanner) Next() ([]map[string]any, error) {
startingValuesChanged = startingValuesChanged || changed
}

if !s.isFirstBatch && !startingValuesChanged {
if !wasFirstBatch && !startingValuesChanged {
// Detect situations where the scanner is stuck in a loop.
// The second batch will use a > comparision instead of a > comparision for the lower bound.
return nil, fmt.Errorf("primarky key start values did not change, scanner is stuck in a loop")
}
}

s.isFirstBatch = false

return rows, nil
}

Expand Down

0 comments on commit 9f30c2d

Please sign in to comment.