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

query and insert data error whlie concat_ws as expression index #27361

Closed
aytrack opened this issue Aug 19, 2021 · 2 comments · Fixed by #27376
Closed

query and insert data error whlie concat_ws as expression index #27361

aytrack opened this issue Aug 19, 2021 · 2 comments · Fixed by #27376
Assignees
Labels
severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented Aug 19, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t01(a varchar(20));
insert into t01 values ("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙");
alter table t01 add index eidx ((concat_ws('expression_index', a, 'test')));
 select * from t01 use index (eidx)  where (concat_ws('expression_index', a, 'test')) not like (concat_ws('expression_index', "齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙", 'test'));
insert into t01 values ("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙");

2. What did you expect to see? (Required)

MySQL root@172.16.5.103:hchwang> select * from t01 use index (eidx)  where (concat_ws('expression_index', a, 'test')) not like (concat_ws('expression_index', "齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙", 'test'));
+---+
| a |
+---+
0 rows in set
Time: 0.054s
MySQL root@172.16.5.103:hchwang> insert into t01 values ("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙");
Query OK, 1 row affected
Time: 0.039s
MySQL root@172.16.5.103:hchwang> select * from t01;
+------------------------------------------+
| a                                        |
+------------------------------------------+
| 齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙 |
| 齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙 |
+------------------------------------------+

3. What did you see instead (Required)

MySQL root@127.0.0.1:test> drop table t01;
Query OK, 0 rows affected
Time: 0.019s
MySQL root@127.0.0.1:test> create table t01(a varchar(20));
Query OK, 0 rows affected
Time: 0.011s
MySQL root@127.0.0.1:test> insert into t01 values ("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙");
Query OK, 1 row affected
Time: 0.001s
MySQL root@127.0.0.1:test> alter table t01 add index eidx ((concat_ws('expression_index', a, 'test')));
Query OK, 0 rows affected
Time: 2.547s

MySQL root@127.0.0.1:test> select * from t01 use index (eidx)  where (concat_ws('expression_index', a, 'test')) not like (concat_ws('expression_index', "齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙", 'test'));
+------------------------------------------+
| a                                        |
+------------------------------------------+
| 齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙 |
+------------------------------------------+
1 row in set
Time: 0.008s
MySQL root@127.0.0.1:test> insert into t01 values ("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙");
(1406, 'Data Too Long, field len 25, data len 40')

MySQL root@127.0.0.1:test> select * from t01;
+------------------------------------------+
| a                                        |
+------------------------------------------+
| 齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙 |
+------------------------------------------+

4. What is your TiDB version? (Required)

tidb_version() | Release Version: v5.2.0-alpha-567-gdba8e111f-dirty
Edition: Community
Git Commit Hash: dba8e111fe26b1db0742dd5a024309137d49f5d2
Git Branch: release-5.2
UTC Build Time: 2021-08-19 01:23:29
GoVersion: go1.16.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/sql-infra SIG: SQL Infra severity/critical labels Aug 19, 2021
@aytrack
Copy link
Contributor Author

aytrack commented Aug 19, 2021

replace has the same problem

MySQL root@127.0.0.1:test> drop table t01;
Query OK, 0 rows affected
Time: 0.021s
MySQL root@127.0.0.1:test> create table t01(a varchar(20));
Query OK, 0 rows affected
Time: 0.011s
MySQL root@127.0.0.1:test> insert into t01 values ("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙");
Query OK, 1 row affected
Time: 0.001s
MySQL root@127.0.0.1:test> alter table t01 add index eidx ((replace(a, substr(a, 1, 3), 'expression_index')));
Query OK, 0 rows affected
Time: 2.549s
MySQL root@127.0.0.1:test> select * from t01;
+------------------------------------------+
| a                                        |
+------------------------------------------+
| 齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙 |
+------------------------------------------+
1 row in set
Time: 0.006s
MySQL root@127.0.0.1:test> select * from t01 use index (eidx)  where replace(a, substr(a, 1, 3), 'expression_index') = replace("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙", substr("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙", 1, 3), 'expression_index');
+---+
| a |
+---+
0 rows in set
Time: 0.006s
MySQL root@127.0.0.1:test> select * from t01 ignore index (eidx)  where replace(a, substr(a, 1, 3), 'expression_index') = replace("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙", substr("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙", 1, 3), 'expression_index');
+------------------------------------------+
| a                                        |
+------------------------------------------+
| 齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙 |
+------------------------------------------+
1 row in set
Time: 0.009s
MySQL root@127.0.0.1:test> insert into t01 values ("齆斮聒蚆髙锐潊贩哨啅捸爖斥圱犳飁綴纜牖蚙");
(1406, 'Data Too Long, field len 20, data len 33')

@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
severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
3 participants