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

mariadb makes non explicit rounding for DECIMAL type dynamic columns

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not a Bug
    • Affects Version/s: 10.0.20
    • Fix Version/s: N/A
    • Component/s: Dynamic Columns
    • Labels:
      None
    • Environment:
      Linux

      Description

      SET @aaa = COLUMN_CREATE('sum', 18802.5);
      SELECT COLUMN_GET(@aaa, 'sum' AS DECIMAL);
      
      COLUMN_GET(@aaa, 'sum' as decimal)  
      ------------------------------------
      18803      
      

      Expected see here 18802.5 because i not pointed here any restrictions for DECIMAL type

      So why by default DECIMAL works as INT? I think this is not expected and not correct.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            It is documented: https://mariadb.com/kb/en/mariadb/decimal/

            DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]

            …If D is omitted, the default is 0. If M is omitted, the default is 10.

            Compare with:

            MariaDB [test]> create table t1 (a decimal);
            Query OK, 0 rows affected (0.00 sec)
            
            MariaDB [test]> show create table t1\G
            *************************** 1. row ***************************
                   Table: t1
            Create Table: CREATE TABLE `t1` (
              `a` decimal(10,0) DEFAULT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1
            1 row in set (0.00 sec)
            
            Show
            serg Sergei Golubchik added a comment - It is documented: https://mariadb.com/kb/en/mariadb/decimal/ DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL] …If D is omitted, the default is 0. If M is omitted, the default is 10. Compare with: MariaDB [test]> create table t1 (a decimal); Query OK, 0 rows affected (0.00 sec) MariaDB [test]> show create table t1\G *************************** 1. row *************************** Table: t1 Create Table: CREATE TABLE `t1` ( `a` decimal(10,0) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 1 row in set (0.00 sec)

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                mikhail Mikhail Gavrilov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: