Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with MySQL 8.0 about insert over length string into CHAR column #10392

Closed
lonng opened this issue May 8, 2019 · 9 comments · Fixed by #20987
Closed

Incompatible with MySQL 8.0 about insert over length string into CHAR column #10392

lonng opened this issue May 8, 2019 · 9 comments · Fixed by #20987
Assignees
Labels
challenge-program component/expression good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/P3 The issue has P3 priority. Assigned to backlog. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug. type/compatibility
Milestone

Comments

@lonng
Copy link
Contributor

lonng commented May 8, 2019

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
➜  ~ tidiff 'select @@sql_mode'
MySQL(127.0.0.1:3306)> select @@sql_mode
+-----------------------------------------------------------------------------------------------------------------------+
| @@sql_mode                                                                                                            |
+-----------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.002 sec)

TiDB(127.0.0.1:4000)> select @@sql_mode
+--------------------------------------------+
| @@sql_mode                                 |
+--------------------------------------------+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+
1 row in set (0.003 sec)

➜  ~ tidiff 'create table vctt (v varchar(4), c char(4))'
MySQL(127.0.0.1:3306)> create table vctt (v varchar(4), c char(4))
Query OK (0.006 sec)

TiDB(127.0.0.1:4000)> create table vctt (v varchar(4), c char(4))
Query OK (0.007 sec)

➜  ~ tidiff 'insert into vctt values ("ab  ", "ab   ")'
MySQL(127.0.0.1:3306)> insert into vctt values ("ab  ", "ab   ")
Query OK (0.003 sec)

TiDB(127.0.0.1:4000)> insert into vctt values ("ab  ", "ab   ")
Error 1406: Data too long for column 'c' at row 1

➜  ~ tidiff 'select * from vctt'
MySQL(127.0.0.1:3306)> select * from vctt
+-----------+
| v    | c  |
+-----------+
| ab   | ab |
+-----------+
1 row in set (0.001 sec)

TiDB(127.0.0.1:4000)> select * from vctt
0 row in set (0.107 sec)
  1. What did you expect to see?

Truncate over length string successfully.

  1. What did you see instead?

Got error Error 1406: Data too long for column 'c' at row 1

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                                            |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v2.1.8-24-g7b36cdfb6-dirty
Git Commit Hash: 7b36cdfb6e8a4c279fc360ed79cf1c499b553688
Git Branch: failpoint-2.1
UTC Build Time: 2019-04-30 08:26:17
GoVersion: go version go1.12 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

SIG slack channel

#sig-exec

Score

  • 300

Mentor

@lonng lonng added type/bug The issue is confirmed as a bug. type/compatibility good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels May 8, 2019
zhuozl added a commit to zhuozl/tidb that referenced this issue May 9, 2019
@ghost
Copy link

ghost commented Jul 13, 2020

Confirming this bug still exists in master (you don't need to change TiDB's sql modes - the original testcase is unclear there):

drop table if exists vctt;
create table vctt (v varchar(4), c char(4));
insert into vctt values ("ab  ", "ab   ");

..

mysql> insert into vctt values ("ab  ", "ab   ");
ERROR 1406 (22001): Data too long for column 'c' at row 1
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-750-g8a661044c
Edition: Community
Git Commit Hash: 8a661044cedf8daad1de4fbf79a390962b6f6c3b
Git Branch: master
UTC Build Time: 2020-07-10 10:52:37
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)

@ghost ghost added the priority/P3 The issue has P3 priority. Assigned to backlog. label Aug 12, 2020
@qw4990 qw4990 added severity/critical help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Aug 26, 2020
@lzmhhh123
Copy link
Contributor

duplicated with #4323

@wjhuang2016
Copy link
Member

I think it's a compatibility problem. TiDB truncates the tailing spaces, insert "ab "(three tail spaces) to char(4) is ok. But MySQL would pads "ab " to char(4), then fails. @nullnotnil What do you think about this? Should we need to fix it?

@ghost
Copy link

ghost commented Nov 3, 2020

Yes, I don't think it is high priority, but I expect there could be applications that depend on this.

@wjhuang2016
Copy link
Member

wjhuang2016 commented Nov 3, 2020

Yes, I don't think it is high priority, but I expect there could be applications that depend on this.

Ok, I hope some contributors can help us with this issue. It's not hard to fix.

@jebter jebter assigned SunRunAway and unassigned SunRunAway Nov 4, 2020
@scsldb scsldb added this to the v4.0.9 milestone Nov 4, 2020
@ichn-hu
Copy link
Contributor

ichn-hu commented Nov 9, 2020

/assign @ichn-hu

@ichn-hu
Copy link
Contributor

ichn-hu commented Nov 17, 2020

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

@ti-srebot
Copy link
Contributor

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

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
challenge-program component/expression good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/P3 The issue has P3 priority. Assigned to backlog. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug. type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants