mariadb/mysql-test/suite
Michael Widenius ce50b1138d MDEV-19683 Add support for Oracle TO_DATE()
Syntax:
TO_DATE(string_expression [DEFAULT string_expression ON CONVERSION ERROR],
        format_string [,NLS_FORMAT_STRING])
The format_string has the same format elements as TO_CHAR(), except a
few elements that are not supported/usable for TO_DATE().
TO_DATE() returns a datetime or date value, depending on if the format
element FF is used.

Allowed separators, same as TO_CHAR():
space, tab and any of !#%'()*+,-./:;<=>

'&' can also be used if next character is not a character a-z or A-Z
"text' indicates a text string that is verbatim in the format. One cannot
use " as a separator.

Format elements supported by TO_DATE():
AD          Anno Domini ("in the year of the Lord")
AD_DOT      Anno Domini ("in the year of the Lord")
AM          Meridian indicator (Before midday)
AM_DOT      Meridian indicator (Before midday)
DAY         Name of day
DD          Day (1-31)
DDD         Day of year (1-336)
DY          Abbreviated name of day
FF[1-6]     Fractional seconds
HH          Hour (1-12)
HH12        Hour (1-12)
HH24        Hour (0-23)
IW          Week of year (1-53). Used with I, IY...IYYY. ISO 8601
MI          Minutes (0-59)
MM          Month (1-12)
MON         Abbreviated name of month
MONTH       Name of Month
PM          Meridian indicator (After midday)
PM_DOT      Meridian indicator (After midday)
RR          20th century dates in the 21st century. 2 digits
            50-99 is assumed from 2000, 0-49 is assumed from 1900.
RRRR        20th century dates in the 21st century. 4 digits
SS          Seconds
SYYYY       Signed 4 digit year; MariaDB only supports positive years
Y           1 digit year
YY          2 digits year
YYY         3 digits year
YYYY        4 digits year

Note that if there is a missing part of the date, the current date is used!
For example if 'MM-DD HH-MM-SS' then the current year will be used.
(Oracle behaviour)

Not supported options:
BC, D, DL, DS, E, EE, FM, FX, RM, SSSSS, TS, TZD, TZH, TZR, X,SY
BC is not supported by MariaDB datetime.
Most of the other are exotic formats, format modifies other things that
does not make in MariaDB as we return datetime or datetime with fractions,
not string.
D (day-of-week) is not supported as it is not clear exactly how it would
map to MariaDB. This element depends on the NLS territory of the session.

Extensions / differences compared to Oracle;
- MariaDB supports FF (fractional seconds).  If FF[£] is used,
  then TO_DATE will return a datetime with # of subseconds.
  If FF is not used a datetime will be returned.
- Names can be shortened to it's unique prefix. For example January and Ja
  works fine.
- No error if the date string is shorter format_string. This is useful to
  get a date from a mixed set of strings in date or datetime format.
  Oracle gives an error if date string is too short.
- MariaDB supports short locales as language names
- NLS_DATE_FORMAT can use both " and ' for quoting.

New formats handled by TO_CHAR():
FF[1-6]     Fractional seconds
DDD         Daynumber 1-366
IW          Week 1-53 according to ISO 8601
I           1 digit year according to ISO 8601
IY          2 digit year according to ISO 8601
IYY         3 digit year according to ISO 8601
IYYY        4 digit year according to ISO 8601
SYYY        4 digit year according to ISO 8601 (Oracle can do signed)

Supported NLS_FORMAT_STRING options are:
NLS_CALENDAR=GREGORIAN
NLS_DATE_LANGUAGE=language

Support languages are:
- All MariaDB short locales, like en_AU.
- The following Oracle language names:
ALBANIAN, AMERICAN, ARABIC, BASQUE, BELARUSIAN, BRAZILIAN PORTUGUESE
BULGARIAN, CANADIAN FRENCH, CATALAN, CROATIAN, CYRILLIC SERBIAN CZECH,
DANISH, DUTCH, EGYPTIAN, ENGLISH, ESTONIAN, FINNISH, FRENCH, GERMAN,
GREEK, HEBREW, HINDI, HUNGARIAN, ICELANDIC, INDONESIAN ITALIAN,
JAPANESE, KANNADA, KOREAN, LATIN AMERICAN SPANISH, LATVIAN,
LITHUANIAN, MACEDONIAN, MALAY, MEXICAN SPANISH, NORWEGIAN, POLISH,
PORTUGUESE, ROMANIAN, RUSSIAN, SIMPLIFIED CHINESE, SLOVAK, SLOVENIAN,
SPANISH, SWAHILI, SWEDISH, TAMIL, THAI, TRADITIONAL CHINESE, TURKISH,
UKRAINIAN, URDU, VIETNAMESE
2025-12-11 13:24:50 +02:00
..
archive Merge remote-tracking branch 'github/bb-11.4-release' into bb-11.8-serg 2025-04-27 19:40:00 +02:00
atomic Fix the test: changing charset should be dome when we can not skip the test. 2025-05-09 07:36:15 +02:00
binlog Merge 11.8 into 12.1 2025-10-09 17:46:33 +03:00
binlog_encryption Merge branch '10.11' into 11.4 2025-07-28 19:40:10 +02:00
client Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
compat MDEV-19683 Add support for Oracle TO_DATE() 2025-12-11 13:24:50 +02:00
csv mariadb-test: wait on disconnect 2025-07-16 09:14:33 +07:00
encryption Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
engines Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
events MDEV-35617: DROP USER should leave no active session for that user 2025-07-16 09:14:33 +07:00
federated Merge branch '12.0' into 12.1 2025-08-03 15:01:09 +02:00
funcs_1 MDEV-37054: Implement INFORMATION_SCHEMA.PARAMETERS.PARAMETER_DEFAULT column 2025-10-15 22:04:28 +05:30
funcs_2 Merge 11.4 into 11.8 2025-04-02 14:07:01 +03:00
galera Merge 11.8 into 12.1 2025-10-09 17:46:33 +03:00
galera_3nodes Merge 11.8 into 12.1 2025-10-09 17:46:33 +03:00
galera_3nodes_sr Merge 11.4 into 11.8 2025-04-02 14:07:01 +03:00
galera_sr galera tests: synchronization between versions and editions 2025-08-14 17:04:40 +02:00
gcol Merge branch '10.11' into 11.4 2025-07-28 19:40:10 +02:00
handler mariadb-test: wait on disconnect 2025-07-16 09:14:33 +07:00
heap
innodb Merge 11.8 into 12.1 2025-10-09 17:46:33 +03:00
innodb_fts MDEV-35163 InnoDB persistent statistics fail to update after ALTER TABLE...ALGORITHM=COPY 2025-09-22 17:39:47 +05:30
innodb_gis mariadb-test: wait on disconnect 2025-07-16 09:14:33 +07:00
innodb_i_s
innodb_zip Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
jp Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
json Merge branch '11.8' into 12.0 2025-05-22 09:22:55 +02:00
large_tests
maria Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
mariabackup Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
merge mariadb-test: wait on disconnect 2025-07-16 09:14:33 +07:00
mtr/t
mtr2
multi_source Merge branch '12.1' into 12.2 2025-10-09 09:32:33 +02:00
optimizer_unfixed_bugs
parts Merge branch '11.8' into 12.0 2025-07-31 20:55:47 +02:00
perfschema Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
perfschema_stress remove features that were deprecated in 10.5 2025-04-29 16:53:02 +02:00
period Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
plugins Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
roles Merge branch '12.0' into 12.1 2025-08-03 15:01:09 +02:00
rpl Merge 11.8 into 12.1 2025-10-09 17:46:33 +03:00
s3 Merge branch '11.8' into 12.0 2025-06-18 07:50:39 +02:00
sql_sequence Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
storage_engine mariadb-test: wait on disconnect 2025-07-16 09:14:33 +07:00
stress
sys_vars Merge branch '12.1' into 12.2 2025-10-09 09:32:33 +02:00
sysschema Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
unit
vcol Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
versioning Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
wsrep Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00