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

TO_CHAR does not take into account capitalization in format elements

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • N/A
    • 10.6
    • Server
    • None

    Description

      In Oracle, capitalization of the format elements matters. It is documented and actually holds truth:

      SELECT TO_CHAR(SYSDATE, 'MONTH') FROM DUAL
      MAY 
       
      SELECT TO_CHAR(SYSDATE, 'Month') FROM DUAL
      May
       
      SELECT TO_CHAR(SYSDATE, 'month') FROM DUAL
      may 
      

      In MariaDB implementation it is not so. All variants are accepted, but the same result is returned for any of them:

      a04ef8a3cb90

      MariaDB [test]> SELECT TO_CHAR(SYSDATE, 'MONTH') FROM DUAL;
      +---------------------------+
      | TO_CHAR(SYSDATE, 'MONTH') |
      +---------------------------+
      | May                       |
      +---------------------------+
      1 row in set (0.001 sec)
       
      MariaDB [test]> SELECT TO_CHAR(SYSDATE, 'Month') FROM DUAL;
      +---------------------------+
      | TO_CHAR(SYSDATE, 'Month') |
      +---------------------------+
      | May                       |
      +---------------------------+
      1 row in set (0.001 sec)
       
      MariaDB [test]> SELECT TO_CHAR(SYSDATE, 'month') FROM DUAL;
      +---------------------------+
      | TO_CHAR(SYSDATE, 'month') |
      +---------------------------+
      | May                       |
      +---------------------------+
      1 row in set (0.001 sec)
      

      I haven't found anything in MDEV-20017 description or comments that would suggest it is intentional. It says that only MONTH is supported (which is not true, as shown above), but even if it were true, it would mean that it returns a different value comparing to Oracle.

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              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.