summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2020-02-02 15:13:29 +0300
committerAleksey Midenkov <midenok@gmail.com>2020-02-02 15:13:29 +0300
commitb0fa30808622fe12d474a70af1838906e60b9897 (patch)
treed3a9096d3f7bfcf51411b8a6892733a9c31e6e7c /sql/sql_partition.cc
parent74deeaee342c901c92b91d12033771716a373d8e (diff)
downloadmariadb-git-b0fa30808622fe12d474a70af1838906e60b9897.tar.gz
MDEV-21195 INSERT chooses wrong partition for RANGE partitioning by DECIMAL column
Use FLOOR rounding for DECIMAL_RESULT item_expr in partition function.
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 00a78ce3199..febd88c4b9b 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -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;
}