Details
Description
I'm not sure this is a bug or not, because there is no such configuration like auto round points.
I thought it connect to div_precision_increment. but seems not
all test configuration is same
MariaDB [(none)]> show variables like '%prec%';
|
+-------------------------+-------+
|
| Variable_name | Value |
|
+-------------------------+-------+
|
| div_precision_increment | 4 |
|
+-------------------------+-------+
|
MariaDB 10.3.24 && 10.4.14
MariaDB [(none)]> select (55/23244*1000);
|
+-----------------+
|
| (55/23244*1000) |
|
+-----------------+
|
| 2.4000 |
|
+-----------------+
|
|
select cast( (55/23244*1000) as decimal(5,4));
|
+----------------------------------------+
|
| cast( (55/23244*1000) as decimal(5,4)) |
|
+----------------------------------------+
|
| 2.4000 |
|
+----------------------------------------+
|
|
MariaDB [(none)]> set div_precision_increment=8;
|
Query OK, 0 rows affected (0.000 sec)
|
|
MariaDB [(none)]> select cast( (55/23244*1000) as decimal(5,4));
|
+----------------------------------------+
|
| cast( (55/23244*1000) as decimal(5,4)) |
|
+----------------------------------------+
|
| 2.3662 |
|
+----------------------------------------+
|
|
MariaDB [(none)]> select (55/23244*1000);
|
+-----------------+
|
| (55/23244*1000) |
|
+-----------------+
|
| 2.36620000 |
|
+-----------------+
|
MariaDB 5.5 ~ 10.3.22
MariaDB [(none)]> show variables like '%prec%';
|
+-------------------------+-------+
|
| Variable_name | Value |
|
+-------------------------+-------+
|
| div_precision_increment | 4 |
|
+-------------------------+-------+
|
|
MariaDB [(none)]> select (55/23244*1000);
|
+-----------------+
|
| (55/23244*1000) |
|
+-----------------+
|
| 2.3662 |
|
+-----------------+
|
|
MariaDB [(none)]> select cast( (55/23244*1000) as decimal(5,4));
|
+----------------------------------------+
|
| cast( (55/23244*1000) as decimal(5,4)) |
|
+----------------------------------------+
|
| 2.3662 |
|
+----------------------------------------+
|
Attachments
Issue Links
- duplicates
-
MDEV-23762 Strange type-inference/rounding problem since >10.3.23
-
- Closed
-
-
MDEV-23953 Decimal precision
-
- Closed
-
- is caused by
-
MDEV-19232 Floating point precision / value comparison problem
-
- Closed
-
- relates to
-
MDEV-23712 Clarify the description of div_precision_increment
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Description |
I'm not sure this is a bug or not, because there is no such configuration like auto round points.
I thought it connect to div_precision_increment. but seems not all test configuration is same MariaDB [(none)]> show variables like '%prec%'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | div_precision_increment | 4 | +-------------------------+-------+ h2. MariaDB 10.3.24 && 10.4.14 MariaDB [(none)]> select (55/23244*1000); +-----------------+ | (55/23244*1000) | +-----------------+ | 2.4000 | +-----------------+ select cast( (55/23244*1000) as decimal(5,4)); +----------------------------------------+ | cast( (55/23244*1000) as decimal(5,4)) | +----------------------------------------+ | 2.4000 | +----------------------------------------+ MariaDB [(none)]> set div_precision_increment=8; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> select cast( (55/23244*1000) as decimal(5,4)); +----------------------------------------+ | cast( (55/23244*1000) as decimal(5,4)) | +----------------------------------------+ | 2.3662 | +----------------------------------------+ MariaDB [(none)]> select (55/23244*1000); +-----------------+ | (55/23244*1000) | +-----------------+ | 2.36620000 | +-----------------+ h2. MariaDB 5.5 ~ 10.3.22 MariaDB [(none)]> show variables like '%prec%'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | div_precision_increment | 4 | +-------------------------+-------+ MariaDB [(none)]> select (55/23244*1000); +-----------------+ | (55/23244*1000) | +-----------------+ | 2.3662 | +-----------------+ MariaDB [(none)]> select cast( (55/23244*1000) as decimal(5,4)); +----------------------------------------+ | cast( (55/23244*1000) as decimal(5,4)) | +----------------------------------------+ | 2.3662 | +----------------------------------------+ |
I'm not sure this is a bug or not, because there is no such configuration like auto round points.
I thought it connect to div_precision_increment. but seems not all test configuration is same {noformat} MariaDB [(none)]> show variables like '%prec%'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | div_precision_increment | 4 | +-------------------------+-------+ {noformat} h2. MariaDB 10.3.24 && 10.4.14 {noformat} MariaDB [(none)]> select (55/23244*1000); +-----------------+ | (55/23244*1000) | +-----------------+ | 2.4000 | +-----------------+ select cast( (55/23244*1000) as decimal(5,4)); +----------------------------------------+ | cast( (55/23244*1000) as decimal(5,4)) | +----------------------------------------+ | 2.4000 | +----------------------------------------+ MariaDB [(none)]> set div_precision_increment=8; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> select cast( (55/23244*1000) as decimal(5,4)); +----------------------------------------+ | cast( (55/23244*1000) as decimal(5,4)) | +----------------------------------------+ | 2.3662 | +----------------------------------------+ MariaDB [(none)]> select (55/23244*1000); +-----------------+ | (55/23244*1000) | +-----------------+ | 2.36620000 | +-----------------+ {noformat} h2. MariaDB 5.5 ~ 10.3.22 {noformat} MariaDB [(none)]> show variables like '%prec%'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | div_precision_increment | 4 | +-------------------------+-------+ MariaDB [(none)]> select (55/23244*1000); +-----------------+ | (55/23244*1000) | +-----------------+ | 2.3662 | +-----------------+ MariaDB [(none)]> select cast( (55/23244*1000) as decimal(5,4)); +----------------------------------------+ | cast( (55/23244*1000) as decimal(5,4)) | +----------------------------------------+ | 2.3662 | +----------------------------------------+ {noformat} |
Fix Version/s | N/A [ 14700 ] | |
Assignee | Sergei Golubchik [ serg ] | |
Resolution | Not a Bug [ 6 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Link |
This issue is caused by |
Link |
This issue relates to |
Resolution | Not a Bug [ 6 ] | |
Status | Closed [ 6 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | Open [ 1 ] |
Status | Open [ 1 ] | Confirmed [ 10101 ] |
Fix Version/s | 10.3 [ 22126 ] | |
Fix Version/s | 10.4 [ 22408 ] | |
Fix Version/s | 10.5 [ 23123 ] | |
Fix Version/s | N/A [ 14700 ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
Link |
This issue duplicates |
Link |
This issue is duplicated by |
Link |
This issue duplicates |
Link |
This issue is duplicated by |
Status | Confirmed [ 10101 ] | In Progress [ 3 ] |
issue.field.resolutiondate | 2020-10-29 08:33:35.0 | 2020-10-29 08:33:35.225 |
Fix Version/s | 10.1.48 [ 25108 ] | |
Fix Version/s | 10.2.35 [ 25022 ] | |
Fix Version/s | 10.3.26 [ 25021 ] | |
Fix Version/s | 10.4.16 [ 25020 ] | |
Fix Version/s | 10.5.7 [ 25019 ] | |
Fix Version/s | 10.3 [ 22126 ] | |
Fix Version/s | 10.4 [ 22408 ] | |
Fix Version/s | 10.5 [ 23123 ] | |
Resolution | Fixed [ 1 ] | |
Status | In Progress [ 3 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 113339 ] | MariaDB v4 [ 158355 ] |
This doesn't look like a bug. The intermediate result is
MariaDB [(none)]> select 55/23244;
+----------+
| 55/23244 |
+----------+
| 0.0024 |
+----------+
That is, both argument have zero digits after the dot, plus div_precision_increment=4, so you get 4 digits after the dot. Looks correct.
Earlier versions ignored div_precision_increment in intermediate calculations and this was a bug, as the result was unpredictable, depending on how exactly the optimizer would decide to evaluate the query and where it (or you) would decide to store the intermediate results.