pingcap / pingcap/tidb

TiDB execute SQL return wired error but MySQL execute successfully

Open
#34,731 4 comments 0 reactions 0 assignees View on GitHub
severity/moderate sig/execution 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)

**Prepare Data**
```sql
CREATE TABLE `tbl_1` (
`col_1` text COLLATE utf8mb4_unicode_ci NOT NULL,
`col_2` text COLLATE utf8mb4_unicode_ci NOT NULL,
`col_3` bigint(20) unsigned DEFAULT '5676205646913889784',
`col_4` timestamp NULL DEFAULT NULL,
`col_5` bigint(20) DEFAULT '-4308548683952882255',
`col_6` year(4) DEFAULT NULL,
`col_7` varchar(170) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Imt9*GHItNVFB=#Kup',
`col_8` tinyint(4) DEFAULT NULL,
`col_9` int(11) NOT NULL DEFAULT '208580336',
KEY `idx_1` (`col_9`,`col_4`),
UNIQUE KEY `idx_2` (`col_8`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `tbl_1` VALUES
('wvAGg7BHlv(u','曇蚮&(^M亍',6877734825699900156,'2028-03-07 00:00:00',-3958324004700513057,'1996','wZMV4VQf=',-113,-1195974152),
('aO+(xbC(8cCfGa!','忈t0hsF箴DkmV',598351611504325273,'1971-11-11 00:00:00',-1177180505683402119,'1980','E',-116,-483710475),
('QRDZ3!ulW(','暱蘰6as溍',5544890415772998864,'1987-04-15 00:00:00',-8846330732296091735,'1993','G',103,1725453023),
('udKCu$sepqpFGPXs','g瘘7A^懙拶^f綣LeIwi(',8292215072274937135,'1998-09-26 00:00:00',NULL,'2028','vF_&C$K-',127,7328258),
('z~=iUZCKbzapt##','9+3~',6739222345304830172,'2008-11-07 00:00:00',-4681772579285841080,'1976','mqD3*TaRLWKBUJ&YzDA',18,-487364325),
('Sp14kX~M','眮_菘&4鮂!F',1180806539399325827,'2034-08-26 00:00:00',16023400532868066,'2012','SV',101,1355349306),
('k4V','予~=(xpF領',8534163310348411402,'2003-01-25 00:00:00',-4356084940612209469,'2008','wEI)-5+',-38,-1234666151),
('G','_^蔇eG)硺VI',139045569072236563,'2028-04-02 00:00:00',-5116147526701196955,'2021','Q^yEuBx6h)KHk=Zz',-56,-1049680221);

CREATE TABLE `tbl_2` (
`col_10` timestamp NOT NULL DEFAULT '2012-01-15 00:00:00',
`col_11` datetime NOT NULL,
`col_12` mediumint(8) unsigned NOT NULL,
`col_13` tinyint(4) DEFAULT NULL,
`col_14` enum('Alice','Bob','Charlie','David') COLLATE gbk_bin NOT NULL DEFAULT 'Bob',
`col_15` date DEFAULT '1998-04-08',
`col_16` date DEFAULT '1996-03-07',
`col_17` tinyint(4) NOT NULL DEFAULT '80',
KEY `idx_3` (`col_15`,`col_12`),
KEY `idx_4` (`col_14`,`col_13`),
KEY `idx_5` (`col_16`,`col_12`,`col_14`),
PRIMARY KEY (`col_12`,`col_10`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE=gbk_bin;

INSERT INTO `tbl_2` VALUES
('2007-07-28 00:00:00','1979-01-20 00:00:00',630549,-75,'David','2029-05-06','1997-03-30',-81),
('2030-09-03 00:00:00','1973-01-19 00:00:00',1152126,-93,'Charlie','2033-03-19','2018-06-09',105),
('2034-02-15 00:00:00','2026-02-19 00:00:00',1301046,-69,'David','2008-06-24','2013-02-07',-38),
('1996-03-20 00:00:00','1995-12-30 00:00:00',3763527,46,'Bob','1970-11-20','2029-06-19',-56),
('2027-07-01 00:00:00','1990-08-04 00:00:00',4017394,13,'Charlie','1975-03-04','2007-07-07',-115),
('2015-06-20 00:00:00','1982-09-17 00:00:00',6761827,-54,'David','1974-10-24','2018-09-27',-108),
('2012-09-08 00:00:00','2002-09-02 00:00:00',7072164,-18,'Charlie',NULL,'1988-08-05',49),
('2000-05-26 00:00:00','1999-05-03 00:00:00',7472892,-108,'Charlie','2014-12-11','1971-11-15',-52),
('1987-05-12 00:00:00','2034-07-28 00:00:00',8326028,-111,'Bob','1979-01-26','2024-05-08',-108),
('1977-04-09 00:00:00','1990-12-17 00:00:00',9489981,79,'Charlie','1987-08-29','1993-07-09',-58),
('1985-06-15 00:00:00','1982-10-02 00:00:00',13082784,15,'Bob','2016-01-09','1991-12-23',-107),
('2029-02-24 00:00:00','2000-01-12 00:00:00',13934230,26,'Alice','1971-03-02',NULL,96),
('2027-05-13 00:00:00','2005-06-22 00:00:00',16156967,62,'Charlie','1994-09-16','2024-02-12',-58);
```

**reproduce**

```sql
update tbl_2 set tbl_2.col_11 = '2012-12-11' ,tbl_2.col_14 = 'Charlie' where tbl_2.col_13 in ( select col_1 from tbl_1 where not( tbl_2.col_16 between '2010-09-09' and '2006-09-26' ) and IsNull( tbl_2.col_13 ) ) and tbl_2.col_13 between -50 and -12;
```

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

Execute sucess. Since MySQL will execute success.

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

return error.

```sql
> update tbl_2 set tbl_2.col_11 = '2012-12-11' ,tbl_2.col_14 = 'Charlie' where tbl_2.col_13 in ( select col_1 from tbl_1 where not( tbl_2.col_16 between '2010-09-09' and '2006-09-26' ) and IsNull( tbl_2.col_13 ) ) and tbl_2.col_13 between -50 and -12;
(1292, "Truncated incorrect DOUBLE value: 'wvAGg7BHlv(u'")

```

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

```sql
***************************[ 1. row ]***************************
tidb_version() | Release Version: v6.1.0-alpha-420-g180ae24234
Edition: Community
Git Commit Hash: 180ae2423459f94d4619a5e950308753c19461eb
Git Branch: master
UTC Build Time: 2022-05-17 07:23:20
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.