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

Data type for WEIGHT_STRING is too short in some cases

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.0.5
    • Fix Version/s: None
    • Component/s: None
    • 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)
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            bar Alexander Barkov added a comment -

            The problem is also repeatable in MySQL-5.6.14.

            Show
            bar Alexander Barkov added a comment - The problem is also repeatable in MySQL-5.6.14.
            Hide
            bar Alexander Barkov added a comment -

            Pushed into 10.0.

            Show
            bar Alexander Barkov added a comment - Pushed into 10.0.

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: