Hi, Alice,
Code-wise all great, a couple of comments about tests.
And let's implement an optional third argument to STR_TO_DATE() in a
second commit.
On Mar 02, Alice Sherepa wrote:
> revision-id: 5cbc904d4d1 (mariadb-12.3.1-8-g5cbc904d4d1)
> parent(s): 242f223b987
> author: Alice Sherepa
> committer: Alice Sherepa
> timestamp: 2026-03-02 13:26:28 +0100
> message:
>
> MDEV-26112 STR_TO_DATE should work with lc_time_names
>
> diff --git a/mysql-test/main/date_formats.result
> b/mysql-test/main/date_formats.result
> index d195d8db6fe..ea813265046 100644
> --- a/mysql-test/main/date_formats.result
> +++ b/mysql-test/main/date_formats.result
> @@ -628,3 +628,30 @@ DATE_FORMAT('2023-03-26 03:00:00', '%z %Z')
> #
> # End of 11.3 test
> #
> +MDEV-26112 STR_TO_DATE should work with lc_time_names
> +SET names utf8;
> +set @@lc_time_names="uk_UA";
> +select str_to_date("1 березень 2010", "%e %M %Y"), str_to_date("1 березня
> 2010", "%e %M %Y");
> +str_to_date("1 березень 2010", "%e %M %Y") str_to_date("1 березня 2010",
> "%e %M %Y")
please, try also different capitalization, like "Березень 1, 2010"
> +2010-03-01 2010-03-01
> +select str_to_date("6 квітня 2010", "%e %M %Y"), str_to_date("31 грудня
> 2010", "%e %M %Y");
> +str_to_date("6 квітня 2010", "%e %M %Y") str_to_date("31 грудня 2010",
> "%e %M %Y")
> +2010-04-06 2010-12-31
> +select str_to_date("пн 27 квітня 2026", "%a %e %M %Y"), str_to_date("неділя
> 28 грудня 2010", "%W %e %M %Y");
> +str_to_date("пн 27 квітня 2026", "%a %e %M %Y") str_to_date("неділя 28
> грудня 2010", "%W %e %M %Y")
> +2026-04-27 2010-12-28
> +select str_to_date(date_format("2010-03-01","%e. %M %Y"), "%e. %M %Y");
> +str_to_date(date_format("2010-03-01","%e. %M %Y"), "%e. %M %Y")
> +2010-03-01
> +set @@lc_time_names="de_DE";
> +select str_to_date("1 März 2010", "%e %M %Y"), str_to_date("1 Juni 2010",
> "%e %M %Y");
> +str_to_date("1 März 2010", "%e %M %Y") str_to_date("1 Juni 2010", "%e
> %M %Y")
> +2010-03-01 2010-06-01
> +select str_to_date("1 Sep 2010", "%e %b %Y"), str_to_date("1 Mär 2010", "%e
> %b %Y");
> +str_to_date("1 Sep 2010", "%e %b %Y") str_to_date("1 Mär 2010", "%e
> %b %Y")
may be some vi_VN tests to have multi-word month names?
> +2010-09-01 2010-03-01
> +#
> +# End of 12.3 test
> +#
one line, please, not three. Just
--echo # End of 12.3 tests
it helps git to merge tests automatically
> +SET @@lc_time_names=DEFAULT;
> +SET NAMES latin1;
> diff --git a/mysql-test/main/date_formats.test
> b/mysql-test/main/date_formats.test
> index 679158c9814..fd6be55a752 100644
> --- a/mysql-test/main/date_formats.test
> +++ b/mysql-test/main/date_formats.test
> @@ -5,6 +5,7 @@
> #
> # Test of str_to_date
> #
> +let $old_charset= `SELECT @@character_set_client`;
>
> select str_to_date(concat('15-01-2001',' 2:59:58.999'),
> concat('%d-%m-%Y',' ','%H:%i:%s.%f')) as exp;
> @@ -325,3 +326,23 @@ SELECT DATE_FORMAT('2023-03-26 03:00:00', '%z %Z');
> --echo #
> --echo # End of 11.3 test
> --echo #
> +
> +--echo MDEV-26112 STR_TO_DATE should work with lc_time_names
and this should be three lines, not one
--echo #
--echo # MDEV-26112 STR_TO_DATE should work with lc_time_names
--echo #
> +
> +SET names utf8;
> +set @@lc_time_names="uk_UA";
> +select str_to_date("1 березень 2010", "%e %M %Y"), str_to_date("1 березня
> 2010", "%e %M %Y");
> +select str_to_date("6 квітня 2010", "%e %M %Y"), str_to_date("31 грудня
> 2010", "%e %M %Y");
> +select str_to_date("пн 27 квітня 2026", "%a %e %M %Y"), str_to_date("неділя
> 28 грудня 2010", "%W %e %M %Y");
> +select str_to_date(date_format("2010-03-01","%e. %M %Y"), "%e. %M %Y");
> +
> +set @@lc_time_names="de_DE";
> +select str_to_date("1 März 2010", "%e %M %Y"), str_to_date("1 Juni 2010",
> "%e %M %Y");
> +select str_to_date("1 Sep 2010", "%e %b %Y"), str_to_date("1 Mär 2010", "%e
> %b %Y");
> +
> +--echo #
> +--echo # End of 12.3 test
> +--echo #
> +
> +SET @@lc_time_names=DEFAULT;
> +eval SET NAMES $old_charset;
Regards,
Sergei
Chief Architect, MariaDB Server
and [email protected]
_______________________________________________
developers mailing list -- [email protected]
To unsubscribe send an email to [email protected]