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

Result of function ROUND is different from MySQL #11205

Closed
SunRunAway opened this issue Jul 11, 2019 · 4 comments
Closed

Result of function ROUND is different from MySQL #11205

SunRunAway opened this issue Jul 11, 2019 · 4 comments
Labels
component/expression help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility wontfix This issue will not be fixed.

Comments

@SunRunAway
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
SELECT ROUND( 'hello', -7787 ) ;
  1. What did you expect to see?
mysql> SELECT ROUND( 'hello', -7787 ) ;
+-------------------------+
| ROUND( 'hello', -7787 ) |
+-------------------------+
|                     NaN |
+-------------------------+
1 row in set, 1 warning (0.00 sec)
  1. What did you see instead?
mysql> SELECT ROUND( 'hello', -7787 ) ;
+-------------------------+
| ROUND( 'hello', -7787 ) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+-------------------------------------------+
| Level   | Code | Message                                   |
+---------+------+-------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'hello' |
+---------+------+-------------------------------------------+
1 row in set (0.00 sec)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
    8c20289
@SunRunAway SunRunAway added type/bug The issue is confirmed as a bug. component/expression and removed component/expression labels Jul 11, 2019
@SunRunAway SunRunAway added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. and removed help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Jul 12, 2019
@wjhuang2016
Copy link
Member

In MySQL 8.0.15:

mysql> SELECT ROUND( 'hello', -7787 ) ;
+-------------------------+
| ROUND( 'hello', -7787 ) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+-------------------------------------------+
| Level   | Code | Message                                   |
+---------+------+-------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'hello' |
+---------+------+-------------------------------------------+
1 row in set (0.00 sec)

@ghost ghost added type/compatibility and removed type/bug The issue is confirmed as a bug. labels Jul 14, 2020
@ghost
Copy link

ghost commented Jul 14, 2020

It looks like TiDB uses the MySQL 8.0 behavior here (with correct error code and message). Functions are not explicitly documented in the docs yet, but until it is known to affect a user this should be categorized as a compatibility issue and not a bug.

It is not expected to specify decimals (i.e. ROUND(number, decimals)) as a negative value.

@wjhuang2016
Copy link
Member

It looks like TiDB uses the MySQL 8.0 behavior here (with correct error code and message). Functions are not explicitly documented in the docs yet, but until it is known to affect a user this should be categorized as a compatibility issue and not a bug.

It is not expected to specify decimals (i.e. ROUND(number, decimals)) as a negative value.

@SunRunAway @nullnotnil Can we close this issue?

@ghost ghost added the wontfix This issue will not be fixed. label Jul 15, 2020
@ghost
Copy link

ghost commented Jul 15, 2020

Yes, I think it is acceptable to close as "won't fix". We can review if there are requests to the counter.

@ghost ghost closed this as completed Jul 15, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility wontfix This issue will not be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants