Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-41823

TO_NUMBER() with format element PR rejects positive values without surrounding blanks, unlike Oracle

    XMLWordPrintable

Details

    • 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

          Activity

            People

              bar Alexander Barkov
              stefan.hinz Stefan Hinz
              External_Contributor External_Contributor
              Alexander Barkov Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.