Skip to content

Commit a98863a

Browse files
committed
Fixes a loop in the GENERATE_SERIES function on boundary values.
1 parent 3d41aac commit a98863a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/jrd/recsrc/TableValueFunctionScan.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,13 @@ bool GenSeriesFunctionScan::nextBuffer(thread_db* tdbb) const
522522
fromDesc.makeInt64(impure->m_scale, &result);
523523
assignParameter(tdbb, &fromDesc, toDesc, 0, record);
524524

525-
result += step;
525+
// Fixes freezing at boundary values.
526+
if (((step < 0) && (result == MIN_SINT64)) ||
527+
((step > 0) && (result == MAX_SINT64)))
528+
impure->m_step.vlu_int64 = 0;
529+
else
530+
result += step;
531+
526532
impure->m_result.vlu_int64 = result;
527533

528534
return true;
@@ -545,7 +551,12 @@ bool GenSeriesFunctionScan::nextBuffer(thread_db* tdbb) const
545551
fromDesc.makeInt128(impure->m_scale, &result);
546552
assignParameter(tdbb, &fromDesc, toDesc, 0, record);
547553

548-
result = result.add(step);
554+
// Fixes freezing at boundary values.
555+
if (((step.sign() < 0) && (result.compare(MIN_Int128) == 0)) ||
556+
((step.sign() > 0) && (result.compare(MAX_Int128) == 0)))
557+
impure->m_step.vlu_int128.set(0, 0);
558+
else
559+
result = result.add(step);
549560
impure->m_result.vlu_int128 = result;
550561

551562
return true;

0 commit comments

Comments
 (0)