Bug #79589 FLOOR(bigint column expr) return different result type (NEWDECIMAL/LONGLONG)
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.
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.