Skip to content

Commit f2fc97a

Browse files
committed
Fixed CORE-6486 and CORE-6487 with one shot
1 parent 0acb837 commit f2fc97a

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

src/jrd/recsrc/Cursor.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,10 @@ bool Cursor::fetchAbsolute(thread_db* tdbb, SINT64 offset) const
281281
return false;
282282
}
283283

284-
const BufferedStream* const buffer = static_cast<const BufferedStream*>(m_top);
285-
impure->irsb_position = (offset > 0) ? offset - 1 : buffer->getCount(tdbb) + offset;
284+
const auto buffer = static_cast<const BufferedStream*>(m_top);
285+
const auto count = buffer->getCount(tdbb);
286+
287+
impure->irsb_position = (offset > 0) ? offset - 1 : count + offset;
286288
buffer->locate(tdbb, impure->irsb_position);
287289

288290
if (!buffer->getRecord(tdbb))
@@ -323,18 +325,28 @@ bool Cursor::fetchRelative(thread_db* tdbb, SINT64 offset) const
323325
return (impure->irsb_state == POSITIONED);
324326
}
325327

326-
if (impure->irsb_state == BOS && offset < 0)
328+
const auto buffer = static_cast<const BufferedStream*>(m_top);
329+
const auto count = buffer->getCount(tdbb);
330+
331+
if (impure->irsb_state == BOS)
327332
{
328-
return false;
333+
if (offset < 0)
334+
return false;
335+
336+
impure->irsb_position = offset - 1;
329337
}
338+
else if (impure->irsb_state == EOS)
339+
{
340+
if (offset > 0)
341+
return false;
330342

331-
if (impure->irsb_state == EOS && offset > 0)
343+
impure->irsb_position = count + offset;
344+
}
345+
else
332346
{
333-
return false;
347+
impure->irsb_position += offset;
334348
}
335349

336-
const BufferedStream* const buffer = static_cast<const BufferedStream*>(m_top);
337-
impure->irsb_position += offset;
338350
buffer->locate(tdbb, impure->irsb_position);
339351

340352
if (!buffer->getRecord(tdbb))

0 commit comments

Comments
 (0)