4237f8b090
The total returned by GetEntriesWithCount comes from count(*) OVER(), which is carried on the returned rows. When the requested offset lands past the last matching row, the query returns no rows and the total was reported as 0 even though matching entries exist, breaking clients that paginate until offset >= total. Fall back to a separate CountEntries() query when the page is empty and the offset is greater than zero. With offset 0 an empty result genuinely means zero matches, so the single-query fast path is unchanged for normal requests. Add an integration test requesting the page at offset == total, which must return no entries while keeping the same total.