[MDEV-5180] Data type for WEIGHT_STRING is too short in some cases Created: 2013-10-24  Updated: 2013-11-01  Resolved: 2013-11-01

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.5
Fix Version/s: None

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


 Description   

WEIGHT_STRING() for one character uses 8 bytes in latin2_czech_cs,
but the data type for WEIGHT_STRING(varchar_1_column)
is VARBINARY(1). The expected data type is VARBINARY(8).

This script demonstrates the problem:

mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected (0.00 sec)
 
mysql> CREATE TABLE t1 (a VARCHAR(1)) CHARACTER SET latin2 COLLATE latin2_czech_cs;
Query OK, 0 rows affected (0.05 sec)
 
mysql> INSERT INTO t1 VALUES (0xF3),(0xD3);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
mysql> DROP TABLE IF EXISTS t2;
Query OK, 0 rows affected (0.11 sec)
 
mysql> CREATE TABLE t2 AS SELECT weight_string(a) FROM t1;
Query OK, 2 rows affected, 2 warnings (0.36 sec)
Records: 2  Duplicates: 0  Warnings: 2
 
mysql> SHOW WARNINGS;
+---------+------+-------------------------------------------------------+
| Level   | Code | Message                                               |
+---------+------+-------------------------------------------------------+
| Warning | 1265 | Data truncated for column 'weight_string(a)' at row 1 |
| Warning | 1265 | Data truncated for column 'weight_string(a)' at row 2 |
+---------+------+-------------------------------------------------------+
2 rows in set (0.00 sec)
 
mysql> SHOW CREATE TABLE t2;
+-------+-----------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                              |
+-------+-----------------------------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `weight_string(a)` varbinary(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------------------------------------------+
1 row in set (0.16 sec)
 
mysql> SELECT LENGTH(weight_string(a)) FROM t1;
+--------------------------+
| LENGTH(weight_string(a)) |
+--------------------------+
|                        8 |
|                        8 |
+--------------------------+
2 rows in set (0.00 sec)



 Comments   
Comment by Alexander Barkov [ 2013-10-24 ]

The problem is also repeatable in MySQL-5.6.14.

Comment by Alexander Barkov [ 2013-11-01 ]

Pushed into 10.0.

Generated at Thu Feb 08 07:02:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.