summaryrefslogtreecommitdiff
path: root/sql/item_buff.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_buff.cc')
-rw-r--r--sql/item_buff.cc38
1 files changed, 34 insertions, 4 deletions
diff --git a/sql/item_buff.cc b/sql/item_buff.cc
index 1559cfe958e..af17d377e31 100644
--- a/sql/item_buff.cc
+++ b/sql/item_buff.cc
@@ -28,11 +28,20 @@ Item_buff *new_Item_buff(Item *item)
if (item->type() == Item::FIELD_ITEM &&
!(((Item_field *) item)->field->flags & BLOB_FLAG))
return new Item_field_buff((Item_field *) item);
- if (item->result_type() == STRING_RESULT)
+ switch (item->result_type()) {
+ case STRING_RESULT:
return new Item_str_buff((Item_field *) item);
- if (item->result_type() == INT_RESULT)
+ case INT_RESULT:
return new Item_int_buff((Item_field *) item);
- return new Item_real_buff(item);
+ case REAL_RESULT:
+ return new Item_real_buff(item);
+ case DECIMAL_RESULT:
+ return new Item_decimal_buff(item);
+ case ROW_RESULT:
+ default:
+ DBUG_ASSERT(0);
+ return 0;
+ }
}
Item_buff::~Item_buff() {}
@@ -70,7 +79,7 @@ Item_str_buff::~Item_str_buff()
bool Item_real_buff::cmp(void)
{
- double nr=item->val();
+ double nr= item->val_real();
if (null_value != item->null_value || nr != value)
{
null_value= item->null_value;
@@ -107,6 +116,27 @@ bool Item_field_buff::cmp(void)
}
+Item_decimal_buff::Item_decimal_buff(Item *it)
+ :item(it)
+{
+ my_decimal_set_zero(&value);
+}
+
+
+bool Item_decimal_buff::cmp()
+{
+ my_decimal tmp;
+ my_decimal *ptmp= item->val_decimal(&tmp);
+ if (null_value != item->null_value || my_decimal_cmp(&value, ptmp) == 0)
+ {
+ null_value= item->null_value;
+ my_decimal2decimal(ptmp, &value);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
/*****************************************************************************
** Instansiate templates
*****************************************************************************/