Incorrect query result
sayJason opened this issue · 3 comments
sayJason commented
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
CREATE TABLE t1 (c1 INT);
INSERT INTO t1 VALUES (1);
SELECT c1 FROM t1 WHERE c1 REGEXP(IFNULL(c1, 0.0)); -- actual: {1}, expected: {}
2. What did you expect to see? (Required)
SELECT returns nothing.
3. What did you see instead (Required)
SELECT returns 1.
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
bb7133 commented
@jebter I believe the root cause is about the expression evaluation of REGEXP(IFNULL(c1, 0.0));
, reassign it to "sig/execution".
SeaRise commented
use test;
CREATE TABLE t1 (c1 INT);
INSERT INTO t1 VALUES (1);
## mysql
SELECT concat(IFNULL(c1, 0.0)) from t1;
+-----------------------------+
| concat(IFNULL(c1, 0.0), '') |
+-----------------------------+
| 1.0 |
+-----------------------------+
SELECT concat(IFNULL(c1, 0)) from t1;
+---------------------------+
| concat(IFNULL(c1, 0), '') |
+---------------------------+
| 1 |
+---------------------------+
## tidb
SELECT concat(IFNULL(c1, 0.0)) from t1;
+-----------------------------+
| concat(IFNULL(c1, 0.0), '') |
+-----------------------------+
| 1 |
+-----------------------------+
SELECT concat(IFNULL(c1, 0)) from t1;
+---------------------------+
| concat(IFNULL(c1, 0), '') |
+---------------------------+
| 1 |
+---------------------------+
The difference is the result of casting a decimal as a string.