Incorrect query result may caused by number comparison.
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
Consider the following statements.
In theory, query1 and query2 should return the same result. However, query1 return nothing while query2 return 0.
```
CREATE TABLE t0(c0 TEXT(119));
INSERT INTO t0 VALUES ('?');
CREATE VIEW v4(c0) AS SELECT CAST(t0.c0 AS DECIMAL) FROM t0;
SELECT v4.c0 AS _c0 FROM v4 WHERE (v4.c0 = COALESCE(-164345996, v4.c0, CASE v4.c0 WHEN -546905304 THEN 'e' ELSE 1760598647 END)) LIKE v4.c0; --query1
Empty set, 3 warnings (0.01 sec)
SELECT _c0 FROM (SELECT v4.c0 AS _c0, (v4.c0 = COALESCE(-164345996, v4.c0, CASE v4.c0 WHEN -546905304 THEN 'e' ELSE 1760598647 END)) LIKE v4.c0 AS flag FROM v4) AS t WHERE flag = 1; --query2
+------+
| _c0 |
+------+
| 0 |
+------+
1 row in set, 3 warnings (0.00 sec)
```
### 2. What is your TiDB version? (Required)
v7.6.0, v5.3.2
Contributor guide
Research direction
Start by running the supplied CREATE TABLE, view, and two SELECT statements against TiDB v7.6.0 and v5.3.2, then compare their results and warnings. Investigate the number comparison, CAST, COALESCE, CASE, and LIKE expressions involved. Done means the equivalent queries produce consistent results, with a regression test covering the reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100