1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-21195 INSERT chooses wrong partition for RANGE partitioning by DECIMAL column

Use FLOOR rounding for DECIMAL_RESULT item_expr in partition function.
This commit is contained in:
Aleksey Midenkov
2020-02-02 15:13:29 +03:00
parent 74deeaee34
commit b0fa308086
5 changed files with 116 additions and 6 deletions

View File

@ -2840,14 +2840,34 @@ bool partition_key_modified(TABLE *table, const MY_BITMAP *fields)
static inline int part_val_int(Item *item_expr, longlong *result)
{
*result= item_expr->val_int();
switch (item_expr->cmp_type())
{
case DECIMAL_RESULT:
{
my_decimal buf;
my_decimal *val= item_expr->val_decimal(&buf);
if (val && my_decimal2int(E_DEC_FATAL_ERROR, val, item_expr->unsigned_flag,
result, FLOOR) != E_DEC_OK)
return true;
break;
}
case INT_RESULT:
*result= item_expr->val_int();
break;
case STRING_RESULT:
case REAL_RESULT:
case ROW_RESULT:
case TIME_RESULT:
DBUG_ASSERT(0);
break;
}
if (item_expr->null_value)
{
if (unlikely(current_thd->is_error()))
return TRUE;
return true;
*result= LONGLONG_MIN;
}
return FALSE;
return false;
}