Skip to content

set/enum need truncate when meet '\0' #4450

Closed

Description

@lkk2003rty
  1. What did you do?
mysql> create table t4(col2 set('a\nb\tc\rd\0ef'));
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t4(col2) values ('a\nb\tc\rd\0ef');
ERROR 1265 (01000): Data truncated for column 'col2' at row 1
mysql> insert into t4(col2) values ('a\nb\tc\rd');
Query OK, 1 row affected (0.00 sec)
  1. What did you expect to see?
    Just as above question's answer show.

  2. What did you see instead?

mysql> create table t4(col2 set('a\nb\tc\rd\0ef'));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t4(col2) values ('a\nb\tc\rd\0ef');
Query OK, 1 row affected (0.00 sec)

mysql> insert into t4(col2) values ('a\nb\tc\rd');
ERROR 1105 (HY000): cannot convert &{5 0 0 0 0 [97 10 98 9 99 13 100] <nil>} to type set
  1. What version of TiDB are you using (tidb-server -V)?
[root@devlop tidb]# ~/tidb-latest-linux-amd64/bin/tidb-server -V
Release Version: 0.9.0
Git Commit Hash: 44f716fb1342bfe6427d9bca741e1c85a062ff94
Git Commit Branch: master
UTC Build Time:  2017-09-03 01:14:50
[root@devlop tidb]#

Activity

  1. XuHuaiyu commented on Sep 6, 2017

    @XuHuaiyu
    Contributor

    @lkk2003rty This issue has been fixed?

  2. lkk2003rty commented on Sep 6, 2017

    @lkk2003rty
    ContributorAuthor

    Not yet now. It was found this issue when I work in that PR. And I just refer this issue in that PR's conversation as one exception we need to fix.

  3. wwar commented on Apr 18, 2020

    @wwar

    Confirming this issue is still present.

    Pasteable test case:

    DROP TABLE IF EXISTS t1;
    CREATE TABLE t1 (col2 set('a\nb\tc\rd\0ef'));
    INSERT INTO t1 (col2) VALUES ('a\nb\tc\rd\0ef');
    INSERT INTO t1 (col2) values ('a\nb\tc\rd');
    

    Results:

    ...
    
    tidb> INSERT INTO t1 (col2) VALUES ('a\nb\tc\rd\0ef');
    Query OK, 1 row affected (0.03 sec)
    
    tidb> INSERT INTO t1 (col2) values ('a\nb\tc\rd');
    ERROR 1105 (HY000): cannot convert datum from char to type set.
    
    tidb> select tidb_version()\G
    *************************** 1. row ***************************
    tidb_version(): Release Version: v4.0.0-beta.2-290-ga0c740784
    Git Commit Hash: a0c7407846fbc84f939afbc091f2db54f48c1bfa
    Git Branch: master
    UTC Build Time: 2020-04-17 04:04:45
    GoVersion: go1.13
    Race Enabled: false
    TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
    Check Table Before Drop: false
    1 row in set (0.00 sec)
    
  4. self-assigned this
    on Nov 10, 2020
  5. bb7133 commented on Nov 17, 2020

    @bb7133
    Member

    I think it is a bug of MySQL 5.7, probably because the C-styled string terminator is not handled properly and it has been fixed in MySQL 8:

    mysql> create table t4(col2 set('a\nb\tc\rd\0ef'));
    Query OK, 0 rows affected (0.03 sec)
    
    mysql> insert into t4(col2) values ('a\nb\tc\rd\0ef');
    Query OK, 1 row affected (0.01 sec)
    
    mysql> insert into t4(col2) values ('a\nb\tc\rd');
    ERROR 1265 (01000): Data truncated for column 'col2' at row 1
    mysql> 
    mysql> select version();
    +-----------+
    | version() |
    +-----------+
    | 8.0.18    |
    +-----------+
    1 row in set (0.01 sec)
    

    The behavior is exactly the same as TiDB.

    Although we claim that TiDB is compatible with 5.7, I still think we should not treat it as a bug nor "fix" it.

  6. ti-srebot commented on Nov 17, 2020

    @ti-srebot
    Contributor

    Please edit this comment or add a new comment to complete the following information

    Not a bug

    As what I stated above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions