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

Incorrect data conversion #44219

Open
sayJason opened this issue May 27, 2023 · 2 comments
Open

Incorrect data conversion #44219

sayJason opened this issue May 27, 2023 · 2 comments
Labels
severity/moderate sig/execution SIG execution type/bug This issue is a bug.

Comments

@sayJason
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE t1 (c1 INT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (0);
SELECT c1 > - '7' FROM t1;

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

SELECT returns 1

3. What did you see instead (Required)

SELECT returns 0

4. What is your TiDB version? (Required)

Release Version: v7.0.0
Edition: Community
Git Commit Hash: 7376954
Git Branch: heads/refs/tags/v7.0.0
UTC Build Time: 2023-03-29 13:32:13
GoVersion: go1.20.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv

@sayJason sayJason added the type/bug This issue is a bug. label May 27, 2023
@sayJason
Copy link
Author

The root cause may be that -'7' is erroneously converted into 0.

mysql> EXPLAIN SELECT c1 > - '7' FROM t1;
+-------------------------+---------+-----------+---------------+--------------------------------+
| id                      | estRows | task      | access object | operator info                  |
+-------------------------+---------+-----------+---------------+--------------------------------+
| Projection_3            | 1.00    | root      |               | 0->Column#3                    |
| └─TableReader_5         | 1.00    | root      |               | data:TableFullScan_4           |
|   └─TableFullScan_4     | 1.00    | cop[tikv] | table:t1      | keep order:false, stats:pseudo |
+-------------------------+---------+-----------+---------------+--------------------------------+
3 rows in set (0.00 sec)

@seiya-annie
Copy link

in mysql8:

mysql> SELECT c1 > - '7' FROM t1;
+------------+
| c1 > - '7' |
+------------+
|          1 |
+------------+
1 row in set (0.00 sec)

@seiya-annie seiya-annie added sig/execution SIG execution and removed sig/execution SIG execution sig/planner SIG: Planner labels May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/execution SIG execution type/bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants