pingcap / pingcap/tidb

TiDB execute SQL return wired error but MySQL execute successfully

Open
#34,744 0 comments 0 reactions 0 assignees View on GitHub
severity/moderate sig/transaction type/bug type/compatibility
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

1. prepare data
```sql
CREATE TABLE `tbl_1` (
`col_3` time DEFAULT '22:46:54'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE `tbl_2` (
`col_8` time DEFAULT '20:06:25',
`col_9` set('Alice','Bob','Charlie','David') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

INSERT INTO `tbl_1` VALUES ('02:27:56');
INSERT INTO `tbl_2` VALUES ('06:56:19','Alice');
```

2. reproduce

```sql
update tbl_2 set tbl_2.col_9 = 'Bob' where tbl_2.col_8 in (select col_3 from tbl_1 where not( tbl_2.col_8 in ( select col_3 from tbl_1 where not( tbl_2.col_8 in ( '15:41:22.00' ) ) ) ) );
```

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

Execute success, since mysql will execute success.

### 3. What did you see instead (Required)

```sql
> update tbl_2 set tbl_2.col_9 = 'Bob' where tbl_2.col_8 in (select col_3 from tbl_1 where not( tbl_2.col_8 in ( select col_3 from tbl_1 where not( tbl_2.col_8 in ( '15:41:22.00' ) ) ) ) );
(1105, 'Data Too Long, field len 10, data len 15')
```

### 4. What is your TiDB version? (Required)

```sql
***************************[ 1. row ]***************************
tidb_version() | Release Version: v6.1.0-alpha-432-gd75b06ec97
Edition: Community
Git Commit Hash: d75b06ec97e54ef9f5a15630e7dfee30d22f047e
Git Branch: master
UTC Build Time: 2022-05-17 07:29:42
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.