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

CONV() function truncates the result to 21 symbol with default charset.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.2.29, 10.3.20, 10.4.12, 10.5.1
    • Fix Version/s: 10.4.13, 10.5.2
    • Component/s: Data types
    • Labels:
      None

      Description

      Consider the example run with MDB 10.4.11.

       
      MariaDB [test]> create table t1 (si smallint) engine=columnstore;
      Query OK, 0 rows affected (0.480 sec)
       
      MariaDB [test]> drop table t1;
      Query OK, 0 rows affected (0.354 sec)
       
      MariaDB [test]> create table t1 (si smallint);
      Query OK, 0 rows affected (0.020 sec)
       
      MariaDB [test]> insert into t1 values (-8.76221);
      Query OK, 1 row affected (0.004 sec)
       
      MariaDB [test]> select conv(si, 16, 8) from t;
      +------------------------+
      | conv(si, 16, 8)        |
      +------------------------+
      | 1777777777777777777767 |
      +------------------------+
      1 row in set (0.001 sec)
      MariaDB [test]> create table t2 as select conv(si, 16, 8) from t;
      Query OK, 1 row affected, 1 warning (0.028 sec)
      Records: 1  Duplicates: 0  Warnings: 1
      MariaDB [test]> show warnings;
      +---------+------+------------------------------------------------------+
      | Level   | Code | Message                                              |
      +---------+------+------------------------------------------------------+
      | Warning | 1265 | Data truncated for column 'conv(si, 16, 8)' at row 1 |
      +---------+------+------------------------------------------------------+
      1 row in set (0.000 sec)
      MariaDB [test]> show create table t2
          -> ;
      +-------+----------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                               |
      +-------+----------------------------------------------------------------------------------------------------------------------------+
      | t2    | CREATE TABLE `t2` (
        `conv(si, 16, 8)` varchar(21) CHARACTER SET utf8 DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+----------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.000 sec)
      MariaDB [test]> select length(conv(si, 16, 8)) from t;
      +-------------------------+
      | length(conv(si, 16, 8)) |
      +-------------------------+
      |                      22 |
      +-------------------------+
      1 row in set (0.001 sec)
      

      MDB 10.4.12 and 10.5 both return an error on CREATE..AS SELECT.

      MariaDB [test]> create table t1 (si smallint) engine=columnstore;
      Query OK, 0 rows affected (0.480 sec)
       
      MariaDB [test]> drop table t1;
      Query OK, 0 rows affected (0.354 sec)
       
      MariaDB [test]> create table t1 (si smallint);
      Query OK, 0 rows affected (0.020 sec)
       
      MariaDB [test]> insert into t1 values (-8.76221);
      Query OK, 1 row affected (0.004 sec)
       
      MariaDB [test]> create table t2 as select conv(si, 16, 8) from t1;
      ERROR 1406 (22001): Data too long for column 'conv(si, 16, 8)' at row 1
      MariaDB [test]> select length(conv(si, 16, 8)) from t1;
      +-------------------------+
      | length(conv(si, 16, 8)) |
      +-------------------------+
      |                      22 |
      +-------------------------+
      1 row in set (0.001 sec)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              drrtuy Roman
              Reporter:
              drrtuy Roman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: