summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.h
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-08-24 15:50:58 -0700
committerunknown <jimw@mysql.com>2005-08-24 15:50:58 -0700
commitda13a76a289a7f75089c738cb08745e7dd82f619 (patch)
treed1cebeb5bc16f53aaf69f81ac3286a2365c098fc /sql/item_timefunc.h
parenta7ce02bcf7540b044019e98b7c0a349f48ff6269 (diff)
downloadmariadb-git-da13a76a289a7f75089c738cb08745e7dd82f619.tar.gz
Make SYSDATE() behave as in Oracle: always the current datetime, not the
datetime of when the current statement began. This also makes SYSDATE() not safe in replication. (Bug #12562) mysql-test/r/func_time.result: Add new results mysql-test/t/func_time.test: Add tests for new SYSDATE() behavior sql/item_timefunc.cc: Add Item_func_sysdate_local implementation sql/item_timefunc.h: Add Item_func_sysdate_local, so SYSDATE() can behave differently than NOW(). sql/lex.h: SYSDATE() is no longer an alias for NOW(). sql/sql_yacc.yy: Handle SYSDATE()
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r--sql/item_timefunc.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index d9300451fe7..4602088a5f5 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -446,6 +446,7 @@ public:
class Item_func_now :public Item_date_func
{
+protected:
longlong value;
char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy
uint buff_length;
@@ -485,6 +486,32 @@ public:
};
+/*
+ This is like NOW(), but always uses the real current time, not the
+ query_start(). This matches the Oracle behavior.
+*/
+class Item_func_sysdate_local :public Item_func_now
+{
+public:
+ Item_func_sysdate_local() :Item_func_now() {}
+ Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
+ bool const_item() const { return 0; }
+ const char *func_name() const { return "sysdate"; }
+ void store_now_in_TIME(TIME *now_time);
+ double val_real();
+ longlong val_int();
+ int save_in_field(Field *to, bool no_conversions);
+ String *val_str(String *str);
+ void fix_length_and_dec();
+ bool get_date(TIME *res, uint fuzzy_date);
+ void update_used_tables()
+ {
+ Item_func_now::update_used_tables();
+ used_tables_cache|= RAND_TABLE_BIT;
+ }
+};
+
+
class Item_func_from_days :public Item_date
{
public: