From 9f30c2dd8c0401ca9cecffb8c420722d907ec320 Mon Sep 17 00:00:00 2001 From: Nathan Villaescusa Date: Mon, 18 Mar 2024 15:12:32 -0700 Subject: [PATCH] Move var --- lib/rdbms/scan/scan.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/rdbms/scan/scan.go b/lib/rdbms/scan/scan.go index c4169cd6..97e47d47 100644 --- a/lib/rdbms/scan/scan.go +++ b/lib/rdbms/scan/scan.go @@ -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 { @@ -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 }