33
33
#include <drizzled/functions/func.h>
34
34
#include <drizzled/functions/int.h>
35
#include <drizzled/functions/numhybrid.h>
36
#include <drizzled/functions/num_op.h>
35
37
#include <drizzled/functions/real.h>
38
class Item_func_numhybrid: public Item_func
41
Item_result hybrid_type;
43
Item_func_numhybrid(Item *a) :Item_func(a), hybrid_type(REAL_RESULT)
45
Item_func_numhybrid(Item *a,Item *b)
46
:Item_func(a,b), hybrid_type(REAL_RESULT)
48
Item_func_numhybrid(List<Item> &list)
49
:Item_func(list), hybrid_type(REAL_RESULT)
52
enum Item_result result_type () const { return hybrid_type; }
53
void fix_length_and_dec();
54
void fix_num_length_and_dec();
55
virtual void find_num_type()= 0; /* To be called from fix_length_and_dec */
59
my_decimal *val_decimal(my_decimal *);
60
String *val_str(String*str);
63
@brief Performs the operation that this functions implements when the
66
@return The result of the operation.
68
virtual int64_t int_op()= 0;
71
@brief Performs the operation that this functions implements when the
74
@return The result of the operation.
76
virtual double real_op()= 0;
79
@brief Performs the operation that this functions implements when the
80
result type is DECIMAL.
82
@param A pointer where the DECIMAL value will be allocated.
84
- 0 If the result is NULL
85
- The same pointer it was given, with the area initialized to the
86
result of the operation.
88
virtual my_decimal *decimal_op(my_decimal *)= 0;
91
@brief Performs the operation that this functions implements when the
92
result type is a string type.
94
@return The result of the operation.
96
virtual String *str_op(String *)= 0;
97
bool is_null() { update_null_value(); return null_value; }
100
40
/* function where type of result detected by first argument */
101
41
class Item_func_num1: public Item_func_numhybrid
114
/* Base class for operations like '+', '-', '*' */
115
class Item_num_op :public Item_func_numhybrid
118
Item_num_op(Item *a,Item *b) :Item_func_numhybrid(a, b) {}
119
virtual void result_precision()= 0;
121
virtual inline void print(String *str, enum_query_type query_type)
123
print_op(str, query_type);
126
void find_num_type();
127
String *str_op(String *str __attribute__((unused)))
128
{ assert(0); return 0; }
132
54
class Item_func_connection_id :public Item_int_func