Skip to content

DEGREES() does not check for overflow, allowing production of NaN & Infinity #28488

Open
@kennytm

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

select degrees(1e308);

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

ERROR 1690 (22003): DOUBLE value is out of range in 'degrees(1e308)'

3. What did you see instead (Required)

mysql> select degrees(1e308);
+----------------+
| degrees(1e308) |
+----------------+
|              0 |
+----------------+
1 row in set (0.07 sec)

Note that the result is not a zero, but an actual Infinity.

mysql> select degrees(1e308) - 0;
ERROR 1690 (22003): DOUBLE value is out of range in '(+Inf - 0)'

which we can proceed to produce an NaN

mysql> select degrees(1e308) % 1 - 0;
ERROR 1690 (22003): DOUBLE value is out of range in '(NaN - 0)'

4. What is your TiDB version? (Required)

Release Version: v5.2.0
Edition: Community
Git Commit Hash: 05d2210647d6a1503a8d772477e43b14a024f609
Git Branch: heads/refs/tags/v5.2.0
UTC Build Time: 2021-08-27 05:57:10
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

&&

Release Version: v5.3.0-alpha-248-g091ae3bde
Edition: Community
Git Commit Hash: 091ae3bde0a54b126f2f2ed275dd20b0986d74d3
Git Branch: master
UTC Build Time: 2021-09-30 02:39:24
GoVersion: go1.17
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

Metadata

Assignees

No one assigned

    Labels

    affects-4.0This bug affects 4.0.x versions.affects-5.0This bug affects 5.0.x versions.affects-5.1This bug affects 5.1.x versions.affects-5.2This bug affects 5.2.x versions.affects-5.3This bug affects 5.3.x versions.affects-5.4This bug affects the 5.4.x(LTS) versions.affects-6.0affects-6.1This bug affects the 6.1.x(LTS) versions.component/executorseverity/minorsig/executionSIG executiontype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions