pingcap / pingcap/tidb

UPDATE statement with CAST() reports an error in the transaction

Open
#39,972 1 comment 0 reactions 0 assignees View on GitHub
may-affects-4.0 may-affects-5.0 may-affects-5.1 may-affects-5.2 may-affects-5.3 may-affects-5.4 may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 severity/moderate sig/execution 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
/* init */ CREATE TABLE t(c0 INT);
/* init */ INSERT IGNORE INTO t VALUES (2);

/* tx */ BEGIN;
/* tx */ DELETE FROM t WHERE TRUE;
/* tx */ UPDATE t SET c0=0 WHERE (CAST('a' AS SIGNED)); -- report an error
/* tx */ COMMIT;
```

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

UPDATE statement does not report error:
```sql
tidb> DELETE FROM t WHERE TRUE;
Query OK, 1 row affected (0.01 sec)

tidb> UPDATE t SET c0=0 WHERE (CAST('a' AS SIGNED));
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
```

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

Executing UPDATE statement after the DELETE statement in tx reports an error:
```sql
tidb> UPDATE t SET c0=0 WHERE (CAST('a' AS SIGNED));
ERROR 1292 (22007): Truncated incorrect INTEGER value: 'a'
```

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

```sql
Release Version: v6.4.0
Edition: Community
Git Commit Hash: cf36a9ce2fe1039db3cf3444d51930b887df18a1
Git Branch: heads/refs/tags/v6.4.0
UTC Build Time: 2022-11-13 05:25:30
GoVersion: go1.19.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
```

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.