[MDEV-21841] CONV() function truncates the result to 21 symbol with default charset. Created: 2020-02-28  Updated: 2020-02-29  Resolved: 2020-02-29

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.2.29, 10.3.20, 10.4.12, 10.5.1
Fix Version/s: 10.4.13, 10.5.2

Type: Bug Priority: Minor
Reporter: Roman Assignee: Roman
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MCOL-3596 conv() returns less chars in the resu... Closed

 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)



 Comments   
Comment by Alexander Barkov [ 2020-02-29 ]

Ok to push. Thanks for fixing this!

Comment by Roman [ 2020-02-29 ]

Pushed.

Generated at Thu Feb 08 09:10:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.