Skip to content

Truncate strings when converting to double #7128

@jycor

Description

@jycor

Whenever a string is converted to a double, MySQL truncates the invalid portions of the string, throws a warning, and continues with rest of the operation. In dolt, we throw errors.

Examples:

mysql> select round('123.456abc');
+---------------------+
| round('123.456abc') |
+---------------------+
|                 123 |
+---------------------+
1 row in set, 1 warning (0.0004 sec)
Warning (code 1292): Truncated incorrect DOUBLE value: '123.456abc'
mysql> select sin('123.456abc');
+---------------------+
| sin('123.456abc')   |
+---------------------+
| -0.8039373685728239 |
+---------------------+
1 row in set, 1 warning (0.0004 sec)
Warning (code 1292): Truncated incorrect DOUBLE value: '123.456abc'
mysql> select log('123.456abc');
+-------------------+
| log('123.456abc') |
+-------------------+
| 4.815884817283264 |
+-------------------+
1 row in set, 1 warning (0.0004 sec)
Warning (code 1292): Truncated incorrect DOUBLE value: '123.456abc'
mysql> select 1 where 1 > '123.456abc';
Empty set, 1 warning (0.0004 sec)
Warning (code 1292): Truncated incorrect DOUBLE value: '123.456abc'
mysql> select sqrt('a');
+-----------+
| sqrt('a') |
+-----------+
|         0 |
+-----------+
1 row in set, 1 warning (0.0010 sec)
Warning (code 1292): Truncated incorrect DOUBLE value: 'a'
mysql> select sqrt('1e-4');
+--------------+
| sqrt('1e-4') |
+--------------+
|         0.01 |
+--------------+
1 row in set (0.0003 sec)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcorrectnessWe don't return the same result as MySQLsqlIssue with SQL

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions