00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #pragma once
00022
00023 #include <drizzled/function/str/strfunc.h>
00024 #include <drizzled/function/time/typecast.h>
00025 #include <drizzled/temporal.h>
00026
00027 namespace drizzled {
00028 namespace function {
00029 namespace cast {
00030
00031 class Time :public Item_typecast_maybe_null
00032 {
00033 public:
00034 using Item_func::tmp_table_field;
00035
00036 Time(Item *a) :
00037 Item_typecast_maybe_null(a)
00038 {}
00039
00040 const char *func_name() const { return "cast_as_time"; }
00041 String *val_str(String *str);
00042 bool get_time(type::Time <ime);
00043 const char *cast_type() const { return "time"; }
00044 enum_field_types field_type() const { return DRIZZLE_TYPE_TIME; }
00045
00046 Field *tmp_table_field(Table *table)
00047 {
00048 return tmp_table_field_from_field_type(table, 0);
00049 }
00050
00051 void fix_length_and_dec()
00052 {
00053 collation.set(&my_charset_bin);
00054 max_length= 10;
00055 maybe_null= 1;
00056 }
00057
00058 bool result_as_int64_t() { return true; }
00059 int64_t val_int();
00060 double val_real() { return (double) val_int(); }
00061
00062 type::Decimal *val_decimal(type::Decimal *decimal_value)
00063 {
00064 assert(fixed == 1);
00065 return val_decimal_from_date(decimal_value);
00066 }
00067
00068 int save_in_field(Field *field, bool )
00069 {
00070 return save_date_in_field(field);
00071 }
00072 };
00073
00074 }
00075 }
00076 }
00077