-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.report/communityThe community has encountered this bug.The community has encountered this bug.severity/criticalsig/executionSIG executionSIG executiontype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.type/regression
Description
Bug Report
when if result have decimal,the compare result is wrong
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
CREATE TABLE `articles_of_video_day` (
`clicks_of_today` int(4) NOT NULL,
`ts` bigint(4) NOT NULL,
KEY `ts_index` (`ts`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
insert into articles_of_video_day values(0,1725292800),(0,1725292800);
select from_unixtime( if(`ts` >9999999999, ts/1000, `ts`), '%Y-%m-%d %H:%i:%s') from articles_of_video_day;
2. What did you expect to see? (Required)
+--------------------------------------------------------------------------+
| from_unixtime( if(`ts` >9999999999, ts/1000, `ts`), '%Y-%m-%d %H:%i:%s') |
+--------------------------------------------------------------------------+
| 2024-09-03 00:00:00 |
| 2024-09-03 00:00:00 |
+--------------------------------------------------------------------------+
2 rows in set (0.00 sec)
3. What did you see instead (Required)
MySQL [test]> select from_unixtime( if(`ts` >9999999999, ts/1000, `ts`), '%Y-%m-%d %H:%i:%s') from articles_of_video_day;
+--------------------------------------------------------------------------+
| from_unixtime( if(`ts` >9999999999, ts/1000, `ts`), '%Y-%m-%d %H:%i:%s') |
+--------------------------------------------------------------------------+
| 1970-01-02 11:46:39 |
| 1970-01-02 11:46:39 |
+--------------------------------------------------------------------------+
2 rows in set, 2 warnings (0.00 sec)
MySQL [test]> show warnings;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1690 | DECIMAL value is out of range in '(9, 4)' |
| Warning | 1690 | DECIMAL value is out of range in '(9, 4)' |
+---------+------+-------------------------------------------+
2 rows in set (0.00 sec)
you can see the currect result by this(cast(ts/1000 as signed))
MySQL [test]> select from_unixtime( if(`ts` >9999999999, cast(ts/1000 as signed), `ts`), '%Y-%m-%d %H:%i:%s') from articles_of_video_day;
+------------------------------------------------------------------------------------------+
| from_unixtime( if(`ts` >9999999999, cast(ts/1000 as signed), `ts`), '%Y-%m-%d %H:%i:%s') |
+------------------------------------------------------------------------------------------+
| 2024-09-03 00:00:00 |
| 2024-09-03 00:00:00 |
+------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
4. What is your TiDB version? (Required)
v7.5.1,v8.1.1,
asktug url: https://asktug.com/t/topic/1031711/10
lance6716 and Defined2014
Metadata
Metadata
Assignees
Labels
affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.report/communityThe community has encountered this bug.The community has encountered this bug.severity/criticalsig/executionSIG executionSIG executiontype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.type/regression