[MDEV-15311] DOUBLE PRECISION(M,D)-SELECT CAST ('value' AS DOUBLE(30)); gives an syntax error Created: 2018-02-14  Updated: 2020-08-25  Resolved: 2018-02-14

Status: Closed
Project: MariaDB Server
Component/s: Data types, Documentation
Affects Version/s: 10.2
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Pramod Mahto Assignee: Sergei Golubchik
Resolution: Fixed Votes: 1
Labels: datatype


 Description   

Hi Team,

DOUBLE [(M [, D])] - New in 5.3 D is obviously not an optional requirement but without filling D option it is giving sql syntax error.

While looking at MariaDB KB :-
https://mariadb.com/kb/en/library/double/

"M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits allowed by the hardware."

For Example:-

MariaDB [(none)]> SELECT CAST ('9.22337E+18' AS DOUBLE(30));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '))' at line 1
 
MariaDB [(none)]> SELECT CAST ('9.22337E+18' AS DOUBLE(30,2));
+--------------------------------------+
| CAST ('9.22337E+18' AS DOUBLE(30,2)) |
+--------------------------------------+
|               9223370000000000000.00 |
+--------------------------------------+

Another example of create table :-

MariaDB [test]> create table dtest3 (dd double(30));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '))' at line 1
MariaDB [test]> create table dtest3 (dd double(30,2));
Query OK, 0 rows affected (0.05 sec)
 
MariaDB [test]> show create table dtest3;;
+--------+-------------------------------------------------------------------------------------------------+
| Table  | Create Table                                                                                    |
+--------+-------------------------------------------------------------------------------------------------+
| dtest3 | CREATE TABLE `dtest3` (
  `dd` double(30,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+--------+-------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)



 Comments   
Comment by Elena Stepanova [ 2018-02-14 ]

As mentioned in comments to MDEV-597 the "D" part in DOUBLE [(M [, D])] for CAST at https://mariadb.com/kb/en/library/convert/ is a documentation issue. DOUBLE(M) makes no sense, it's not even a valid type, as your second example demonstrates, and as documented at https://mariadb.com/kb/en/library/double/.

I'll leave it to bar to confirm.

Comment by Alexander Barkov [ 2018-02-16 ]

Sergei fixed the manual. Now it says DOUBLE[(M,D)] instead of DOUBLE [(M [, D])].

Generated at Thu Feb 08 08:20:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.