Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions mysql-test/main/date_formats.result
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,24 @@ str_to_date('1 Tháng 9 2026', '%d %M %Y','vi_VN') 2026-09-01
str_to_date('1 Tháng 10 2026', '%d %M %Y','vi_VN') 2026-10-01
str_to_date('1 Tháng 11 2026', '%d %M %Y','vi_VN') 2026-11-01
str_to_date('1 Tháng 12 2026', '%d %M %Y','vi_VN') 2026-12-01
#
# MDEV-39721: SIGSEGV in check_word|(extract_date_time|extract_oracle_date_time)
#
# locale as a session var
SET SESSION lc_time_names='ar_DZ';
SELECT STR_TO_DATE('Wednesday, June 2, 2014', '%W, %M %e, %Y');
STR_TO_DATE('Wednesday, June 2, 2014', '%W, %M %e, %Y') NULL
Warnings:
Level Warning
Code 1411
Message Incorrect datetime value: 'Wednesday, June 2, 2014' for function str_to_date
# locale as third param to STR_TO_DATE
SELECT STR_TO_DATE('Wednesday, June 2, 2014', '%W, %M %e, %Y', 'ar_DZ');
STR_TO_DATE('Wednesday, June 2, 2014', '%W, %M %e, %Y', 'ar_DZ') NULL
Warnings:
Level Warning
Code 1411
Message Incorrect datetime value: 'Wednesday, June 2, 2014' for function str_to_date
# End of 12.3 test
SET @@lc_time_names=DEFAULT;
SET NAMES latin1;
11 changes: 11 additions & 0 deletions mysql-test/main/date_formats.test
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,17 @@ str_to_date('1 Tháng 10 2026', '%d %M %Y','vi_VN'),
str_to_date('1 Tháng 11 2026', '%d %M %Y','vi_VN'),
str_to_date('1 Tháng 12 2026', '%d %M %Y','vi_VN');

--echo #
--echo # MDEV-39721: SIGSEGV in check_word|(extract_date_time|extract_oracle_date_time)
--echo #

--echo # locale as a session var
SET SESSION lc_time_names='ar_DZ';
SELECT STR_TO_DATE('Wednesday, June 2, 2014', '%W, %M %e, %Y');

--echo # locale as third param to STR_TO_DATE
SELECT STR_TO_DATE('Wednesday, June 2, 2014', '%W, %M %e, %Y', 'ar_DZ');

--echo # End of 12.3 test

SET @@lc_time_names=DEFAULT;
Expand Down
18 changes: 18 additions & 0 deletions mysql-test/suite/compat/oracle/r/func_to_date.result
Original file line number Diff line number Diff line change
Expand Up @@ -927,4 +927,22 @@ ERROR HY000: Invalid argument error: date format not recognized at FF in functio
SELECT TO_DATE('2026 100', 'YYYY DDD') FROM DUAL;
TO_DATE('2026 100', 'YYYY DDD')
2026-04-10 00:00:00
#
# MDEV-39721: SIGSEGV in check_word|(extract_date_time|extract_oracle_date_time)
#
# Oracle Mode
SET sql_mode=ORACLE;
# locale as session var
SET SESSION lc_time_names='ar_DZ';
SELECT TO_DATE('Wednesday, June 2, 2014', 'Day, Month DD, YYYY');
TO_DATE('Wednesday, June 2, 2014', 'Day, Month DD, YYYY')
NULL
Warnings:
Warning 1411 Incorrect datetime value: 'Wednesday, June 2, 2014' for function to_date
# locale as param to TO_DATE
SELECT TO_DATE('Wednesday, June 2, 2014', 'Day, Month DD, YYYY', 'NLS_DATE_LANGUAGE=ar_DZ');
TO_DATE('Wednesday, June 2, 2014', 'Day, Month DD, YYYY', 'NLS_DATE_LANGUAGE=ar_DZ')
NULL
Warnings:
Warning 1411 Incorrect datetime value: 'Wednesday, June 2, 2014' for function to_date
# End of 12.3 tests
14 changes: 14 additions & 0 deletions mysql-test/suite/compat/oracle/t/func_to_date.test
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,18 @@ SELECT TO_DATE('123 456', 'FF FF') FROM DUAL;
--echo # YYYY and DDD are compatible (Year + Day of Year)
SELECT TO_DATE('2026 100', 'YYYY DDD') FROM DUAL;

--echo #
--echo # MDEV-39721: SIGSEGV in check_word|(extract_date_time|extract_oracle_date_time)
--echo #

--echo # Oracle Mode
SET sql_mode=ORACLE;

--echo # locale as session var
SET SESSION lc_time_names='ar_DZ';
SELECT TO_DATE('Wednesday, June 2, 2014', 'Day, Month DD, YYYY');

--echo # locale as param to TO_DATE
SELECT TO_DATE('Wednesday, June 2, 2014', 'Day, Month DD, YYYY', 'NLS_DATE_LANGUAGE=ar_DZ');

--echo # End of 12.3 tests
2 changes: 1 addition & 1 deletion sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4017,7 +4017,7 @@ static int init_common_variables()

my_tzset();
my_tzname(system_time_zone, sizeof(system_time_zone));
init_oracle_data_locale(); // For TO_DATE()
init_locale(); // For TO_DATE()

/*
We set SYSTEM time zone as reasonable default and
Expand Down
15 changes: 7 additions & 8 deletions sql/sql_locale.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4801,16 +4801,15 @@ static void update_lengths_in_typelib(TYPELIB *typelib)
}


void init_oracle_data_locale()
void init_locale()
{
ORACLE_DATE_LOCALE *locale;
for (locale= Oracle_date_locale; locale->locale ; locale++)
for (MY_LOCALE **locale= my_locales; *locale ; locale++)
{
update_lengths_in_typelib(locale->locale->month_names);
update_lengths_in_typelib(locale->locale->month_names_formatting);
update_lengths_in_typelib(locale->locale->ab_month_names);
update_lengths_in_typelib(locale->locale->day_names);
update_lengths_in_typelib(locale->locale->ab_day_names);
update_lengths_in_typelib((*locale)->month_names);
update_lengths_in_typelib((*locale)->month_names_formatting);
update_lengths_in_typelib((*locale)->ab_month_names);
update_lengths_in_typelib((*locale)->day_names);
update_lengths_in_typelib((*locale)->ab_day_names);
}

}
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_locale.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ MY_LOCALE *my_locale_by_name(const LEX_CSTRING &name);
MY_LOCALE *my_locale_by_number(uint number);
MY_LOCALE *my_locale_by_oracle_name(const LEX_CSTRING &name);
void cleanup_errmsgs(void);
void init_oracle_data_locale();
void init_locale();

#endif /* SQL_LOCALE_INCLUDED */
Loading