Hello Sergei, Thanks for the review. Please see a comment below: On 1/24/24 03:34, Sergei Golubchik wrote:
Hi, Alexander,
On Jan 24, Alexander Barkov wrote:
revision-id: 1a3974f534f (mariadb-11.3.1-12-g1a3974f534f) parent(s): 83a79ba33b0 author: Alexander Barkov committer: Alexander Barkov timestamp: 2024-01-23 18:04:31 +0400 message:
MDEV-33299 Assertion `(tm->tv_usec % (int) log_10_int[6 - dec]) == 0' failed in void my_timestamp_to_binary(const timeval*, uchar*, uint)
diff --git a/sql/opt_rewrite_date_cmp.cc b/sql/opt_rewrite_date_cmp.cc index 5a6410414da..8ff0ab3847e 100644 --- a/sql/opt_rewrite_date_cmp.cc +++ b/sql/opt_rewrite_date_cmp.cc @@ -288,10 +288,13 @@ Item *Date_cmp_func_rewriter::create_end_bound() const_arg_ts.hour= 23; const_arg_ts.minute= TIME_MAX_MINUTE; const_arg_ts.second= TIME_MAX_SECOND; - const_arg_ts.second_part= TIME_MAX_SECOND_PART; + const_arg_ts.second_part= TIME_MAX_SECOND_PART - + my_time_fraction_remainder(TIME_MAX_SECOND_PART, + field_ref->decimals); if (check_datetime_range(&const_arg_ts)) return nullptr; res= new (thd->mem_root) Item_datetime(thd); + res->decimals= field_ref->decimals;
would it work you if always set res->decimals=6 here (and below)? looks like a simpler way to make the item consistent.
It should work. However, it's better to have equal fractional precision on the both sides, to go through the optimized execution path here: int Type_handler_timestamp_common::cmp_native(const Native &a, const Native &b) const { /* Optimize a simple case: Either both timeatamp values have the same fractional precision, or both values are zero datetime '0000-00-00 00:00:00.000000', */ if (a.length() == b.length()) return memcmp(a.ptr(), b.ptr(), a.length()); return Timestamp_or_zero_datetime(a).cmp(Timestamp_or_zero_datetime(b)); } The above method is called from Item_func_le::val_int(), with this stack: #0 Type_handler_timestamp_common::cmp_native (this=0x555557b11c80 <type_handler_timestamp>, a=..., b=...) at /home/bar/maria-git/11.3.m33299.tsdt/sql/sql_type.cc:9239 #1 0x00005555563ed153 in Arg_comparator::compare_native (this=0x7fff9c018ff0) at /home/bar/maria-git/11.3.m33299.tsdt/sql/item_cmpfunc.cc:903 #2 0x000055555640692c in Arg_comparator::compare (this=0x7fff9c018ff0) at /home/bar/maria-git/11.3.m33299.tsdt/sql/item_cmpfunc.h:118 #3 0x00005555563f0c3f in Item_func_le::val_int (this=0x7fff9c018f38) at /home/bar/maria-git/11.3.m33299.tsdt/sql/item_cmpfunc.cc:1932
res->set(&const_arg_ts); break;
Regards, Sergei Chief Architect, MariaDB Server and security@mariadb.org