summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.h
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-08-19 00:10:21 +0300
committerunknown <monty@mashka.mysql.fi>2003-08-19 00:10:21 +0300
commit755e72a0f55b593cf930ae9bd69998f82b70d5cf (patch)
treebf340fae8765f9d5f1e1ac543d2926bef0021e03 /sql/item_timefunc.h
parent2901c3b8fa7d4095445c6ca2070367d2f61af2d1 (diff)
parenta7c82c5693110bfa744bd4cf481b02eaabb7a0aa (diff)
downloadmariadb-git-755e72a0f55b593cf930ae9bd69998f82b70d5cf.tar.gz
merge
configure.in: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/subselect.test: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_union.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r--sql/item_timefunc.h80
1 files changed, 75 insertions, 5 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 4b0ef02f20d..29cfad2e095 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -350,6 +350,8 @@ public:
};
+/* Abstract CURTIME function. Children should define what timezone is used */
+
class Item_func_curtime :public Item_func
{
longlong value;
@@ -363,29 +365,77 @@ public:
double val() { return (double) value; }
longlong val_int() { return value; }
String *val_str(String *str);
- const char *func_name() const { return "curtime"; }
void fix_length_and_dec();
Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg)
{
return (new Field_time(maybe_null, name, t_arg, default_charset()));
- }
+ }
+ /*
+ Abstract method that defines which time zone is used for conversion.
+ Converts time from time_t representation to broken down representation
+ in struct tm using gmtime_r or localtime_r functions.
+ */
+ virtual void store_now_in_tm(time_t now, struct tm *now_tm)=0;
};
+class Item_func_curtime_local :public Item_func_curtime
+{
+public:
+ Item_func_curtime_local() :Item_func_curtime() {}
+ Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
+ const char *func_name() const { return "curtime"; }
+ void store_now_in_tm(time_t now, struct tm *now_tm);
+};
+
+
+class Item_func_curtime_utc :public Item_func_curtime
+{
+public:
+ Item_func_curtime_utc() :Item_func_curtime() {}
+ Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
+ const char *func_name() const { return "utc_time"; }
+ void store_now_in_tm(time_t now, struct tm *now_tm);
+};
+
+
+/* Abstract CURDATE function. See also Item_func_curtime. */
+
class Item_func_curdate :public Item_date
{
longlong value;
TIME ltime;
public:
Item_func_curdate() :Item_date() {}
+ void set_result_from_tm(struct tm *now);
longlong val_int() { return (value) ; }
- const char *func_name() const { return "curdate"; }
- void fix_length_and_dec(); /* Retrieves curtime */
+ void fix_length_and_dec();
bool get_date(TIME *res,bool fuzzy_date);
+ virtual void store_now_in_tm(time_t now, struct tm *now_tm)=0;
+};
+
+
+class Item_func_curdate_local :public Item_func_curdate
+{
+public:
+ Item_func_curdate_local() :Item_func_curdate() {}
+ const char *func_name() const { return "curdate"; }
+ void store_now_in_tm(time_t now, struct tm *now_tm);
};
+class Item_func_curdate_utc :public Item_func_curdate
+{
+public:
+ Item_func_curdate_utc() :Item_func_curdate() {}
+ const char *func_name() const { return "utc_date"; }
+ void store_now_in_tm(time_t now, struct tm *now_tm);
+};
+
+
+/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */
+
class Item_func_now :public Item_date_func
{
longlong value;
@@ -400,9 +450,29 @@ public:
longlong val_int() { return value; }
int save_in_field(Field *to, bool no_conversions);
String *val_str(String *str);
- const char *func_name() const { return "now"; }
void fix_length_and_dec();
bool get_date(TIME *res,bool fuzzy_date);
+ virtual void store_now_in_tm(time_t now, struct tm *now_tm)=0;
+};
+
+
+class Item_func_now_local :public Item_func_now
+{
+public:
+ Item_func_now_local() :Item_func_now() {}
+ 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);
+};
+
+
+class Item_func_now_utc :public Item_func_now
+{
+public:
+ Item_func_now_utc() :Item_func_now() {}
+ Item_func_now_utc(Item *a) :Item_func_now(a) {}
+ const char *func_name() const { return "utc_timestamp"; }
+ void store_now_in_tm(time_t now, struct tm *now_tm);
};