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

[FATAL] [lib.rs:478] ["range end index 4 out of range for slice of length 3"] #56494

Closed
sayJason opened this issue Oct 9, 2024 · 2 comments · Fixed by #57484
Closed

[FATAL] [lib.rs:478] ["range end index 4 out of range for slice of length 3"] #56494

sayJason opened this issue Oct 9, 2024 · 2 comments · Fixed by #57484
Assignees
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. impact/crash crash/fatal severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@sayJason
Copy link

sayJason commented Oct 9, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE t1 (c1 bit(24));
INSERT IGNORE t1 (c1) VALUES (b'100011111100001110010100001000000101000011011100000011010001110');
SELECT c1 FROM t1 WHERE FALSE NOT LIKE CONVERT(c1, CHAR);

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

Execute without crash

3. What did you see instead (Required)

Crash down the server

4. What is your TiDB version? (Required)

Release Version: v8.3.0
Edition: Community
Git Commit Hash: 1a0c3ac
Git Branch: HEAD
UTC Build Time: 2024-08-20 10:13:01
GoVersion: go1.21.10
Race Enabled: false
Check Table Before Drop: false
Store: tikv

@windtalker
Copy link
Contributor

The root cause is the collation of like function is derived to be utf8mb4_general_ci, which is not expected. Since the collation of cast(bit as char) should be binary, and the collation of like should be binary.

@windtalker windtalker added sig/sql-infra SIG: SQL Infra and removed sig/execution SIG execution labels Oct 25, 2024
@ti-chi-bot ti-chi-bot bot added the affects-8.5 This bug affects the 8.5.x(LTS) versions. label Nov 1, 2024
@lcwangchao lcwangchao added affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. and removed may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 labels Nov 19, 2024
@lcwangchao
Copy link
Collaborator

The root cause is the collation of like function is derived to be utf8mb4_general_ci, which is not expected. Since the collation of cast(bit as char) should be binary, and the collation of like should be binary.

I think the collation of cast(bit as char) should still be utf8mb4_general_ci wich is the connection collation. However, the cast should return a NULL value if the bit is not a legal utf8 format. That is what I tested in MySQL:

mysql> create table t1(a bit(24));
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t1 values(0xffff);
Query OK, 1 row affected (0.01 sec)

mysql> select cast(a as char) from t1;
Field   1:  `cast(a as char)`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8mb4_general_ci (45)
Length:     96
Max_length: 0
Decimals:   31
Flags:


+-----------------+
| cast(a as char) |
+-----------------+
| NULL            |
+-----------------+
1 row in set, 1 warning (0.01 sec)

@lcwangchao lcwangchao self-assigned this Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. impact/crash crash/fatal severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants