summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.h
diff options
context:
space:
mode:
authorunknown <pem@mysql.com>2004-04-07 19:07:44 +0200
committerunknown <pem@mysql.com>2004-04-07 19:07:44 +0200
commitc635d37479fbf8aa0da03d47f264ab9907cfe72b (patch)
treee5ac1517ff3dccc42352b7bac39ecd1c093d0ae6 /sql/item_timefunc.h
parent8468cde4f1e028b380c24d0bac28402678568d81 (diff)
parent0948f9769b3e3da2e064e65015b86644af4acd78 (diff)
downloadmariadb-git-c635d37479fbf8aa0da03d47f264ab9907cfe72b.tar.gz
Merge 4.1 -> 5.0.
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged client/Makefile.am: Auto merged client/mysql.cc: Auto merged client/mysqltest.c: Auto merged configure.in: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/mysql_com.h: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged myisam/myisamdef.h: Auto merged mysql-test/install_test_db.sh: Auto merged mysql-test/r/insert_select.result: Auto merged mysql-test/r/join_outer.result: Auto merged mysql-test/r/null.result: Auto merged mysql-test/r/connect.result: Auto merged mysql-test/r/func_sapdb.result: Auto merged mysql-test/r/mix_innodb_myisam_binlog.result: Auto merged mysql-test/r/mysqldump.result: Auto merged mysql-test/r/rpl_change_master.result: Auto merged mysql-test/r/rpl_log.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/symlink.result: Auto merged mysql-test/r/rpl_flush_log_loop.result: Auto merged mysql-test/r/rpl_flush_tables.result: Auto merged mysql-test/r/rpl_loaddata.result: Auto merged mysql-test/r/rpl_loaddata_rule_m.result: Auto merged mysql-test/r/rpl_loaddata_rule_s.result: Auto merged mysql-test/r/rpl_max_relay_size.result: Auto merged mysql-test/r/rpl_reset_slave.result: Auto merged mysql-test/r/rpl_temporary.result: Auto merged mysql-test/r/rpl_until.result: Auto merged mysql-test/r/rpl_user_variables.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/func_sapdb.test: Auto merged mysql-test/t/mix_innodb_myisam_binlog.test: Auto merged mysql-test/t/mysqlbinlog.test: Auto merged mysql-test/t/rpl_change_master.test: Auto merged mysql-test/t/rpl_log.test: Auto merged mysql-test/t/variables.test: Auto merged netware/BUILD/compile-linux-tools: Auto merged netware/BUILD/compile-netware-END: Auto merged netware/BUILD/compile-netware-all: Auto merged netware/BUILD/compile-netware-standard: Auto merged mysql-test/t/rpl_empty_master_crash.test: Auto merged mysql-test/t/rpl_error_ignored_table.test: Auto merged mysql-test/t/rpl_flush_log_loop.test: Auto merged mysql-test/t/rpl_loaddata.test: Auto merged mysql-test/t/rpl_loaddata_rule_m.test: Auto merged mysql-test/t/rpl_loaddata_rule_s.test: Auto merged mysql-test/t/rpl_max_relay_size.test: Auto merged mysql-test/t/rpl_openssl.test: Auto merged mysql-test/t/rpl_relayrotate-slave.opt: Auto merged mysql-test/t/rpl_reset_slave.test: Auto merged mysql-test/t/rpl_trunc_binlog.test: Auto merged mysql-test/t/rpl_until.test: Auto merged mysql-test/t/rpl_user_variables.test: Auto merged mysql-test/t/subselect.test: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged scripts/mysql_install_db.sh: Auto merged sql/filesort.cc: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_berkeley.h: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_create.cc: Auto merged sql/item_create.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.h: Auto merged sql/lock.cc: Auto merged sql/log_event.h: Auto merged sql/mysqld.cc: Auto merged sql/net_serv.cc: Auto merged sql/protocol.cc: Auto merged sql/protocol.h: Auto merged sql/repl_failsafe.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_derived.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_list.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_repl.h: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_test.cc: Auto merged sql/sql_update.cc: Auto merged sql-common/client.c: Auto merged tests/client_test.c: Auto merged
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r--sql/item_timefunc.h104
1 files changed, 64 insertions, 40 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 9f1d7dbd85a..263969cd26b 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -21,6 +21,11 @@
#pragma interface /* gcc class implementation */
#endif
+enum date_time_format_types
+{
+ TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND
+};
+
class Item_func_period_add :public Item_int_func
{
public:
@@ -83,7 +88,8 @@ class Item_func_month :public Item_func
public:
Item_func_month(Item *a) :Item_func(a) {}
longlong val_int();
- double val() { return (double) Item_func_month::val_int(); }
+ double val()
+ { DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
String *val_str(String *str)
{
str->set(val_int(), &my_charset_bin);
@@ -244,9 +250,10 @@ public:
Item_func_weekday(Item *a,bool type_arg)
:Item_func(a), odbc_type(type_arg) {}
longlong val_int();
- double val() { return (double) val_int(); }
+ double val() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
String *val_str(String *str)
- {
+ {
+ DBUG_ASSERT(fixed == 1);
str->set(val_int(), &my_charset_bin);
return null_value ? 0 : str;
}
@@ -318,7 +325,8 @@ public:
enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
String *val_str(String *str);
- double val() { return (double) val_int(); }
+ longlong val_int();
+ double val() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
const char *func_name() const { return "date"; }
void fix_length_and_dec()
{
@@ -360,8 +368,8 @@ public:
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; }
- double val() { return (double) value; }
- longlong val_int() { return value; }
+ double val() { 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 *t_arg)
@@ -406,7 +414,8 @@ class Item_func_curdate :public Item_date
public:
Item_func_curdate() :Item_date() {}
void set_result_from_tm(struct tm *now);
- longlong val_int() { return (value) ; }
+ longlong val_int() { DBUG_ASSERT(fixed == 1); return (value) ; }
+ String *val_str(String *str);
void fix_length_and_dec();
bool get_date(TIME *res, uint fuzzy_date);
virtual void store_now_in_tm(time_t now, struct tm *now_tm)=0;
@@ -443,8 +452,8 @@ public:
Item_func_now() :Item_date_func() {}
Item_func_now(Item *a) :Item_date_func(a) {}
enum Item_result result_type () const { return STRING_RESULT; }
- double val() { return (double) value; }
- longlong val_int() { return value; }
+ double val() { DBUG_ASSERT(fixed == 1); return (double) value; }
+ longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
int save_in_field(Field *to, bool no_conversions);
String *val_str(String *str);
void fix_length_and_dec();
@@ -460,6 +469,7 @@ public:
Item_func_now_local(Item *a) :Item_func_now(a) {}
const char *func_name() const { return "now"; }
void store_now_in_tm(time_t now, struct tm *now_tm);
+ virtual enum Functype functype() const { return NOW_FUNC; }
};
@@ -477,8 +487,8 @@ class Item_func_from_days :public Item_date
{
public:
Item_func_from_days(Item *a) :Item_date(a) {}
- longlong val_int();
const char *func_name() const { return "from_days"; }
+ bool get_date(TIME *res, uint fuzzy_date);
};
@@ -501,7 +511,11 @@ class Item_func_from_unixtime :public Item_date_func
{
public:
Item_func_from_unixtime(Item *a) :Item_date_func(a) {}
- double val() { return (double) Item_func_from_unixtime::val_int(); }
+ double val()
+ {
+ DBUG_ASSERT(fixed == 1);
+ return (double) Item_func_from_unixtime::val_int();
+ }
longlong val_int();
String *val_str(String *str);
const char *func_name() const { return "from_unixtime"; }
@@ -519,7 +533,11 @@ class Item_func_sec_to_time :public Item_str_func
{
public:
Item_func_sec_to_time(Item *item) :Item_str_func(item) {}
- double val() { return (double) Item_func_sec_to_time::val_int(); }
+ double val()
+ {
+ DBUG_ASSERT(fixed == 1);
+ return (double) Item_func_sec_to_time::val_int();
+ }
longlong val_int();
String *val_str(String *);
void fix_length_and_dec()
@@ -565,7 +583,7 @@ public:
const char *func_name() const { return "date_add_interval"; }
void fix_length_and_dec();
enum_field_types field_type() const { return cached_field_type; }
- double val() { return (double) val_int(); }
+ double val() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
longlong val_int();
bool get_date(TIME *res, uint fuzzy_date);
void print(String *str);
@@ -594,6 +612,7 @@ public:
Item_typecast(Item *a) :Item_str_func(a) {}
String *val_str(String *a)
{
+ DBUG_ASSERT(fixed == 1);
String *tmp=args[0]->val_str(a);
null_value=args[0]->null_value;
if (tmp)
@@ -610,6 +629,19 @@ public:
};
+class Item_typecast_maybe_null :public Item_typecast
+{
+public:
+ Item_typecast_maybe_null(Item *a) :Item_typecast(a) {}
+ void fix_length_and_dec()
+ {
+ collation.set(&my_charset_bin);
+ max_length=args[0]->max_length;
+ maybe_null= 1;
+ }
+};
+
+
class Item_char_typecast :public Item_typecast
{
int cast_length;
@@ -626,10 +658,10 @@ public:
};
-class Item_date_typecast :public Item_typecast
+class Item_date_typecast :public Item_typecast_maybe_null
{
public:
- Item_date_typecast(Item *a) :Item_typecast(a) {}
+ Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
String *val_str(String *str);
bool get_date(TIME *ltime, uint fuzzy_date);
const char *cast_type() const { return "date"; }
@@ -641,10 +673,10 @@ public:
};
-class Item_time_typecast :public Item_typecast
+class Item_time_typecast :public Item_typecast_maybe_null
{
public:
- Item_time_typecast(Item *a) :Item_typecast(a) {}
+ Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
String *val_str(String *str);
bool get_time(TIME *ltime);
const char *cast_type() const { return "time"; }
@@ -656,10 +688,10 @@ public:
};
-class Item_datetime_typecast :public Item_typecast
+class Item_datetime_typecast :public Item_typecast_maybe_null
{
public:
- Item_datetime_typecast(Item *a) :Item_typecast(a) {}
+ Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {}
String *val_str(String *str);
const char *cast_type() const { return "datetime"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
@@ -810,37 +842,29 @@ public:
};
-class Item_func_str_to_date :public Item_date_func
+class Item_func_str_to_date :public Item_str_func
{
+ enum_field_types cached_field_type;
+ date_time_format_types cached_format_type;
+ timestamp_type cached_timestamp_type;
+ bool const_item;
public:
Item_func_str_to_date(Item *a, Item *b)
- :Item_date_func(a, b)
+ :Item_str_func(a, b)
{}
String *val_str(String *str);
bool get_date(TIME *ltime, uint fuzzy_date);
const char *func_name() const { return "str_to_date"; }
- void fix_length_and_dec()
- {
- maybe_null= 1;
- decimals=0;
- max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- }
+ enum_field_types field_type() const { return cached_field_type; }
+ void fix_length_and_dec();
+ Field *tmp_table_field(TABLE *t_arg);
};
-class Item_func_last_day :public Item_str_func
+
+class Item_func_last_day :public Item_date
{
public:
- Item_func_last_day(Item *a) :Item_str_func(a) {}
- String *val_str(String *str);
+ Item_func_last_day(Item *a) :Item_date(a) {}
const char *func_name() const { return "last_day"; }
- enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
- void fix_length_and_dec()
- {
- decimals=0;
- max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- }
- Field *tmp_table_field(TABLE *t_arg)
- {
- return (new Field_date(maybe_null, name, t_arg, &my_charset_bin));
- }
+ bool get_date(TIME *res, uint fuzzy_date);
};