[MDEV-23702] calculating(auto rounding) issue Created: 2020-09-09 Updated: 2020-10-29 Resolved: 2020-10-29 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | 10.3.24, 10.4.14 |
| Fix Version/s: | 10.1.48, 10.2.35, 10.3.26, 10.4.16, 10.5.7 |
| Type: | Bug | Priority: | Critical |
| Reporter: | leo cardia | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
| Comments |
| Comment by Sergei Golubchik [ 2020-09-09 ] | |||||||||||||||||
|
This doesn't look like a bug. The intermediate result is
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. | |||||||||||||||||
| Comment by leo cardia [ 2020-09-09 ] | |||||||||||||||||
|
select (cost/burst)*impression from sometable is actually matter. new versions of mariadb 10.3.24~ and 10.3.22 provides different data. | |||||||||||||||||
| Comment by Sergei Golubchik [ 2020-09-09 ] | |||||||||||||||||
|
that depends on with what precision you want the division to be performed. I don't quite understand, your example above shows that 55/23244*1000 returns 2.36620000 if div_precision_increment = 8. By the way, if you'd calculate cost*impression/burst it will quite possibly avoid the whole issue altogether. | |||||||||||||||||
| Comment by leo cardia [ 2020-09-09 ] | |||||||||||||||||
|
Metric formula is rely on their own recipes. In previous version, div_precision_increment seems control on delivered (final) results only, The newer version seems limits the maximum computational decimal point without any notification on releases notes. It seems serious changes div_precision_increment select 1/7*10000000; when if it's not a bug, then need to notify and change the description. | |||||||||||||||||
| Comment by Sergei Golubchik [ 2020-09-10 ] | |||||||||||||||||
|
This change was intentional, done to fix greenman, could you clarify the description of div_precision_increment and note this change in release notes please? | |||||||||||||||||
| Comment by leo cardia [ 2020-09-11 ] | |||||||||||||||||
|
Hello, This issue raised from computation of column to column in the table. When columnstore with cdc adapters using SBR. it causes different value to store. Also, using SBR with different settings of div_precision_increment causes may lead to store wrong value between replication nodes.
Previously intermediate calculation or integer calculation also treat as Decimal. (select 1/7 seems using div_precision_increment = 8, so you seems this is a bug) But now, integer is treat as integer and following div_precision_increment . Also this setting depends on session & global. I'll create cdc adapter issue and replication issues also (need more inspection on my side) | |||||||||||||||||
| Comment by Brian [ 2020-09-14 ] | |||||||||||||||||
|
is not about using subquery but in this case the query output is affected by a fix for subquery. I think that fix in | |||||||||||||||||
| Comment by Sergei Golubchik [ 2020-09-15 ] | |||||||||||||||||
|
brian.t, it wasn't so much a side effect, but an intended effect. For example, (this is before
This shows that moving part of the expression into a subquery sometimes changes the result. Anyway, we're now trying to come up with a solution that will restore the original higher-precision behavior without bringing back all related bugs. |