diff options
author | Alexander Barkov <bar@mariadb.org> | 2013-07-10 18:46:33 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2013-07-10 18:46:33 +0400 |
commit | a057b504904c3e6ab1e3006c081b4fb23faaf1d4 (patch) | |
tree | 338485c4cb052eba8d60f8c9d1a6077ef4c377b0 /sql/item.cc | |
parent | 5b0774ee1c5a32ef694ce18413fa003bc6646c48 (diff) | |
parent | d98584f56a5ec46d6258bba6250c6c797a678afd (diff) | |
download | mariadb-git-a057b504904c3e6ab1e3006c081b4fb23faaf1d4.tar.gz |
Merging temporal literals
added:
mysql-test/r/temporal_literal.result
mysql-test/t/temporal_literal.test
modified:
client/mysqlbinlog.cc
include/my_time.h
mysql-test/r/cast.result
mysql-test/r/partition_innodb.result
mysql-test/t/cast.test
mysql-test/t/partition_innodb.test
sql-common/my_time.c
sql/field.cc
sql/item.cc
sql/item.h
sql/item_cmpfunc.cc
sql/item_create.cc
sql/item_create.h
sql/item_strfunc.cc
sql/item_timefunc.cc
sql/item_timefunc.h
sql/sql_select.cc
sql/sql_time.cc
sql/sql_time.h
sql/sql_yacc.yy
storage/spider/spd_db_mysql.cc
pending merges:
Alexander Barkov 2013-07-10 Adding support for the SQL-standard temporal...
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 93 |
1 files changed, 92 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc index f9def19bf6a..21eacb38401 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -377,6 +377,27 @@ my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value) } +longlong Item::val_int_from_date() +{ + DBUG_ASSERT(fixed == 1); + MYSQL_TIME ltime; + if (get_date(<ime, TIME_FUZZY_DATE)) + return 0; + longlong v= TIME_to_ulonglong(<ime); + return ltime.neg ? -v : v; +} + + +double Item::val_real_from_date() +{ + DBUG_ASSERT(fixed == 1); + MYSQL_TIME ltime; + if (get_date(<ime, TIME_FUZZY_DATE)) + return 0; + return TIME_to_double(<ime); +} + + double Item::val_real_from_decimal() { /* Note that fix_fields may not be called for Item_avg_field items */ @@ -1272,7 +1293,7 @@ bool Item::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) String tmp(buff,sizeof(buff), &my_charset_bin),*res; if (!(res=val_str(&tmp)) || str_to_datetime_with_warn(res->charset(), res->ptr(), res->length(), - ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR) + ltime, fuzzydate)) goto err; break; } @@ -6283,6 +6304,76 @@ Item_bin_string::Item_bin_string(const char *str, uint str_length) } +bool Item_temporal_literal::eq(const Item *item, bool binary_cmp) const +{ + return + item->basic_const_item() && type() == item->type() && + field_type() == ((Item_temporal_literal *) item)->field_type() && + !my_time_compare(&cached_time, + &((Item_temporal_literal *) item)->cached_time); +} + + +void Item_date_literal::print(String *str, enum_query_type query_type) +{ + str->append("DATE'"); + char buf[MAX_DATE_STRING_REP_LENGTH]; + my_date_to_str(&cached_time, buf); + str->append(buf); + str->append('\''); +} + + +bool Item_date_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) +{ + DBUG_ASSERT(fixed); + *ltime= cached_time; + return (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)); +} + + +void Item_datetime_literal::print(String *str, enum_query_type query_type) +{ + str->append("TIMESTAMP'"); + char buf[MAX_DATE_STRING_REP_LENGTH]; + my_datetime_to_str(&cached_time, buf, decimals); + str->append(buf); + str->append('\''); +} + + +bool Item_datetime_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) +{ + DBUG_ASSERT(fixed); + *ltime= cached_time; + return (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)); +} + + +void Item_time_literal::print(String *str, enum_query_type query_type) +{ + str->append("TIME'"); + char buf[MAX_DATE_STRING_REP_LENGTH]; + my_time_to_str(&cached_time, buf, decimals); + str->append(buf); + str->append('\''); +} + + +bool Item_time_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) +{ + DBUG_ASSERT(fixed); + *ltime= cached_time; + if (fuzzy_date & TIME_TIME_ONLY) + return (null_value= false); + return (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)); +} + + + /** Pack data in buffer for sending. */ |