1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-179 Don't round before divide for DIV. Mimic InnoDB behavior.

This commit is contained in:
David Hall
2019-07-31 15:03:12 -05:00
parent 1b9d10c84e
commit e768a6c5ce

View File

@ -51,6 +51,16 @@ int64_t Func_div::getIntVal(rowgroup::Row& row,
{ {
double val1 = parm[0]->data()->getDoubleVal(row, isNull); double val1 = parm[0]->data()->getDoubleVal(row, isNull);
double val2 = parm[1]->data()->getDoubleVal(row, isNull); double val2 = parm[1]->data()->getDoubleVal(row, isNull);
if (val2 == 0 || val2 == NAN)
{
isNull = true;
return 0;
}
// MCOL-179 InnoDB doesn't round or convert to int before dividing.
return static_cast<int64_t>(val1 / val2);
#if 0
int64_t int_val2 = (int64_t)(val2 > 0 ? val2 + 0.5 : val2 - 0.5); int64_t int_val2 = (int64_t)(val2 > 0 ? val2 + 0.5 : val2 - 0.5);
if (int_val2 == 0) if (int_val2 == 0)
@ -69,6 +79,7 @@ int64_t Func_div::getIntVal(rowgroup::Row& row,
} }
return int_val1 / int_val2; return int_val1 / int_val2;
#endif
} }