Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-5248

Truncate on char and varchar columns with numeric digits returned incorrect results

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 22.08.2
    • 22.08.8
    • None
    • None
    • 2022-22, 2022-23

    Description

      Build tested: 22.08.2

      It seems to be a data type overflow issue.

      The issue was uncovered by MTR test case devregression/r/mcs7085_regression_bug3483.test. Actually, the reference result is also incorrect. The reference result needs to be updated when the issue is fixed.

      ColumnStore

      MariaDB [mytest]> create table t1 (c1 char(120), c2 varchar(120)) engine=columnstore;
      Query OK, 0 rows affected (0.228 sec)
       
      MariaDB [mytest]> insert into t1 values
       ('12345678901234567890', '12345678901234567890'), 
       ('12345678901234567890123456789012345678901234567890', '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'),
       ('-12345678901234567890', '-12345678901234567890'),
       ('-12345678901234567890123456789012345678901234567890', '-1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
      Query OK, 4 rows affected (0.175 sec)
      Records: 4  Duplicates: 0  Warnings: 0
       
      MariaDB [mytest]> 
      MariaDB [mytest]> select c1, truncate(c1, 2) from t1;
      +-----------------------------------------------------+-----------------------+
      | c1                                                  | truncate(c1, 2)       |
      +-----------------------------------------------------+-----------------------+
      | 12345678901234567890                                |  92233720368547760.00 |
      | 12345678901234567890123456789012345678901234567890  |  92233720368547760.00 |
      | -12345678901234567890                               | -92233720368547760.00 |
      | -12345678901234567890123456789012345678901234567890 | -92233720368547760.00 |
      +-----------------------------------------------------+-----------------------+
      4 rows in set (0.026 sec)
       
      MariaDB [mytest]> select c2, truncate(c2, 2) from t1;
      +-------------------------------------------------------------------------------------------------------+-----------------------+
      | c2                                                                                                    | truncate(c2, 2)       |
      +-------------------------------------------------------------------------------------------------------+-----------------------+
      | 12345678901234567890                                                                                  |  92233720368547760.00 |
      | 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890  |  92233720368547760.00 |
      | -12345678901234567890                                                                                 | -92233720368547760.00 |
      | -1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 | -92233720368547760.00 |
      +-------------------------------------------------------------------------------------------------------+-----------------------+
      

      InnoDB

      MariaDB [mytest]> create table t2 (c1 char(120), c2 varchar(120)) engine=innodb;
      Query OK, 0 rows affected (0.012 sec)
       
      MariaDB [mytest]> insert into t2 values 
          -> ('12345678901234567890', '12345678901234567890'), 
          -> ('12345678901234567890123456789012345678901234567890', '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'),
          -> ('-12345678901234567890', '-12345678901234567890'),
          -> ('-12345678901234567890123456789012345678901234567890', '-1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
      Query OK, 4 rows affected (0.000 sec)
      Records: 4  Duplicates: 0  Warnings: 0
       
      MariaDB [mytest]> 
      MariaDB [mytest]> 
      MariaDB [mytest]> select c1, truncate(c1, 2) from t2;
      +-----------------------------------------------------+--------------------------------------------------------+
      | c1                                                  | truncate(c1, 2)                                        |
      +-----------------------------------------------------+--------------------------------------------------------+
      | 12345678901234567890                                |                                12345678901234567000.00 |
      | 12345678901234567890123456789012345678901234567890  |  12345678901234567000000000000000000000000000000000.00 |
      | -12345678901234567890                               |                               -12345678901234567000.00 |
      | -12345678901234567890123456789012345678901234567890 | -12345678901234567000000000000000000000000000000000.00 |
      +-----------------------------------------------------+--------------------------------------------------------+
      4 rows in set (0.000 sec)
       
      MariaDB [mytest]> select c2, truncate(c2, 2) from t2;
      +-------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
      | c2                                                                                                    | truncate(c2, 2)                                                                                          |
      +-------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
      | 12345678901234567890                                                                                  |                                                                                  12345678901234567000.00 |
      | 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890  |  1234567890123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000.00 |
      | -12345678901234567890                                                                                 |                                                                                 -12345678901234567000.00 |
      | -1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 | -1234567890123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000.00 |
      +-------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
      4 rows in set (0.000 sec)
      
      

      Attachments

        Issue Links

          Activity

            People

              David.Hall David Hall (Inactive)
              dleeyh Daniel Lee (Inactive)
              Leonid Fedorov Leonid Fedorov
              Daniel Lee Daniel Lee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.