mariadb/mysql-test/suite/compat
Alexander Barkov 2dc9b8b78e MDEV-36216 TO_CHAR FM format not recognized in SQL_MODE=Oracle
Adding support for the "FM" format in function TO_CHAR(date_time, fmt).

"FM" in the format string disables padding of all components following it.

So now TO_CHAR() works as follows:

- By default string format components DAY (weekday name) and
  MONTH (month name) are right-padded with spaces to the maximum
  possible DAY and MONTH name lengths respectively,
  according to the current locale specified in @@lc_time_names.
  So for example, with lc_time_names='en_US' all month names are
  right-padded with spaces up to 9 characters ('September' is the longest).

    SET lc_time_names='en_US';
    SELECT TO_CHAR('0001-02-03', 'MONTH');   -> 'February '  (padded to 9 chars)

  NEW: When typed after FM, DAY and MONTH names are not right-padded
  with trailing spaces any more:

   SET lc_time_names='en_US';
   SELECT TO_CHAR('0001-02-03', 'FMMONTH'); -> 'February' (not padded)

- By default numeric components YYYY, YYY, YY, Y, DD, H12, H24, MI, SS
  are left-padded with leading digits '0' up to the maximum possible
  number of digits in the component (e.g. 4 for YYYY):

    SELECT TO_CHAR('0001-02-03', 'YYYY'); -> '0001' (padded to 4 chars)

  NEW: When typed after FM, these numeric components are not left-padded
  with leading zeros any more:

    SELECT TO_CHAR('0001-02-03', 'FMYYYY'); -> '1' (not padded)

- If FM is specified multiple times in a format string,
  every FM negates the previous padding state:
  * an odd FM disables padding
  * an even FM enables padding

Implementation details:
- Adding a helper class Date_time_format_oracle.
- Adding a helper method Date_time_format_oracle::append_lex_cstring()
- Moving the function append_val() to Date_time_format_oracle as a method.
- Moving the function make_date_time_oracle() to Date_time_format_oracle
  as a method format().
- Adding helper methods month_name() and day_name() in class MY_LOCALE,
  to return the corresponding components as LEX_CSTRINGs.
2025-04-16 12:55:49 +04:00
..
maxdb Merge 10.9 into 10.10 2022-09-21 10:59:56 +03:00
mssql MDEV-19142 sql_mode=MSSQL: Bracket identifiers 2019-04-15 09:39:28 +04:00
oracle MDEV-36216 TO_CHAR FM format not recognized in SQL_MODE=Oracle 2025-04-16 12:55:49 +04:00
README.txt MDEV-20017 Implement TO_CHAR() Oracle compatible function 2021-05-19 22:54:12 +02:00

To run a test suite under this directory, you should use the format:

mysql-test-run --suite=compat/oracle

or to run one test:

mysql-test-run compat/oracle.test_name