diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-12-08 19:39:23 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-12-10 13:39:45 +0400 |
commit | 240edac84620fc75e90731cb5e95bc52ba672984 (patch) | |
tree | 444c8d6f29cc0cec659e6e2b1546722c5dac1c85 /sql/filesort.cc | |
parent | e5144f4bad017d5bda80d21b0e7cf8caeb9f6dfb (diff) | |
download | mariadb-git-bb-10.4-mdev13995.tar.gz |
MDEV-13995 MAX(timestamp) returns a wrong result near DST changebb-10.4-mdev13995
Diffstat (limited to 'sql/filesort.cc')
-rw-r--r-- | sql/filesort.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index d0cb77ac63d..c76295e666a 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1068,6 +1068,28 @@ Type_handler_temporal_result::make_sort_key(uchar *to, Item *item, void +Type_handler_timestamp_common::make_sort_key(uchar *to, Item *item, + const SORT_FIELD_ATTR *sort_field, + Sort_param *param) const +{ + uint binlen= my_timestamp_binary_length(item->decimals); + Timestamp_or_zero_datetime_native_null native(current_thd, item); + if (native.is_null() || native.is_zero_datetime()) + { + // NULL or '0000-00-00 00:00:00' + bzero(to, item->maybe_null ? binlen + 1 : binlen); + } + else + { + DBUG_ASSERT(native.length() == binlen); + if (item->maybe_null) + *to++= 1; + memcpy((char *) to, native.ptr(), binlen); + } +} + + +void Type_handler::make_sort_key_longlong(uchar *to, bool maybe_null, bool null_value, @@ -1874,6 +1896,15 @@ Type_handler_temporal_result::sortlength(THD *thd, void +Type_handler_timestamp_common::sortlength(THD *thd, + const Type_std_attributes *item, + SORT_FIELD_ATTR *sortorder) const +{ + sortorder->length= my_timestamp_binary_length(item->decimals); +} + + +void Type_handler_int_result::sortlength(THD *thd, const Type_std_attributes *item, SORT_FIELD_ATTR *sortorder) const |