diff options
author | unknown <hf@deer.(none)> | 2005-02-09 02:50:45 +0400 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2005-02-09 02:50:45 +0400 |
commit | 91db48e35a57421c00f65d5ce82e84b843ceec22 (patch) | |
tree | 9631c72d46b0fd08479ad02de00e5846cd339cda /sql/item_buff.cc | |
parent | 63bcbfc4339ae843dc367d08fff0760da4d484c3 (diff) | |
download | mariadb-git-91db48e35a57421c00f65d5ce82e84b843ceec22.tar.gz |
Precision Math implementation
BitKeeper/etc/ignore:
Added client/decimal.c client/my_decimal.cc client/my_decimal.h to the ignore list
Diffstat (limited to 'sql/item_buff.cc')
-rw-r--r-- | sql/item_buff.cc | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 66de26dba9a..7c77f7fa3bc 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -28,11 +28,21 @@ 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() {} @@ -107,6 +117,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 *****************************************************************************/ |