Wrong result when comparing `BOOL UNSIGNED` column with `TAN()` result
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Comparing a floating-point expression with a `BOOL UNSIGNED` column produces a different result than comparing with `CAST(c1 AS SIGNED)`, even though both comparisons should evaluate the same boolean expression.
### 1. Minimal reproduce step (Required)
```sql
DROP DATABASE IF EXISTS testdb;
CREATE DATABASE testdb;
USE testdb;
CREATE TABLE t0(c1 BOOL UNSIGNED NOT NULL);
INSERT INTO t0 VALUES (false), (true);
SELECT
TAN(-0.15),
c1,
TAN(-0.15) < c1,
TAN(-0.15) < CAST(c1 AS SIGNED)
FROM t0;
```
### 2. What did you expect to see? (Required)
`TAN(-0.15) < c1` and `TAN(-0.15) < CAST(c1 AS SIGNED)` should produce the same result for each row, since comparing a float with a BOOL value should be semantically equivalent to comparing the same float with the integer representation of that BOOL value.
Expected result:
```
+-------------------------+----+------------------+-----------------------------------+
| TAN(-0.15) | c1 | TAN(-0.15) < c1 | TAN(-0.15) < CAST(c1 AS SIGNED) |
+-------------------------+----+------------------+-----------------------------------+
| -0.15113521805829508 | 0 | 1 | 1 |
| -0.15113521805829508 | 1 | 1 | 1 |
+-------------------------+----+------------------+-----------------------------------+
```
### 3. What did you see instead (Required)
```sql
mysql> SELECT TAN(-0.15), c1, TAN(-0.15) < c1, TAN(-0.15) < CAST(c1 AS SIGNED) FROM t0;
+-------------------------+----+------------------+-----------------------------------+
| TAN(-0.15) | c1 | TAN(-0.15) < c1 | TAN(-0.15) < CAST(c1 AS SIGNED) |
+-------------------------+----+------------------+-----------------------------------+
| -0.15113521805829508 | 0 | 0 | 1 |
| -0.15113521805829508 | 1 | 0 | 1 |
+-------------------------+----+------------------+-----------------------------------+
```
`TAN(-0.15) < c1` incorrectly returns `0` for both rows, while `TAN(-0.15) < CAST(c1 AS SIGNED)` correctly returns `1`. The comparison with the `BOOL UNSIGNED` column gives wrong results.
### 4. What is your TiDB version? (Required)
```
Release Version: v8.5.6
Edition: Community
Git Commit Hash: ae18096e023780bb56bfce33698abec0d4640d0a
Git Branch: HEAD
UTC Build Time: 2026-06-04 05:49:11
GoVersion: go1.25.8
Race Enabled: false
Check Table Before Drop: false
Store: unistore
```
Contributor guide
Assessment
This issue has not been assessed yet.