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

ConnectSE truncating data on DECIMAL column

    Details

      Description

      The Connect engine is doing some strange things for a DECIMAL column.

      It starts off normal:

      MariaDB [test]> CREATE TABLE connect14007 ( id INT PRIMARY KEY AUTO_INCREMENT, foo DECIMAL(18,3));
      Query OK, 0 rows affected (0.02 sec)
       
      MariaDB [test]> CREATE TABLE connect14007j ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=connect14007 CONNECTION='jdbc:mysql://localhost/test?user=root';
      Query OK, 0 rows affected (0.02 sec)
       
      MariaDB [test]> INSERT INTO connect14007 ( foo ) VALUES ( 1234567890.123 );
      Query OK, 1 row affected (0.09 sec)
       
      MariaDB [test]> SELECT 'MariaDB', foo FROM connect14007 UNION ALL SELECT 'Connect', foo FROM connect14007j;
      +---------+----------------+
      | MariaDB | foo            |
      +---------+----------------+
      | MariaDB | 1234567890.123 |
      | Connect | 1234567890.123 |
      +---------+----------------+
      2 rows in set (0.01 sec)
       
      MariaDB [test]> 
      

      Until we add one more number (10x):

      MariaDB [test]> INSERT INTO connect14007 ( foo ) VALUES ( 12345678901.123 );
      Query OK, 1 row affected (0.00 sec)
       
      MariaDB [test]> SELECT 'MariaDB', foo FROM connect14007 UNION ALL SELECT 'Connect', foo FROM connect14007j;
      +---------+-----------------+
      | MariaDB | foo             |
      +---------+-----------------+
      | MariaDB |  1234567890.123 |
      | MariaDB | 12345678901.123 |
      | Connect |  1234567890.123 |
      | Connect | 12345678901.123 |
      +---------+-----------------+
      4 rows in set, 1 warning (0.00 sec)
       
      MariaDB [test]> SHOW WARNINGS;
      +-------+------+------------------------------------------+
      | Level | Code | Message                                  |
      +-------+------+------------------------------------------+
      | Note  | 1265 | Data truncated for column 'foo' at row 2 |
      +-------+------+------------------------------------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> 
      

      We can do this three more times:

      MariaDB [test]> SELECT 'MariaDB', foo FROM connect14007 UNION ALL SELECT 'Connect', foo FROM connect14007j;
      +---------+--------------------+
      | MariaDB | foo                |
      +---------+--------------------+
      | MariaDB |     1234567890.123 |
      | MariaDB |    12345678901.123 |
      | MariaDB |   123456789012.123 |
      | MariaDB |  1234567890123.123 |
      | MariaDB | 12345678901234.123 |
      | Connect |     1234567890.123 |
      | Connect |    12345678901.123 |
      | Connect |   123456789012.123 |
      | Connect |  1234567890123.123 |
      | Connect | 12345678901234.123 |
      +---------+--------------------+
      10 rows in set, 4 warnings (0.01 sec)
       
      MariaDB [test]> show warnings;
      +-------+------+------------------------------------------+
      | Level | Code | Message                                  |
      +-------+------+------------------------------------------+
      | Note  | 1265 | Data truncated for column 'foo' at row 2 |
      | Note  | 1265 | Data truncated for column 'foo' at row 3 |
      | Note  | 1265 | Data truncated for column 'foo' at row 4 |
      | Note  | 1265 | Data truncated for column 'foo' at row 5 |
      +-------+------+------------------------------------------+
      4 rows in set (0.00 sec)
       
      MariaDB [test]>  
      

      And the fifth one somehow changes the decimal value:

      MariaDB [test]> INSERT INTO connect14007 ( foo ) VALUES ( 123456789012345.123 );
      Query OK, 1 row affected (0.00 sec)
       
      MariaDB [test]> SELECT 'MariaDB', foo FROM connect14007 UNION ALL SELECT 'Connect', foo FROM connect14007j;
      +---------+---------------------+
      | MariaDB | foo                 |
      +---------+---------------------+
      | MariaDB |      1234567890.123 |
      | MariaDB |     12345678901.123 |
      | MariaDB |    123456789012.123 |
      | MariaDB |   1234567890123.123 |
      | MariaDB |  12345678901234.123 |
      | MariaDB | 123456789012345.123 |
      | Connect |      1234567890.123 |
      | Connect |     12345678901.123 |
      | Connect |    123456789012.123 |
      | Connect |   1234567890123.123 |
      | Connect |  12345678901234.123 |
      | Connect | 123456789012345.125 |
      +---------+---------------------+
      12 rows in set, 4 warnings (0.00 sec)
       
      MariaDB [test]> SHOW WARNINGS;
      +-------+------+------------------------------------------+
      | Level | Code | Message                                  |
      +-------+------+------------------------------------------+
      | Note  | 1265 | Data truncated for column 'foo' at row 2 |
      | Note  | 1265 | Data truncated for column 'foo' at row 3 |
      | Note  | 1265 | Data truncated for column 'foo' at row 4 |
      | Note  | 1265 | Data truncated for column 'foo' at row 5 |
      +-------+------+------------------------------------------+
      4 rows in set (0.00 sec)
       
      MariaDB [test]> 
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bertrandop Olivier Bertrand
                Reporter:
                wfong Will Fong
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: