33
33
#include <drizzled/functions/func.h>
34
34
#include <drizzled/functions/int.h>
36
class Item_real_func :public Item_func
39
Item_real_func() :Item_func() {}
40
Item_real_func(Item *a) :Item_func(a) {}
41
Item_real_func(Item *a,Item *b) :Item_func(a,b) {}
42
Item_real_func(List<Item> &list) :Item_func(list) {}
43
String *val_str(String*str);
44
my_decimal *val_decimal(my_decimal *decimal_value);
46
{ assert(fixed == 1); return (int64_t) rint(val_real()); }
47
enum Item_result result_type () const { return REAL_RESULT; }
48
void fix_length_and_dec()
49
{ decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
53
class Item_func_numhybrid: public Item_func
56
Item_result hybrid_type;
58
Item_func_numhybrid(Item *a) :Item_func(a), hybrid_type(REAL_RESULT)
60
Item_func_numhybrid(Item *a,Item *b)
61
:Item_func(a,b), hybrid_type(REAL_RESULT)
63
Item_func_numhybrid(List<Item> &list)
64
:Item_func(list), hybrid_type(REAL_RESULT)
67
enum Item_result result_type () const { return hybrid_type; }
68
void fix_length_and_dec();
69
void fix_num_length_and_dec();
70
virtual void find_num_type()= 0; /* To be called from fix_length_and_dec */
74
my_decimal *val_decimal(my_decimal *);
75
String *val_str(String*str);
78
@brief Performs the operation that this functions implements when the
81
@return The result of the operation.
83
virtual int64_t int_op()= 0;
86
@brief Performs the operation that this functions implements when the
89
@return The result of the operation.
91
virtual double real_op()= 0;
94
@brief Performs the operation that this functions implements when the
95
result type is DECIMAL.
97
@param A pointer where the DECIMAL value will be allocated.
99
- 0 If the result is NULL
100
- The same pointer it was given, with the area initialized to the
101
result of the operation.
103
virtual my_decimal *decimal_op(my_decimal *)= 0;
106
@brief Performs the operation that this functions implements when the
107
result type is a string type.
109
@return The result of the operation.
111
virtual String *str_op(String *)= 0;
112
bool is_null() { update_null_value(); return null_value; }
35
#include <drizzled/functions/numhybrid.h>
36
#include <drizzled/functions/num_op.h>
37
#include <drizzled/functions/real.h>
115
40
/* function where type of result detected by first argument */
116
41
class Item_func_num1: public Item_func_numhybrid
129
/* Base class for operations like '+', '-', '*' */
130
class Item_num_op :public Item_func_numhybrid
133
Item_num_op(Item *a,Item *b) :Item_func_numhybrid(a, b) {}
134
virtual void result_precision()= 0;
136
virtual inline void print(String *str, enum_query_type query_type)
138
print_op(str, query_type);
141
void find_num_type();
142
String *str_op(String *str __attribute__((unused)))
143
{ assert(0); return 0; }
147
54
class Item_func_connection_id :public Item_int_func