• Alexander Barkov's avatar
    MDEV-20831 Table partitioned by LIST/RANGE COLUMNS(inet6) can be created, but not inserted into · 22b645ef
    Alexander Barkov authored
    This clause in CREATE TABLE:
    
      PARTITION BY LIST COLUMNS (inet6column)
        (PARTITION p1 VALUES IN ('::'))
    
    was erroneously written to frm file as:
    
      PARTITION BY LIST COLUMNS(inet6column)
        (PARTITION p1 VALUES IN (_binary 0x3A3A))
    
    I.e. the text value '::' was converted to HEX representation
    and prefixed with _binary.
    
    A simple fix could write `_latin1 0x3A3A` instead of `_binary 0x3A3A`,
    but in case of INET6 we don't need neither character set introducers,
    nor HEX encoding, because text representation of INET6 values consist
    of pure ASCII characters.
    
    So this patch changes the above clause to be printed as:
    
      PARTITION BY LIST COLUMNS(inet6column)
        (PARTITION p1 VALUES IN ('::'))
    
    Details:
    
    The old code in check_part_field() was not friendly to pluggable data types.
    Replacing this function to two new virtual methods in Type_handler:
    
      virtual bool partition_field_check(const LEX_CSTRING &field_name,
                                         Item *item_expr) const;
    
      virtual bool partition_field_append_value(String *str,
                                                Item *item_expr,
                                                CHARSET_INFO *field_cs,
                                                partition_value_print_mode_t mode)
                                                const;
    
    so data type plugins can decide whether they need to use character set
    introducer and/or hex encoding when printing partition values.
    22b645ef
sql_type.h 267 KB