Details
-
Bug
-
Status: In Review (View Workflow)
-
Critical
-
Resolution: Unresolved
-
12.2(EOL), 13.1, 13.0.2
-
Unexpected results
Description
TO_NUMBER() with the PR format element (added in MDEV-20022) does not handle positive values the way Oracle does. MariaDB requires the value to be surrounded by blanks, while Oracle accepts it without them and rejects the blank-surrounded form.
| Statement | Oracle | MariaDB 13.0.2 |
|---|---|---|
| SELECT TO_NUMBER('1234.50', '9999.99PR'); | 1234.5 | NULL (warning 1411) |
| SELECT TO_NUMBER(' 1234.50', '9999.99PR'); | 1234.5 | NULL (warning 1411) |
| SELECT TO_NUMBER(' 1234.50 ', '9999.99PR'); | ORA-01722: unable to convert string value containing ' ' to a number | 1234.5 |
Negative values in angle brackets work the same in both: TO_NUMBER('<1234.50>', '9999.99PR') returns -1234.5.
Cause
get_PR() in sql/item_numconvfunc.cc accepts a subject only if its first and last characters are both blanks or are '<' and '>':
if (!(leading == ' ' && trailing == ' ') &&
|
!(leading == '<' && trailing == '>'))
|
return true; // Unknown
|
Expected
Positive values are accepted as in Oracle: without surrounding blanks, and with a leading blank.
Notes
- MI was also checked: TO_NUMBER('1234.50', '9999.99MI') is rejected by both Oracle (ORA-01722) and MariaDB (NULL), so MI is not part of this report.
- Oracle results were provided by bar (sqlfiddle.com). MariaDB results are from 13.0.2; the code is unchanged in 12.2 and 13.1.
- Found while documenting TO_NUMBER format strings (DOCS-6982). Until this is fixed, the documentation shows only negative PR values.
Attachments
Issue Links
- is caused by
-
MDEV-20022 sql_mode="oracle" does not support TO_NUMBER() function
-
- Closed
-
- split from
-
DOCS-6982 Loading...