mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Fix bug #14016 date_format() 2nd parameter was compared using case insensitive
collation By default constant strings in second parameter of date_time() have case insensitive collation. Because of this expressions date_format(f,'%m') and date_format(f,'%M') wrongly becomes equal, which results in choosing wrong column to sort by. Now if second parameter of date_format() is constant then it's collation is changed to case sensitive. sql/item_timefunc.cc: Fix bug #14016 date_format() 2nd parameter was compared using case insensitive collation. If second parameter of date_format() is constant then it's collation is changed to case sensitive. mysql-test/r/date_formats.result: Test case for bug#14016 2nd parameter was compared using case insensitive collation mysql-test/t/date_formats.test: Test case for bug#14016 2nd parameter was compared using case insensitive collation
This commit is contained in:
@@ -1528,6 +1528,16 @@ void Item_func_date_format::fix_length_and_dec()
|
||||
if (args[1]->type() == STRING_ITEM)
|
||||
{ // Optimize the normal case
|
||||
fixed_length=1;
|
||||
|
||||
/*
|
||||
Force case sensitive collation on format string.
|
||||
This needed because format modifiers with different case,
|
||||
for example %m and %M, have different meaning. Thus eq()
|
||||
will distinguish them.
|
||||
*/
|
||||
args[1]->collation.set(
|
||||
get_charset_by_csname(args[1]->collation.collation->csname,
|
||||
MY_CS_BINSORT,MYF(0)), DERIVATION_COERCIBLE);
|
||||
/*
|
||||
The result is a binary string (no reason to use collation->mbmaxlen
|
||||
This is becasue make_date_time() only returns binary strings
|
||||
|
Reference in New Issue
Block a user