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

Confusing behavior happened in UPDATE statement #32617

Open
where2me opened this issue Feb 24, 2022 · 2 comments
Open

Confusing behavior happened in UPDATE statement #32617

where2me opened this issue Feb 24, 2022 · 2 comments
Labels
severity/moderate sig/transaction SIG:Transaction type/bug This issue is a bug.

Comments

@where2me
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

DROP TABLE IF EXISTS t0;
CREATE TABLE t0(c0 INT);
INSERT INTO t0 VALUES(1);
UPDATE t0 SET c0 = 2 WHERE CAST(CAST(0.4 AS CHAR)^1 AS CHAR);

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

I think there is a data truncate error in UPDATE statement, and UPDATE should fail.

3. What did you see instead (Required)

UPDATE succeeded without throwing an error.

mysql> UPDATE t0 SET c0 = 2 WHERE CAST(CAST(0.4 AS CHAR)^1 AS CHAR);
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

4. What is your TiDB version? (Required)

mysql> SELECT tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()

                                                                   |

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.4.0
Edition: Community
Git Commit Hash: 55f3b24
Git Branch: heads/refs/tags/v5.4.0
UTC Build Time: 2022-01-25 08:39:26
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

@where2me where2me added the type/bug This issue is a bug. label Feb 24, 2022
@aytrack
Copy link
Contributor

aytrack commented Feb 28, 2022

mysql 8.0.28 and tidb with tikv hava the same result, tidb use unistore will report a truncate error.

mysql root@172.16.4.131:test> select version();
+-----------+
| version() |
+-----------+
| 8.0.28    |
+-----------+
1 row in set
Time: 0.009s
mysql root@172.16.4.131:test> UPDATE t0 SET c0 = 2 WHERE CAST(CAST(0.4 AS CHAR)^1 AS CHAR);
Query OK, 0 rows affected
Time: 0.003s
mysql root@172.16.4.131:test> select * from t0;
+----+
| c0 |
+----+
| 2  |
+----+

tidb with tikv

MySQL root@127.0.0.1:test> UPDATE t0 SET c0 = 2 WHERE CAST(CAST(0.4 AS CHAR)^1 AS CHAR);
Query OK, 0 rows affected
Time: 0.002s
MySQL root@127.0.0.1:test> select * from t0;
+----+
| c0 |
+----+
| 2  |
+----+

tidb without tikv

MySQL root@127.0.0.1:test>  UPDATE t0 SET c0 = 2 WHERE CAST(CAST(0.4 AS CHAR)^1 AS CHAR);
                       ->
(1292, "Truncated incorrect INTEGER value: '0.4'")
MySQL root@127.0.0.1:test>

@aytrack
Copy link
Contributor

aytrack commented Feb 28, 2022

the expression of both tidb and mysql have the same results.

MySQL root@172.16.4.131:test> select CAST(CAST(0.4 AS CHAR)^1 AS CHAR);
+-----------------------------------+
| CAST(CAST(0.4 AS CHAR)^1 AS CHAR) |
+-----------------------------------+
| 1                                 |
+-----------------------------------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/transaction SIG:Transaction type/bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants