summaryrefslogtreecommitdiff
path: root/sql/item_buff.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-08-07 10:48:42 +0400
committerAlexander Barkov <bar@mariadb.com>2018-08-07 10:48:42 +0400
commitcb7b5fbf1cf7c5bcd0509e428a53a8b8d6fbba0f (patch)
tree97a2de6b50c55fdecbaacbde75775196ff347421 /sql/item_buff.cc
parent01e4426a6352740973ff275eac60ddacc90da119 (diff)
downloadmariadb-git-cb7b5fbf1cf7c5bcd0509e428a53a8b8d6fbba0f.tar.gz
MDEV-16910 Add class VDec
Adding classes VDec and VDec2_lazy, according to the task description. This patch removes around 250 duplicate code lines.
Diffstat (limited to 'sql/item_buff.cc')
-rw-r--r--sql/item_buff.cc25
1 files changed, 8 insertions, 17 deletions
diff --git a/sql/item_buff.cc b/sql/item_buff.cc
index 4d03462d7c3..3467fda79c7 100644
--- a/sql/item_buff.cc
+++ b/sql/item_buff.cc
@@ -225,16 +225,15 @@ Cached_item_decimal::Cached_item_decimal(Item *it)
bool Cached_item_decimal::cmp()
{
- my_decimal tmp;
- my_decimal *ptmp= item->val_decimal(&tmp);
- if (null_value != item->null_value ||
- (!item->null_value && my_decimal_cmp(&value, ptmp)))
+ VDec tmp(item);
+ if (null_value != tmp.is_null() ||
+ (!tmp.is_null() && tmp.cmp(&value)))
{
- null_value= item->null_value;
+ null_value= tmp.is_null();
/* Save only not null values */
if (!null_value)
{
- my_decimal2decimal(ptmp, &value);
+ my_decimal2decimal(tmp.ptr(), &value);
return TRUE;
}
return FALSE;
@@ -245,17 +244,9 @@ bool Cached_item_decimal::cmp()
int Cached_item_decimal::cmp_read_only()
{
- my_decimal tmp;
- my_decimal *ptmp= item->val_decimal(&tmp);
+ VDec tmp(item);
if (null_value)
- {
- if (item->null_value)
- return 0;
- else
- return -1;
- }
- if (item->null_value)
- return 1;
- return my_decimal_cmp(&value, ptmp);
+ return tmp.is_null() ? 0 : -1;
+ return tmp.is_null() ? 1 : value.cmp(tmp.ptr());
}