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

TO_DATE: NLS_FORMAT_STRING parameter does not accept anything other than literals, incompatible with Oracle

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Won't Fix
    • N/A
    • N/A
    • Server
    • None
    • Not for Release Notes

    Description

      TO_DATE results in a syntax error if the third parameter is a column name, or a variable, or a function – apparently anything other than a string literal:

      CREATE TABLE t (str CHAR(64), nls CHAR(64));
      INSERT INTO t VALUES ('2025-12-12', 'NLS_CALENDAR=GREGORIAN');
      SELECT TO_DATE(str, 'YYYY-MM-DD', nls) FROM t;
      SELECT TO_DATE('2025-12-12', 'YYYY-MM-DD', CONCAT('NLS_CALENDAR=GREGORIAN',' ','NLS_DATE_LANGUAGE=ENGLISH'));
      

      bb-12.3-MDEV-19683-to_date 7cbf7a8c641379d4318067607b71704956e87e5e

      MariaDB [test]> CREATE TABLE t (str CHAR(64), nls CHAR(64));
      Query OK, 0 rows affected (0.027 sec)
       
      MariaDB [test]> INSERT INTO t VALUES ('2025-12-12', 'NLS_CALENDAR=GREGORIAN');
      Query OK, 1 row affected (0.002 sec)
       
      MariaDB [test]> SELECT TO_DATE(str, 'YYYY-MM-DD', nls) FROM t;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'nls) FROM t' at line 1
       
      MariaDB [test]> SELECT TO_DATE('2025-12-12', 'YYYY-MM-DD', CONCAT('NLS_CALENDAR=GREGORIAN',' ','NLS_DATE_LANGUAGE=ENGLISH'));
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CONCAT('NLS_CALENDAR=GREGORIAN',' ','NLS_DATE_LANGUAGE=ENGLISH'))' at line 1
      SELECT TO_DATE('2025-12-12', 'YYYY-MM-DD', CONCAT('NLS_CALENDAR=GREGORIAN',' ','NLS_DATE_LANGUAGE=ENGLISH'));
      

      Oracle

      TO_DATE('
      12-DEC-25
       
      TO_DATE('
      12-DEC-25
      

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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