Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5
-
None
Description
After fixes made in MDEV-23337, ROUND() returns good results for integer input:
CREATE OR REPLACE TABLE t1 (a bigint(21) unsigned); |
CREATE OR REPLACE TABLE t2 AS SELECT ROUND(a),TRUNCATE(a,0),FLOOR(a),CEILING(a) FROM t1; |
DESC t2; |
+---------------+---------------------+------+-----+---------+-------+
|
| Field | Type | Null | Key | Default | Extra |
|
+---------------+---------------------+------+-----+---------+-------+
|
| ROUND(a,0) | bigint(21) unsigned | YES | | NULL | |
|
| TRUNCATE(a,0) | bigint(21) unsigned | YES | | NULL | |
|
| FLOOR(a) | bigint(21) unsigned | YES | | NULL | |
|
| CEILING(a) | bigint(21) unsigned | YES | | NULL | |
|
+---------------+---------------------+------+-----+---------+-------+
|
However, if the length get longer than 21, the result is still not nice:
CREATE OR REPLACE TABLE t1 (a bigint(22) unsigned); |
CREATE OR REPLACE TABLE t2 AS SELECT ROUND(a),TRUNCATE(a,0),FLOOR(a),CEILING(a) FROM t1; |
DESC t2; |
+---------------+------------------------+------+-----+---------+-------+
|
| Field | Type | Null | Key | Default | Extra |
|
+---------------+------------------------+------+-----+---------+-------+
|
| ROUND(a,0) | decimal(22,0) unsigned | YES | | NULL | |
|
| TRUNCATE(a,0) | bigint(22) unsigned | YES | | NULL | |
|
| FLOOR(a) | bigint(22) unsigned | YES | | NULL | |
|
| CEILING(a) | bigint(22) unsigned | YES | | NULL | |
|
+---------------+------------------------+------+-----+---------+-------+
|
Notice, decimal(22,0) instead of bigint(22), which is the data type of the argument.
ROUND(bigint,0) cannot go outside of the BIGINT limit. No needs to create the decimal data type.
Attachments
Issue Links
- relates to
-
MDEV-23337 Rounding functions create a wrong data type for integer input
-
- Closed
-
-
MDEV-23032 FLOOR()/CEIL() incorrectly calculate the precision of a DECIMAL(M,D) column.
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Summary | CREATE OR REPLACE TABLE t1 (a bigint(80) unsigned); CREATE OR REPLACE TABLE t2 AS SELECT ROUND(a),TRUNCATE(a,0),FLOOR(a),CEILING(a) FROM t1; DESC t2; | ROUND(bigint_22_or_longer) returns a wrong data type |
Link |
This issue relates to |
Link |
This issue relates to |
Status | Open [ 1 ] | In Progress [ 3 ] |
issue.field.resolutiondate | 2020-08-02 18:47:08.0 | 2020-08-02 18:47:08.275 |
Fix Version/s | 10.4.14 [ 24305 ] | |
Fix Version/s | 10.5.5 [ 24423 ] | |
Fix Version/s | 10.4 [ 22408 ] | |
Resolution | Fixed [ 1 ] | |
Status | In Progress [ 3 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 111847 ] | MariaDB v4 [ 158174 ] |