• Neeraj Bisht's avatar
    Bug#16691598 - ORDER BY LOWER(COLUMN) PRODUCES OUT-OF-ORDER RESULTS · 97657db9
    Neeraj Bisht authored
    Problem:-
    We have created a table with UTF8_BIN collation.
    In case, when in our query we have ORDER BY clause over a function 
    call we are getting result in incorrect order.
    Note:the bug is not there in 5.5.
    
    Analysis:
    In 5.5, for UTF16_BIN, we have min and max multi-byte length is 2 and 4 
    respectively.In make_sortkey(),for 2 byte character character we are 
    assuming that the resultant length will be 2 byte/character. But when we 
    use my_strnxfrm_unicode_full_bin(), we store sorting weights using 3 bytes 
    per character.This result in truncated result.
    
    Same thing happen for UTF8MB4, where we have 1 byte min multi-byte and 
    4 byte max multi-byte.We will accsume resultant data as 1 byte/character, 
    which result in truncated result.
    
    Solution:-
    use strnxfrm(means use of MY_CS_STRNXFRM macro) is used for sort, in 
    which the resultant length is not dependent on source length.
    97657db9
ctype-utf8.c 219 KB