diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-12-19 14:03:54 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-12-19 14:03:54 +0400 |
commit | 1f1e3ce8a18ab548f9641ea10295372abbd147ad (patch) | |
tree | 4988f087b0688195015141f24aa4f6a0d571504f /sql/item.cc | |
parent | a5a433e256d29f00b6b51babcf0aac49e95c7e82 (diff) | |
download | mariadb-git-1f1e3ce8a18ab548f9641ea10295372abbd147ad.tar.gz |
MDEV-21319 COUNT(*) returns 1, actual SELECT returns no result in 10.3.21, but 1 result in 10.1.41
Item_ref::val_(datetime|time)_packed() erroneously called
(*ref)->val_(datetime|time)_packed().
- Fixing to call (*ref)->val_(datetime|time)_packed_result().
- Backporting Item::val_(datetime|time)_packed_result() from 10.3.
- Fixing Item_field::get_date_result() to handle null_value in the same
way how Item_field::get_date() does.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/sql/item.cc b/sql/item.cc index 86bd4670714..17eb570ad80 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -145,6 +145,19 @@ bool Item::get_date_with_conversion(MYSQL_TIME *ltime, ulonglong fuzzydate) } +longlong Item::val_datetime_packed_result() +{ + MYSQL_TIME ltime, tmp; + if (get_date_result(<ime, TIME_FUZZY_DATES | TIME_INVALID_DATES)) + return 0; + if (ltime.time_type != MYSQL_TIMESTAMP_TIME) + return pack_time(<ime); + if ((null_value= time_to_datetime_with_warn(current_thd, <ime, &tmp, 0))) + return 0; + return pack_time(&tmp); +} + + /** Get date/time/datetime. If DATETIME or DATE result is returned, it's converted to TIME. @@ -2594,12 +2607,13 @@ bool Item_field::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) bool Item_field::get_date_result(MYSQL_TIME *ltime, ulonglong fuzzydate) { - if (result_field->is_null() || result_field->get_date(ltime,fuzzydate)) + if ((null_value= result_field->is_null()) || + result_field->get_date(ltime, fuzzydate)) { bzero((char*) ltime,sizeof(*ltime)); - return (null_value= 1); + return true; } - return (null_value= 0); + return false; } @@ -7313,7 +7327,7 @@ bool Item_ref::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) longlong Item_ref::val_datetime_packed() { DBUG_ASSERT(fixed); - longlong tmp= (*ref)->val_datetime_packed(); + longlong tmp= (*ref)->val_datetime_packed_result(); null_value= (*ref)->null_value; return tmp; } @@ -7322,7 +7336,7 @@ longlong Item_ref::val_datetime_packed() longlong Item_ref::val_time_packed() { DBUG_ASSERT(fixed); - longlong tmp= (*ref)->val_time_packed(); + longlong tmp= (*ref)->val_time_packed_result(); null_value= (*ref)->null_value; return tmp; } |