Skip to content

Commit

Permalink
Postfix for CORE-6344 - fixed MOD()
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPeshkoff committed Jul 1, 2020
1 parent ab86bc7 commit b728ff3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/jrd/SysFunction.cpp
Expand Up @@ -1458,6 +1458,7 @@ void makeMod(DataTypeUtilBase*, const SysFunction* function, dsc* result,
case dtype_short:
case dtype_long:
case dtype_int64:
case dtype_int128:
*result = *value1;
result->dsc_scale = 0;
break;
Expand Down Expand Up @@ -5064,6 +5065,20 @@ dsc* evlMod(thread_db* tdbb, const SysFunction*, const NestValueArray& args,
EVL_make_value(tdbb, value1, impure);
impure->vlu_desc.dsc_scale = 0;

if (impure->vlu_desc.dsc_dtype == dtype_int128)
{
const Int128 divisor = MOV_get_int128(tdbb, value2, 0);
Int128 cmp0;
cmp0.set(0, 0);

if (divisor == cmp0)
status_exception::raise(Arg::Gds(isc_arith_except) << Arg::Gds(isc_exception_integer_divide_by_zero));

impure->vlu_misc.vlu_int128 = MOV_get_int128(tdbb, value1, 0).mod(divisor);

return &impure->vlu_desc;
}

const SINT64 divisor = MOV_get_int64(tdbb, value2, 0);

if (divisor == 0)
Expand Down

0 comments on commit b728ff3

Please sign in to comment.