Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precision controll on Pi() seems not work as mariadb does #26384

Open
hnes opened this issue Jul 20, 2021 · 1 comment
Open

Precision controll on Pi() seems not work as mariadb does #26384

hnes opened this issue Jul 20, 2021 · 1 comment
Labels
compatibility-mariadb MariaDB Compatibility compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug. type/compatibility

Comments

@hnes
Copy link
Contributor

hnes commented Jul 20, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

select PI(), PI()+0.000000000000000000;
select PI(), PI()+0.0000000000000;
select PI(), PI()+0.0000000;

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

MariaDB [testdb]> select version();
+----------------+
| version()      |
+----------------+
| 5.5.68-MariaDB |
+----------------+
1 row in set (0.00 sec)

MariaDB [testdb]> select PI(), PI()+0.000000000000000000;
+----------+---------------------------+
| PI()     | PI()+0.000000000000000000 |
+----------+---------------------------+
| 3.141593 |      3.141592653589793000 |
+----------+---------------------------+
1 row in set (0.00 sec)

MariaDB [testdb]> select PI(), PI()+0.0000000000000;
+----------+----------------------+
| PI()     | PI()+0.0000000000000 |
+----------+----------------------+
| 3.141593 |      3.1415926535898 |
+----------+----------------------+
1 row in set (0.00 sec)

MariaDB [testdb]> select PI(), PI()+0.0000000;
+----------+----------------+
| PI()     | PI()+0.0000000 |
+----------+----------------+
| 3.141593 |      3.1415927 |
+----------+----------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

MySQL [testdb]> select PI(), PI()+0.000000000000000000;
+----------+---------------------------+
| PI()     | PI()+0.000000000000000000 |
+----------+---------------------------+
| 3.141593 |         3.141592653589793 |
+----------+---------------------------+
1 row in set (0.00 sec)

MySQL [testdb]> select PI(), PI()+0.0000000000000;
+----------+----------------------+
| PI()     | PI()+0.0000000000000 |
+----------+----------------------+
| 3.141593 |    3.141592653589793 |
+----------+----------------------+
1 row in set (0.00 sec)

MySQL [testdb]> select PI(), PI()+0.0000000;
+----------+-------------------+
| PI()     | PI()+0.0000000    |
+----------+-------------------+
| 3.141593 | 3.141592653589793 |
+----------+-------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

MySQL [testdb]> SELECT tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                       |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.1.0
Edition: Community
Git Commit Hash: 8acd5c88471cb7b4d4c4a8ed73b4d53d6833f13e
Git Branch: heads/refs/tags/v5.1.0
UTC Build Time: 2021-06-24 07:10:32
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@hnes hnes added the type/bug The issue is confirmed as a bug. label Jul 20, 2021
@dveeden
Copy link
Contributor

dveeden commented Nov 11, 2024

I don't think one should rely on this behavior and instead use ROUND()/FLOOR() instead.

Comparing this with MySQL 9.1.0:

mysql-9.1.0> select PI(), PI()+0.000000000000000000;
+----------+---------------------------+
| PI()     | PI()+0.000000000000000000 |
+----------+---------------------------+
| 3.141593 |      3.141592653589793000 |
+----------+---------------------------+
1 row in set (0.00 sec)

mysql-9.1.0> select PI(), PI()+0.0000000000000;
+----------+----------------------+
| PI()     | PI()+0.0000000000000 |
+----------+----------------------+
| 3.141593 |      3.1415926535898 |
+----------+----------------------+
1 row in set (0.00 sec)

mysql-9.1.0> select PI(), PI()+0.0000000;
+----------+----------------+
| PI()     | PI()+0.0000000 |
+----------+----------------+
| 3.141593 |      3.1415927 |
+----------+----------------+
1 row in set (0.01 sec)

mysql-9.1.0> SELECT ROUND(PI(),5);
+---------------+
| ROUND(PI(),5) |
+---------------+
|       3.14159 |
+---------------+
1 row in set (0.00 sec)

@dveeden dveeden added compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) type/compatibility compatibility-mariadb MariaDB Compatibility labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility-mariadb MariaDB Compatibility compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug. type/compatibility
Projects
None yet
Development

No branches or pull requests

3 participants