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

Data truncation error occurs in update statement. #57650

Open
yanghy233 opened this issue Nov 23, 2024 · 4 comments
Open

Data truncation error occurs in update statement. #57650

yanghy233 opened this issue Nov 23, 2024 · 4 comments
Labels
affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.4 severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@yanghy233
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. schema.
create table t1(c1 CHAR(16));
insert into t1 values('G');
  1. sql statement.
UPDATE t1 SET c1="b+F6rUuv?" WHERE (("-1433326829") LIKE (1909913287)) IN ((0), ((1.790079046E9)IS FALSE), (c1), (-1512320610));

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

MySQL and TIDB have different execution results in the above case.

The normal result in MySQL 8:

mysql> UPDATE t1 SET c1="b+F6rUuv?" WHERE (("-1433326829") LIKE (1909913287)) IN ((0), ((1.790079046E9)IS FALSE), (c1), (-1512320610));
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from t1;
+-----------+
| c1        |
+-----------+
| b+F6rUuv? |
+-----------+
1 row in set (0.00 sec)

TiDB should also return the same result, but failed.

3. What did you see instead (Required)

In TiDB v8.1.1:

MySQL [test]> UPDATE t1 SET c1="b+F6rUuv?" WHERE (("-1433326829") LIKE (1909913287)) IN ((0), ((1.790079046E9)IS FALSE), (c1), (-1512320610));
ERROR 1292 (22007): Truncated incorrect INTEGER value: 'G'

Afterwards, I wondered if the error was caused by predicate, so I constructed the same predicate using a select statement.

The following result is correct:

MySQL [test]> select * from t1 WHERE (("-1433326829") LIKE (1909913287)) IN ((0), ((1.790079046E9)IS FALSE), (c1), (-1512320610));
+------+
| c1   |
+------+
| G    |
+------+
1 row in set, 1 warning (0.02 sec)

The predicate is the same, but the results of the select and update statements are different in TiDB.

4. What is your TiDB version? (Required)

Tidb v8.1.1

@yanghy233 yanghy233 added the type/bug The issue is confirmed as a bug. label Nov 23, 2024
@yanghy233
Copy link
Author

/label affects-8.1

@ti-chi-bot ti-chi-bot bot added the affects-8.1 This bug affects the 8.1.x(LTS) versions. label Nov 23, 2024
@yanghy233
Copy link
Author

Also affects TiDB v8.4
/label affects-8.4

@yibin87
Copy link
Contributor

yibin87 commented Nov 27, 2024

The select statement executes with a warning:
mysql> show warnings;
+---------+------+-----------------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------------+
| Warning | 1292 | evaluation failed: Truncated incorrect INTEGER value: 'G' |
+---------+------+-----------------------------------------------------------+
1 row in set (0.00 sec)
That's the reason why update statement failed. For dml statement, in strict sql mode, any warnings will fail the whole statement execution.
MySQL doesn't report any warnings or errors for this case. However, tidb's behavior seems reasonable for this case.

@yibin87
Copy link
Contributor

yibin87 commented Nov 27, 2024

/severity moderate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.4 severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants