53
57
#include <drizzled/functions/time/period_diff.h>
54
58
#include <drizzled/functions/time/sec_to_time.h>
55
59
#include <drizzled/functions/time/second.h>
60
#include <drizzled/functions/time/str_to_date.h>
56
61
#include <drizzled/functions/time/sysdate_local.h>
57
62
#include <drizzled/functions/time/timestamp_diff.h>
58
63
#include <drizzled/functions/time/time_to_sec.h>
59
64
#include <drizzled/functions/time/timediff.h>
60
65
#include <drizzled/functions/time/to_days.h>
66
#include <drizzled/functions/time/typecast.h>
61
67
#include <drizzled/functions/time/unix_timestamp.h>
62
68
#include <drizzled/functions/time/week.h>
63
69
#include <drizzled/functions/time/week_mode.h>
64
70
#include <drizzled/functions/time/year.h>
65
71
#include <drizzled/functions/time/yearweek.h>
67
bool get_interval_value(Item *args,interval_type int_type,
68
String *str_value, INTERVAL *interval);
70
class Item_date_add_interval :public Item_date_func
73
enum_field_types cached_field_type;
76
const interval_type int_type; // keep it public
77
const bool date_sub_interval; // keep it public
78
Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg)
79
:Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
80
String *val_str(String *);
81
const char *func_name() const { return "date_add_interval"; }
82
void fix_length_and_dec();
83
enum_field_types field_type() const { return cached_field_type; }
85
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
86
bool eq(const Item *item, bool binary_cmp) const;
87
virtual void print(String *str, enum_query_type query_type);
91
class Item_extract :public Item_int_func
96
const interval_type int_type; // keep it public
97
Item_extract(interval_type type_arg, Item *a)
98
:Item_int_func(a), int_type(type_arg) {}
100
enum Functype functype() const { return EXTRACT_FUNC; }
101
const char *func_name() const { return "extract"; }
102
void fix_length_and_dec();
103
bool eq(const Item *item, bool binary_cmp) const;
104
virtual void print(String *str, enum_query_type query_type);
108
class Item_typecast :public Item_str_func
111
Item_typecast(Item *a) :Item_str_func(a) {}
112
String *val_str(String *a)
115
String *tmp=args[0]->val_str(a);
116
null_value=args[0]->null_value;
118
tmp->set_charset(collation.collation);
121
void fix_length_and_dec()
123
collation.set(&my_charset_bin);
124
max_length=args[0]->max_length;
126
virtual const char* cast_type() const= 0;
127
virtual void print(String *str, enum_query_type query_type);
131
class Item_typecast_maybe_null :public Item_typecast
134
Item_typecast_maybe_null(Item *a) :Item_typecast(a) {}
135
void fix_length_and_dec()
137
collation.set(&my_charset_bin);
138
max_length=args[0]->max_length;
144
class Item_char_typecast :public Item_typecast
147
const CHARSET_INFO *cast_cs, *from_cs;
148
bool charset_conversion;
151
Item_char_typecast(Item *a, int length_arg, const CHARSET_INFO * const cs_arg)
152
:Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {}
153
enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
154
bool eq(const Item *item, bool binary_cmp) const;
155
const char *func_name() const { return "cast_as_char"; }
156
const char* cast_type() const { return "char"; };
157
String *val_str(String *a);
158
void fix_length_and_dec();
159
virtual void print(String *str, enum_query_type query_type);
163
class Item_date_typecast :public Item_typecast_maybe_null
166
Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
167
const char *func_name() const { return "cast_as_date"; }
168
String *val_str(String *str);
169
bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
170
bool get_time(DRIZZLE_TIME *ltime);
171
const char *cast_type() const { return "date"; }
172
enum_field_types field_type() const { return DRIZZLE_TYPE_DATE; }
173
Field *tmp_table_field(Table *table)
175
return tmp_table_field_from_field_type(table, 0);
177
void fix_length_and_dec()
179
collation.set(&my_charset_bin);
183
bool result_as_int64_t() { return true; }
185
double val_real() { return (double) val_int(); }
186
my_decimal *val_decimal(my_decimal *decimal_value)
189
return val_decimal_from_date(decimal_value);
191
int save_in_field(Field *field,
192
bool no_conversions __attribute__((unused)))
194
return save_date_in_field(field);
199
class Item_time_typecast :public Item_typecast_maybe_null
202
Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
203
const char *func_name() const { return "cast_as_time"; }
204
String *val_str(String *str);
205
bool get_time(DRIZZLE_TIME *ltime);
206
const char *cast_type() const { return "time"; }
207
enum_field_types field_type() const { return DRIZZLE_TYPE_TIME; }
208
Field *tmp_table_field(Table *table)
210
return tmp_table_field_from_field_type(table, 0);
212
bool result_as_int64_t() { return true; }
214
double val_real() { return val_real_from_decimal(); }
215
my_decimal *val_decimal(my_decimal *decimal_value)
218
return val_decimal_from_time(decimal_value);
220
int save_in_field(Field *field,
221
bool no_conversions __attribute__((unused)))
223
return save_time_in_field(field);
228
class Item_datetime_typecast :public Item_typecast_maybe_null
231
Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {}
232
const char *func_name() const { return "cast_as_datetime"; }
233
String *val_str(String *str);
234
const char *cast_type() const { return "datetime"; }
235
enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
236
Field *tmp_table_field(Table *table)
238
return tmp_table_field_from_field_type(table, 0);
240
void fix_length_and_dec()
242
collation.set(&my_charset_bin);
244
max_length= MAX_DATETIME_FULL_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
245
decimals= DATETIME_DEC;
247
bool result_as_int64_t() { return true; }
249
double val_real() { return val_real_from_decimal(); }
250
double val() { return (double) val_int(); }
251
my_decimal *val_decimal(my_decimal *decimal_value)
254
return val_decimal_from_date(decimal_value);
256
int save_in_field(Field *field,
257
bool no_conversions __attribute__((unused)))
259
return save_date_in_field(field);
264
class Item_func_str_to_date :public Item_str_func
266
enum_field_types cached_field_type;
267
date_time_format_types cached_format_type;
268
enum enum_drizzle_timestamp_type cached_timestamp_type;
271
Item_func_str_to_date(Item *a, Item *b)
272
:Item_str_func(a, b), const_item(false)
274
String *val_str(String *str);
275
bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
276
const char *func_name() const { return "str_to_date"; }
277
enum_field_types field_type() const { return cached_field_type; }
278
void fix_length_and_dec();
279
Field *tmp_table_field(Table *table)
281
return tmp_table_field_from_field_type(table, 1);
286
class Item_func_last_day :public Item_date
289
Item_func_last_day(Item *a) :Item_date(a) {}
290
const char *func_name() const { return "last_day"; }
291
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
294
73
#endif /* DRIZZLED_ITEM_TIMEFUNC_H */