summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.h
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@deer.(none)>2006-11-08 19:09:39 +0400
committerunknown <holyfoot/hf@deer.(none)>2006-11-08 19:09:39 +0400
commit90d14d50a99508a4ac459f510eb717d596976da2 (patch)
tree533737794921f247b2bb1a19b363f96a1c6b22c6 /sql/item_timefunc.h
parent7b126a91c00d7c2bca321da0de13f47220da1972 (diff)
parent3e0139d95750aa79d96f185c81aebd375fdc571e (diff)
downloadmariadb-git-90d14d50a99508a4ac459f510eb717d596976da2.tar.gz
Merge mysql.com:/home/hf/work/mysql-5.0.clean
into mysql.com:/home/hf/work/mysql-5.1.clean include/my_time.h: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/gis-rtree.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/type_datetime.result: Auto merged mysql-test/r/udf.result: Auto merged mysql-test/t/func_group.test: Auto merged mysql-test/t/gis-rtree.test: Auto merged mysql-test/t/type_datetime.test: Auto merged mysql-test/t/udf.test: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/filesort.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_subselect.h: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.cc: Auto merged sql/my_decimal.cc: Auto merged sql/my_decimal.h: Auto merged sql/mysql_priv.h: Auto merged sql/records.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged sql-common/my_time.c: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged mysql-test/r/type_newdecimal.result: SCCS merged mysql-test/t/type_newdecimal.test: merging sql/item.cc: merging sql/item_subselect.cc: SCCS merged sql/item_timefunc.h: merging sql/sql_lex.cc: SCCS merged sql/sql_select.h: merging
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r--sql/item_timefunc.h150
1 files changed, 104 insertions, 46 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 2a6ddd1bc65..360307a677f 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -360,12 +360,20 @@ public:
decimals=0;
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
}
- int save_in_field(Field *to, bool no_conversions);
Field *tmp_table_field(TABLE *table)
{
return tmp_table_field_from_field_type(table, 0);
}
bool result_as_longlong() { return TRUE; }
+ my_decimal *val_decimal(my_decimal *decimal_value)
+ {
+ DBUG_ASSERT(fixed == 1);
+ return val_decimal_from_date(decimal_value);
+ }
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ return save_date_in_field(field);
+ }
};
@@ -382,29 +390,61 @@ public:
return tmp_table_field_from_field_type(table, 0);
}
bool result_as_longlong() { return TRUE; }
+ my_decimal *val_decimal(my_decimal *decimal_value)
+ {
+ DBUG_ASSERT(fixed == 1);
+ return val_decimal_from_date(decimal_value);
+ }
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ return save_date_in_field(field);
+ }
+};
+
+
+class Item_str_timefunc :public Item_str_func
+{
+public:
+ Item_str_timefunc() :Item_str_func() {}
+ Item_str_timefunc(Item *a) :Item_str_func(a) {}
+ Item_str_timefunc(Item *a,Item *b) :Item_str_func(a,b) {}
+ Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_func(a, b ,c) {}
+ enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
+ void fix_length_and_dec()
+ {
+ decimals=0;
+ max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+ }
+ Field *tmp_table_field(TABLE *table)
+ {
+ return tmp_table_field_from_field_type(table, 0);
+ }
+ my_decimal *val_decimal(my_decimal *decimal_value)
+ {
+ DBUG_ASSERT(fixed == 1);
+ return val_decimal_from_time(decimal_value);
+ }
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ return save_time_in_field(field);
+ }
};
/* Abstract CURTIME function. Children should define what time zone is used */
-class Item_func_curtime :public Item_func
+class Item_func_curtime :public Item_str_timefunc
{
longlong value;
char buff[9*2+32];
uint buff_length;
public:
- Item_func_curtime() :Item_func() {}
- Item_func_curtime(Item *a) :Item_func(a) {}
- enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
+ Item_func_curtime() :Item_str_timefunc() {}
+ Item_func_curtime(Item *a) :Item_str_timefunc(a) {}
double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; }
longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
String *val_str(String *str);
void fix_length_and_dec();
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
/*
Abstract method that defines which time zone is used for conversion.
Converts time current time in my_time_t representation to broken-down
@@ -626,10 +666,10 @@ class Item_func_convert_tz :public Item_date_func
};
-class Item_func_sec_to_time :public Item_str_func
+class Item_func_sec_to_time :public Item_str_timefunc
{
public:
- Item_func_sec_to_time(Item *item) :Item_str_func(item) {}
+ Item_func_sec_to_time(Item *item) :Item_str_timefunc(item) {}
double val_real()
{
DBUG_ASSERT(fixed == 1);
@@ -639,17 +679,12 @@ public:
String *val_str(String *);
void fix_length_and_dec()
{
+ Item_str_timefunc::fix_length_and_dec();
collation.set(&my_charset_bin);
maybe_null=1;
decimals= DATETIME_DEC;
- max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
}
- enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
const char *func_name() const { return "sec_to_time"; }
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
bool result_as_longlong() { return TRUE; }
bool check_partition_func_processor(byte *int_arg) {return FALSE;}
};
@@ -774,6 +809,15 @@ public:
}
bool result_as_longlong() { return TRUE; }
longlong val_int();
+ my_decimal *val_decimal(my_decimal *decimal_value)
+ {
+ DBUG_ASSERT(fixed == 1);
+ return val_decimal_from_date(decimal_value);
+ }
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ return save_date_in_field(field);
+ }
};
@@ -792,6 +836,15 @@ public:
}
bool result_as_longlong() { return TRUE; }
longlong val_int();
+ my_decimal *val_decimal(my_decimal *decimal_value)
+ {
+ DBUG_ASSERT(fixed == 1);
+ return val_decimal_from_time(decimal_value);
+ }
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ return save_time_in_field(field);
+ }
};
@@ -809,12 +862,21 @@ public:
}
bool result_as_longlong() { return TRUE; }
longlong val_int();
+ my_decimal *val_decimal(my_decimal *decimal_value)
+ {
+ DBUG_ASSERT(fixed == 1);
+ return val_decimal_from_date(decimal_value);
+ }
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ return save_date_in_field(field);
+ }
};
-class Item_func_makedate :public Item_str_func
+class Item_func_makedate :public Item_date_func
{
public:
- Item_func_makedate(Item *a,Item *b) :Item_str_func(a,b) {}
+ Item_func_makedate(Item *a,Item *b) :Item_date_func(a,b) {}
String *val_str(String *str);
const char *func_name() const { return "makedate"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
@@ -823,11 +885,6 @@ public:
decimals=0;
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
}
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
- bool result_as_longlong() { return TRUE; }
longlong val_int();
bool check_partition_func_processor(byte *int_arg) {return FALSE;}
};
@@ -853,45 +910,46 @@ public:
void print(String *str);
const char *func_name() const { return "add_time"; }
bool check_partition_func_processor(byte *int_arg) {return FALSE;}
+ my_decimal *val_decimal(my_decimal *decimal_value)
+ {
+ DBUG_ASSERT(fixed == 1);
+ if (cached_field_type == MYSQL_TYPE_TIME)
+ return val_decimal_from_time(decimal_value);
+ if (cached_field_type == MYSQL_TYPE_DATETIME)
+ return val_decimal_from_date(decimal_value);
+ return Item_str_func::val_decimal(decimal_value);
+ }
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ if (cached_field_type == MYSQL_TYPE_TIME)
+ return save_time_in_field(field);
+ if (cached_field_type == MYSQL_TYPE_DATETIME)
+ return save_date_in_field(field);
+ return Item_str_func::save_in_field(field, no_conversions);
+ }
};
-class Item_func_timediff :public Item_str_func
+class Item_func_timediff :public Item_str_timefunc
{
public:
Item_func_timediff(Item *a, Item *b)
- :Item_str_func(a, b) {}
+ :Item_str_timefunc(a, b) {}
String *val_str(String *str);
const char *func_name() const { return "timediff"; }
- enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
void fix_length_and_dec()
{
- decimals=0;
- max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+ Item_str_timefunc::fix_length_and_dec();
maybe_null= 1;
}
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
};
-class Item_func_maketime :public Item_str_func
+class Item_func_maketime :public Item_str_timefunc
{
public:
Item_func_maketime(Item *a, Item *b, Item *c)
- :Item_str_func(a, b ,c) {}
+ :Item_str_timefunc(a, b ,c) {}
String *val_str(String *str);
const char *func_name() const { return "maketime"; }
- enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
- void fix_length_and_dec()
- {
- decimals=0;
- max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- }
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
bool check_partition_func_processor(byte *int_arg) {return FALSE;}
};