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

A forbidden cast happened in UPDATE statement #32556

Open
where2me opened this issue Feb 23, 2022 · 1 comment
Open

A forbidden cast happened in UPDATE statement #32556

where2me opened this issue Feb 23, 2022 · 1 comment
Labels
affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 affects-8.1 may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. severity/major sig/execution SIG execution type/bug This issue is a bug. type/compatibility

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 '1.0' << 1;

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

The UPDATE statement should fail, because cast '1.0' into an INTEGER is not allowable in MySQL.

3. What did you see instead (Required)

UPDATE succeeded.

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 23, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. labels Feb 23, 2022
@aytrack
Copy link
Contributor

aytrack commented Feb 23, 2022

tidb without tikv will report error

MySQL root@127.0.0.1:test> DROP TABLE IF EXISTS t0;
                       ->  CREATE TABLE t0 (c0 INT);
                       ->  INSERT INTO t0 VALUES(1);
                       ->  UPDATE t0 SET c0 = 2 WHERE '1.0' << 1;
Query OK, 0 rows affected
Time: 0.002s

Query OK, 0 rows affected
Time: 0.012s

Query OK, 1 row affected
Time: 0.001s
(1292, "Truncated incorrect INTEGER value: '1.0'")

a cluster with tikv will execute success

MySQL root@127.0.0.1:test> DROP TABLE IF EXISTS t0;
                       ->  CREATE TABLE t0 (c0 INT);
                       ->  INSERT INTO t0 VALUES(1);
                       ->  UPDATE t0 SET c0 = 2 WHERE '1.0' << 1;
Query OK, 0 rows affected
Time: 0.002s

Query OK, 0 rows affected
Time: 0.126s

Query OK, 1 row affected
Time: 0.005s

Query OK, 1 row affected
Time: 0.002s
MySQL root@127.0.0.1:test> select * from t0;
+----+
| c0 |
+----+
| 2  |
+----+
MySQL root@127.0.0.1:test> explain UPDATE t0 SET c0 = 2 WHERE '1.0' << 1;
                       ->
+-----------------------+----------+-----------+---------------+---------------------------------------------+
| id                    | estRows  | task      | access object | operator info                               |
+-----------------------+----------+-----------+---------------+---------------------------------------------+
| Update_4              | N/A      | root      |               | N/A                                         |
| └─TableReader_8       | 8000.00  | root      |               | data:Selection_7                            |
|   └─Selection_7       | 8000.00  | cop[tikv] |               | leftshift(cast("1.0", bigint(3) BINARY), 1) |
|     └─TableFullScan_6 | 10000.00 | cop[tikv] | table:t0      | keep order:false, stats:pseudo              |
+-----------------------+----------+-----------+---------------+---------------------------------------------+
MySQL root@127.0.0.1:test> select '1.0' << 1;
+------------+
| '1.0' << 1 |
+------------+
| 2          |
+------------+

will success on both tidb and mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 affects-8.1 may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. severity/major sig/execution SIG execution type/bug This issue is a bug. type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants