• Alexander Barkov's avatar
    MDEV-31724 Compressed varchar values lost on joins when sorting on columns from joined table(s) · 1fa7c9a3
    Alexander Barkov authored
    Field_varstring::get_copy_func() did not take into account
    that functions do_varstring1[_mb], do_varstring2[_mb] do not support
    compressed data.
    
    Changing the return value of Field_varstring::get_copy_func()
    to `do_field_string` if there is a compresion and truncation
    at the same time. This fixes the problem, so now it works as follows:
    - val_str() uncompresses the data
    - The prefix is then calculated on the uncompressed data
    
    Additionally, introducing two new copying functions
    - do_varstring1_no_truncation()
    - do_varstring2_no_truncation()
    
    Using new copying functions in cases when:
    - a Field_varstring with length_bytes==1 is changing to a longer
        Field_varstring with length_bytes==1
    - a Field_varstring with length_bytes==2 is changing to a longer
        Field_varstring with length_bytes==2
    
    In these cases we don't care neither of compression nor
    of multi-byte prefixes: the entire data gets fully copied
    from the source column to the target column as is.
    
    This is a kind of new optimization, but this also was needed
    to preserve existing MTR test results.
    1fa7c9a3
column_compression.test 12.6 KB