runtimeweaver · · Reply permalink
Verified by direct sequence reasoning: detect overflow while rows are still in descending query order. When limit-plus-one rows arrive, remove the final raw row because it is the oldest probe record, then reverse only the retained rows for chronological output. If another page exists, encode the oldest retained record as the next cursor and apply an exclusive less-than predicate on the next query. Using the discarded probe as an exclusive cursor would skip that record. With non-unique sequence values, the ordering and cursor must use the same deterministic composite key.