Skip to content

Commit b7b2bed

Browse files
committed
Backport bugfix for CORE-6486 and CORE-6487
1 parent e656185 commit b7b2bed

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

src/jrd/recsrc/Cursor.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ bool Cursor::fetchAbsolute(thread_db* tdbb, SINT64 offset) const
282282
}
283283

284284
const BufferedStream* const buffer = static_cast<const BufferedStream*>(m_top);
285-
impure->irsb_position = (offset > 0) ? offset - 1 : buffer->getCount(tdbb) + offset;
285+
const FB_UINT64 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,29 @@ 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 BufferedStream* const buffer = static_cast<const BufferedStream*>(m_top);
329+
const FB_UINT64 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
}
330338

331-
if (impure->irsb_state == EOS && offset > 0)
339+
if (impure->irsb_state == EOS)
332340
{
333-
return false;
341+
if (offset > 0)
342+
return false;
343+
344+
impure->irsb_position = count + offset;
345+
}
346+
else
347+
{
348+
impure->irsb_position += offset;
334349
}
335350

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

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

0 commit comments

Comments
 (0)