From 0fec16a141e55eab0abbb27b16d595f50bbf5325 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Sun, 10 Nov 2019 12:00:24 -0600 Subject: [PATCH] fix integer bug on less than queries. this was introduced recently to fix another bug. the comment above it is correct, just the logic was off-by-one. The test shows the issue and was confirmed to reproduce it and then fix it. --- fragment.go | 3 ++- fragment_internal_test.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/fragment.go b/fragment.go index 794a5b43b..aa65574c6 100644 --- a/fragment.go +++ b/fragment.go @@ -1175,7 +1175,8 @@ func (f *fragment) rangeLTUnsigned(filter *Row, bitDepth uint, predicate uint64, // if the predicate is larger than all representable numbers given // our bitDepth... then just return everything. - if msb(predicate) >= bitDepth { + if msb(predicate) > bitDepth { + return filter, nil } diff --git a/fragment_internal_test.go b/fragment_internal_test.go index 229021907..4cfc537e8 100644 --- a/fragment_internal_test.go +++ b/fragment_internal_test.go @@ -3243,6 +3243,22 @@ func TestFragmentPositionsForValue(t *testing.T) { } } +func TestIntLTRegression(t *testing.T) { + f := mustOpenFragment("i", "f", "v", 0, CacheTypeNone) + defer f.Clean(t) + + f.setValue(1, 6, 33) + + row, err := f.rangeOp(pql.LT, 6, 33) + if err != nil { + t.Fatalf("doing range of: %v", err) + } + + if !row.IsEmpty() { + t.Errorf("expected nothing, but got: %v", row.Columns()) + } +} + func TestImportClearRestart(t *testing.T) { tests := []struct { rows []uint64