Skip to content

Commit 2897b83

Browse files
committed
Clamp fractional row estimates to at least 1
1 parent 1f0b756 commit 2897b83

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

sqlite3_opt_vtable.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,9 @@ func goVBestIndex(pVTab unsafe.Pointer, icp unsafe.Pointer) *C.char {
493493
var rows int64
494494
if res.EstimatedRows >= float64(math.MaxInt64) {
495495
rows = math.MaxInt64
496-
} else {
497-
rows = int64(res.EstimatedRows)
496+
} else if rows = int64(res.EstimatedRows); rows < 1 {
497+
// A positive fractional estimate must not truncate to 0.
498+
rows = 1
498499
}
499500
info.estimatedRows = C.sqlite3_int64(rows)
500501
}

0 commit comments

Comments
 (0)