Bug #79589 FLOOR(bigint column expr) return different result type (NEWDECIMAL/LONGLONG)

Submitted: 10 Dec 2015 8:51 Modified: 2 Dec 2019 22:21
Reporter: Su Dylan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.7.8, 5.7.10, 5.6.29 OS:Any
Assigned to: CPU Architecture:Any

[10 Dec 2015 8:51] Su Dylan
Description:
Output:
========
mysql> drop table if exists t1;
Query OK, 0 rows affected (0.00 sec)

mysql> create table t1(c1 int, c2 bigint);
Query OK, 0 rows affected (0.01 sec)

mysql> select c1+1, floor(c1+1), c2, floor(c2) from t1;
Field   1:  `c1+1`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONGLONG
Collation:  binary (63)
Length:     12
Max_length: 0
Decimals:   0
Flags:      BINARY NUM

Field   2:  `floor(c1+1)`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONGLONG
Collation:  binary (63)
Length:     14
Max_length: 0
Decimals:   0
Flags:      BINARY NUM

Field   3:  `c2`
Catalog:    `def`
Database:   `test`
Table:      `t1`
Org_table:  `t1`
Type:       LONGLONG
Collation:  binary (63)
Length:     20
Max_length: 0
Decimals:   0
Flags:      NUM

Field   4:  `floor(c2)`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       NEWDECIMAL
Collation:  binary (63)
Length:     17
Max_length: 0
Decimals:   0
Flags:      BINARY

0 rows in set (0.00 sec)

mysql>
mysql> select version();
Field   1:  `version()`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  ? (45)
Length:     32
Max_length: 8
Decimals:   31
Flags:      NOT_NULL

+-----------+
| version() |
+-----------+
| 5.7.8-rc  |
+-----------+
1 row in set (0.00 sec)

Problem:
========
c1+1 and c2 are both with LONGLONG type, but floor(c1+1) and floor(c2) have different types.

How to repeat:
> With --column-type-info

drop table if exists t1;
create table t1(c1 int, c2 bigint);
select c1+1, floor(c1+1), c2, floor(c2) from t1;

Suggested fix:
floor(c1+1) and floor(c2) have the same type.
[10 Dec 2015 11:34] MySQL Verification Team
Hello Su Dylan,

Thank you for the report.

Thanks,
Umesh
[2 Dec 2019 22:21] Roy Lyseng
Posted by developer:
 
Fixed in 8.0.18

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

Page generated in 0.041 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.