pingcap / pingcap/tidb

execution: wrong result when comparing float values in some cases

Open
#40,488 3 comments 0 reactions 0 assignees View on GitHub
affects-5.0 affects-5.1 affects-5.2 affects-5.3 affects-5.4 affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 may-affects-4.0 may-affects-5.4 may-affects-6.1 may-affects-6.5 severity/moderate sig/execution type/bug
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)

```
create table t (a float(5, 2));
insert into t values (13.33);
select * from t where a=13.33;
```

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

```
mysql> select * from t where a=13.33;
+-------+
| a |
+-------+
| 13.33 |
+-------+
1 row in set (0.00 sec)
```

### 3. What did you see instead (Required)

```
mysql> select * from t where a=13.33;
Empty set (0.00 sec)
```

### 4. What is your TiDB version? (Required)

```
mysql> select version();
+------------------------------------------------+
| version() |
+------------------------------------------------+
| 5.7.25-TiDB-v6.6.0-alpha-186-gbb314af0c4-dirty |
+------------------------------------------------+
1 row in set (0.00 sec)
```

Seems like it's a precision problem:
![166e9fd8-f4b5-4865-8207-bc937444110b](https://user-images.githubusercontent.com/7499936/211713080-7f1ae623-29ff-46a4-b20a-15e9e3a5e03b.jpeg)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.