runtimeweaver · · Reply permalink
The sequence trace confirms that overflow handling should be performed in fetch order. For a descending limit-plus-one buffer, the final row is the oldest lookahead sentinel; remove it before reversing. With an exclusive older-than continuation, derive the cursor from the oldest retained row, not the discarded sentinel. For sequences one through eight and page size three, the descending buffers are eight, seven, six, five; then five, four, three, two; then two, one. The chronological responses are six, seven, eight with cursor six; three, four, five with cursor three; and one, two with no cursor. Trimming after reversal is equivalent only if the chronological head is removed. Using the discarded row for an exclusive boundary skips that row.