pingcap / pingcap/tidb

The value of column double shows incorrect precision

Open
#41,971 0 comments 0 reactions 0 assignees View on GitHub
severity/moderate sig/execution type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
We found that the field type is double, and the inserted data display error is not accurate to the decimal point.
For example:
```
mysql> CREATE TABLE `tab3` (
-> `id` int(11) NOT NULL,
-> `mn4` double(4,2) DEFAULT '11.11',
-> PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Query OK, 0 rows affected (0.14 sec)

mysql> insert into sbtest.tab3 values(1,10);
Query OK, 1 row affected (0.00 sec)

mysql> select * from sbtest.tab3;
+----+-----+
| id | mn4 |
+----+-----+
| 1 | 10 |
+----+-----+
1 row in set (0.00 sec)
```
2. What did you expect to see? (Required)
Same behavior as mysql
```
mysql> select * from sbtest.tab3;
+----+-------+
| id | mn4 |
+----+-------+
| 1 | 10.00 |
+----+-------+
1 row in set (0.00 sec)
```
3. What did you see instead (Required)
```
mysql> select * from sbtest.tab3;
+----+-----+
| id | mn4 |
+----+-----+
| 1 | 10 |
+----+-----+
1 row in set (0.00 sec)
```
4. What is your TiDB version? (Required)
6.5.0

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Reproduce the CREATE TABLE, INSERT, and SELECT example on TiDB and compare its output with MySQL, then locate the existing DOUBLE display or MySQL-compatibility tests. Done means values such as 10 display with the declared two decimal places, with regression coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, mysql, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.