diff options
author | Michael Widenius <monty@askmonty.org> | 2011-05-12 14:30:34 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-05-12 14:30:34 +0300 |
commit | f09f1c7c7da344d0078b2c13edc9249c4c61c6b9 (patch) | |
tree | 1b707c9edf2d159102019147a5dbca390e1aac83 /sql/item.cc | |
parent | f34be1893892745b5b1a7a099eab4ad8e9ac8641 (diff) | |
parent | 4c81cef75d7871e2c77d6723813ac328c34603b5 (diff) | |
download | mariadb-git-f09f1c7c7da344d0078b2c13edc9249c4c61c6b9.tar.gz |
Merge with dynamic column code
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/sql/item.cc b/sql/item.cc index c1620174533..9e9f71abeba 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -985,23 +985,13 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate) { - if (result_type() == STRING_RESULT) - { - char buff[40]; - String tmp(buff,sizeof(buff), &my_charset_bin),*res; - if (!(res=val_str(&tmp)) || - str_to_datetime_with_warn(res->ptr(), res->length(), - ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR) - goto err; - } - else + switch (result_type()) { + case INT_RESULT: { int was_cut; longlong value= val_int(); - if (null_value) goto err; - if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == LL(-1)) { char buff[22], *end; @@ -1009,8 +999,52 @@ bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate) make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, buff, (int) (end-buff), MYSQL_TIMESTAMP_NONE, NullS); + null_value= 1; goto err; } + break; + } + case REAL_RESULT: + { + double value= val_real(); + if (null_value) + goto err; + if (double_to_datetime_with_warn(value, ltime, fuzzydate)) + { + null_value= 1; + goto err; + } + break; + } + case DECIMAL_RESULT: + { + my_decimal value, *res; + if (!(res= val_decimal(&value))) + goto err; // Null + if (decimal_to_datetime_with_warn(res, ltime, fuzzydate)) + { + null_value= 1; + goto err; + } + break; + } + default: + { + /* + Default go trough string as this is the safest way to ensure that + we also get the microseconds. + */ + char buff[40]; + String tmp(buff,sizeof(buff), &my_charset_bin),*res; + if (!(res=val_str(&tmp)) || + str_to_datetime_with_warn(res->ptr(), res->length(), + ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR) + { + null_value= 1; + goto err; + } + break; + } } return 0; @@ -1030,7 +1064,11 @@ bool Item::get_time(MYSQL_TIME *ltime) char buff[40]; String tmp(buff,sizeof(buff),&my_charset_bin),*res; if (!(res=val_str(&tmp)) || - str_to_time_with_warn(res->ptr(), res->length(), ltime)) + str_to_time_with_warn(res->ptr(), res->length(), ltime, + TIME_FUZZY_DATE | + (current_thd->variables.sql_mode & + (MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE | + MODE_INVALID_DATES)))) { bzero((char*) ltime,sizeof(*ltime)); return 1; @@ -5753,7 +5791,10 @@ bool Item::send(Protocol *protocol, String *buffer) { String *res; if ((res=val_str(buffer))) + { + DBUG_ASSERT(!null_value); result= protocol->store(res->ptr(),res->length(),res->charset()); + } else { DBUG_ASSERT(null_value); |