Bug #102169 tinyint DIV a small value expression return wrong

Submitted: 7 Jan 2021 9:42 Modified: 7 Jan 2021 9:55
Reporter: zetao wei Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S2 (Serious)
Version:8.0.18, 5.6.50, 5.7.32, 8.0.22 OS:Any
Assigned to: CPU Architecture:Any

[7 Jan 2021 9:42] zetao wei
Description:

mysql> select (b DIV 0.0001 / 2) as x from t3 group by x;
+-----------+
| x         |
+-----------+
| 5000.0000 |
+-----------+

mysql> select (a DIV 0.0001 / 2) as x from t3 group by x order by x;
+----------+
| x        |
+----------+
| 999.9999 |
+----------+

The result is wrong when `Using temporary`.

I think the Field_new_decimal is overflow when the DIV expression has tinyint.

How to repeat:
create table t3 (a tinyint, b int);
insert into t3 values (1, 1);
select (a DIV 0.0001 / 2) as x from t3 group by x order by x;
[7 Jan 2021 9:55] MySQL Verification Team
Hello zetao wei,

Thank you for the report and test case.

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.