WL#12595: Deprecate the ability to specify number of digits for floating point types

Affects: Server-8.0   —   Status: Complete

MySQL has a non-standard extension that allows users to specify the total number 
of digits as well as the number of digits after the decimal point:

  mysql> CREATE TABLE t1 (col1 DOUBLE(255, 0));
  Query OK, 0 rows affected (0.02 sec)

  mysql> CREATE TABLE t2 (col1 FLOAT(255, 0));
  Query OK, 0 rows affected (0.02 sec)

According to documentation, it has the following behavior:

"MySQL permits a nonstandard syntax: FLOAT(M,D) or REAL(M,D) or DOUBLE 
PRECISION(M,D). Here, (M,D) means than values can be stored with up to M digits 
in total, of which D digits may be after the decimal point. For example, a 
column defined as FLOAT(7,4) will look like -999.9999 when displayed. MySQL 
performs rounding when storing values, so if you insert 999.00009 into a 
FLOAT(7,4) column, the approximate result is 999.0001."

This is nonstandard, and causes a lot of headache when trying to find out how 
"long" a floating point number is. A column with this definition will skip 
scientific notation and print out numbers using its full length:

  mysql> CREATE TABLE t1 (col1 DOUBLE(50, 0));
  Query OK, 0 rows affected (0.05 sec)

  mysql> INSERT INTO t1 VALUES (1e50);
  Query OK, 1 row affected (0.01 sec)

  mysql> SELECT * FROM t1;
  +-----------------------------------------------------+
  | col1                                                |
  +-----------------------------------------------------+
  | 100000000000000000000000000000000000000000000000000 |
  +-----------------------------------------------------+
  1 row in set (0.00 sec)

It also contains a few interesting bugs:

  mysql> CREATE TABLE t1 (col1 DOUBLE(22, 23));
  ERROR 1427 (42000): For float(M,D), double(M,D) or decimal(M,D), M must be >= 
D (column 'col1').
  
  mysql> CREATE TABLE t1 AS SELECT ROUND(1e1, 23) AS col1;
  Query OK, 1 row affected (0.06 sec)
  Records: 1 Duplicates: 0 Warnings: 0
  
  mysql> SHOW CREATE TABLE t1;
  +-------+---------------------------------------------------------------------
--------------------------------------------------------------------------------
-------+
  | Table | Create Table |
  +-------+---------------------------------------------------------------------
--------------------------------------------------------------------------------
-------+
  | t1 | CREATE TABLE `t1` (
   `col1` double(22,23) NOT NULL DEFAULT '0.00000000000000000000000'
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
  +-------+---------------------------------------------------------------------
--------------------------------------------------------------------------------
-------+
  1 row in set (0.00 sec)


Note that we have DOUBLE(M,D) where D > M !! This causes:
a) Dump/restore will fail on this CREATE TABLE
b) The entire "max number of digits"-check is broken

  mysql> CREATE TABLE t2 (col1 DOUBLE(22, 21));
  Query OK, 0 rows affected (0.02 sec)
  
  mysql> INSERT INTO t2 VALUES (1e308);
  ERROR 1264 (22003): Out of range value for column 'col1' at row 1

  mysql> INSERT INTO t1 VALUES (1e308);
  Query OK, 1 row affected (0.04 sec)
F-1: Creating a table with a DOUBLE(M,D), FLOAT(M,D) or REAL(M,D) column
shall give a deprecation warning. This includes using CREATE TABLE LIKE and
CREATE TABLE SELECT

F-2: Adding a DOUBLE(M,D), FLOAT(M,D) or REAL(M,D) column to an existing 
table shall give a deprecation warning.

F-3: Modifying an existing column to make it a DOUBLE(M,D), FLOAT(M,D) or 
REAL(M,D) column shall give a deprecation warning.

NF-4: Other table changes (e.g. using FLOAT(p), altering a table already 
containing a FLOAT(M,D) column) shall not give a deprecation warning.

F-5: Use of DOUBLE(M,D), FLOAT(M,D) or REAL(M,D) in CREATE PROCEDURE/FUNCTION 
statements (e.g. OUT parameter) shall give a deprecation warning.


The deprecation warning is:
"Specifying number of digits for floating point data types is deprecated and will 
be removed in a future release."