pingcap / pingcap/tidb

replace into gets "writing inconsistent data in table"

Open
#49,567 0 comments 0 reactions 0 assignees View on GitHub
affects-8.1 affects-8.5 fuzz/randomtest severity/major sig/transaction type/bug
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)

``` SQL
CREATE TABLE `te5efd772` (
`col_1` json DEFAULT NULL,
`col_2` text COLLATE utf8_general_ci NOT NULL,
`col_3` char(103) COLLATE utf8_general_ci NOT NULL,
KEY `idx_1` (`col_2`(5),(cast(`col_1` as signed array)),`col_3`),
PRIMARY KEY (`col_2`(2),`col_3`(5)) /*T![clustered_index] NONCLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

replace into te5efd772 set col_1 = "[-1923354066,-978898971,-1657259160,1219285962,589075408,-260980375,-504456391,-731499117,1723097519,923261224,-539847753,-997158988,-1868580778,-1618083845,-1053800644,1054521069,709109552,962039824,655367655,-1356171635,1066736982,1941761941,-38063505,-336958195,-520084813,597726072,1240871010,-2102722588,-844629644,-1067309084,17510181,1802656260]", col_2 = "@93YF0ywhP~W*dOpO", col_3 = "ypgjG+x!YDe";
```

### 2. What did you expect to see? (Required)
No error
### 3. What did you see instead (Required)
``` SQL
mysql> replace into te5efd772 set col_1 = "[-1923354066,-978898971,-1657259160,1219285962,589075408,-260980375,-504456391,-731499117,1723097519,923261224,-539847753,-997158988,-1868580778,-1618083845,-1053800644,1054521069,709109552,962039824,655367655,-1356171635,1066736982,1941761941,-38063505,-336958195,-520084813,597726072,1240871010,-2102722588,-844629644,-1067309084,17510181,1802656260]", col_2 = "@93YF0ywhP~W*dOpO", col_3 = "ypgjG+x!YDe";
ERROR 8140 (HY000): writing inconsistent data in table: te5efd772, index: idx_1, col: _V$_idx_1_1, indexed-value:{KindMysqlJSON } != record-value:{KindMysqlJSON [-1923354066, -978898971, -1657259160, 1219285962, 589075408, -260980375, -504456391, -731499117, 1723097519, 923261224, -539847753, -997158988, -1868580778, -1618083845, -1053800644, 1054521069, 709109552, 962039824, 655367655, -1356171635, 1066736982, 1941761941, -38063505, -336958195, -520084813, 597726072, 1240871010, -2102722588, -844629644, -1067309084, 17510181
```
### 4. What is your TiDB version? (Required)
nightly-a7260ff598ce0e7c0a77367e84ec265f91b8073e

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.