Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-15311

DOUBLE PRECISION(M,D)-SELECT CAST ('value' AS DOUBLE(30)); gives an syntax error

    XMLWordPrintable

    Details

      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)
      

        Attachments

          Activity

            People

            Assignee:
            serg Sergei Golubchik
            Reporter:
            pramod.mahto@mariadb.com Pramod Mahto
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: