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

DELETE statement execution results are inconsistent within and outside a transaction #39976

Open
sayJason opened this issue Dec 15, 2022 · 2 comments
Labels
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. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 severity/minor sig/execution SIG execution sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@sayJason
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

/* init */ CREATE TABLE t(c0 TEXT(284));

/* tx */ BEGIN;
/* tx */ REPLACE INTO t VALUES ('G6y*k]88]');
/* tx */ DELETE FROM t WHERE CAST(TIDB_VERSION() AS DATE); -- report an error
/* tx */ COMMIT;

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

DELETE statement only reports a warning:

tidb> REPLACE INTO t VALUES ('G6y*k]88]');
Query OK, 1 row affected (0.01 sec)

tidb> DELETE FROM t WHERE CAST(TIDB_VERSION() AS DATE);
Query OK, 0 rows affected, 1 warning (0.00 sec)
Warning[1292] evaluation failed: Incorrect datetime value: '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'

3. What did you see instead (Required)

DELETE statement in tx reports an error:

/* tx */ DELETE FROM t WHERE CAST(TIDB_VERSION() AS DATE);
ERROR 1292 (22007): Incorrect datetime value: 'Release Version: v6.4.0
Edition: Community
Git Commit Hash: cf36a9ce2fe1039db3cf3444d51930b887df18a1
Git Branch: heads/refs/tags'

4. What is your TiDB version? (Required)

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
@sayJason sayJason added the type/bug The issue is confirmed as a bug. label Dec 15, 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. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 labels Dec 18, 2022
@zanmato1984
Copy link
Contributor

The difference exists in the error message, lowering severity to minor.

@sayJason
Copy link
Author

sayJason commented Apr 16, 2023

I slightly modify the test case in the description, and obtain weird results.

The modified test case:

/* init */ CREATE TABLE t(c0 TEXT(284));

/* tx */ BEGIN;
/* tx */ REPLACE INTO t VALUES ('1');
/* tx */ DELETE FROM t WHERE CAST(TIDB_VERSION() AS DATE) OR c0; -- report an error
/* tx */ COMMIT;
/* tx */ SELECt * FROM t;

In the modified version, DELETE statement in tx reports an error, and SELECT statement returns a value 1:

/* tx */ DELETE FROM t WHERE CAST(TIDB_VERSION() AS DATE) OR c0; -- report an error
ERROR 1292 (22007): Incorrect datetime value: 'Release Version: v7.0.0
Edition: Community
Git Commit Hash: 7376954cd868dbc44fc3015c9ef89c53749339a7
Git Branch: heads/refs/tags'

/* tx */ COMMIT;
Query OK, 0 rows affected (0.01 sec)

/* tx */ SELECt * FROM t;
+------+
| c0   |
+------+
| 1    |
+------+
1 row in set (0.01 sec)

However, without transaction context, DELETE statement reports a warning and deletes a row, SELECT statement returns an empty set:

tidb> REPLACE INTO t VALUES ('1');
Query OK, 1 row affected (0.00 sec)

tidb> DELETE FROM t WHERE CAST(TIDB_VERSION() AS DATE) OR c0;
Query OK, 1 row affected, 1 warning (0.02 sec)

tidb> SELECt * FROM t;
Empty set (0.00 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 severity/minor sig/execution SIG execution sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

4 participants