Clamp fractional row estimates to at least 1

This commit is contained in:
Yasuhiro Matsumoto
2026-07-29 11:10:45 +09:00
parent 1f0b756378
commit 2897b83d18

View File

@@ -493,8 +493,9 @@ func goVBestIndex(pVTab unsafe.Pointer, icp unsafe.Pointer) *C.char {
var rows int64 var rows int64
if res.EstimatedRows >= float64(math.MaxInt64) { if res.EstimatedRows >= float64(math.MaxInt64) {
rows = math.MaxInt64 rows = math.MaxInt64
} else { } else if rows = int64(res.EstimatedRows); rows < 1 {
rows = int64(res.EstimatedRows) // A positive fractional estimate must not truncate to 0.
rows = 1
} }
info.estimatedRows = C.sqlite3_int64(rows) info.estimatedRows = C.sqlite3_int64(rows)
} }