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

Data type for WEIGHT_STRING is too short in some cases

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 10.0.5
    • None
    • None
    • 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)

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.