• Vlad Lesin's avatar
    MDEV-19464: Altering partitioned table into S3 causes an obscure error · 878ad986
    Vlad Lesin authored
    The error occured because aria_copy_to_s3() function tried to copy .frm file
    of partition, but partition does not have it's own .frm file. The same is true
    for aria_rename_s3().
    
    To fix this issue the new parameter was added to those two functions to specify
    if .frm file must be copied or not. The parameter is set to 'false' for
    partitions.
    
    Also there was other issue with EXCHANGE PARTITION. Briefly, there is the
    following sequence of operations(see  exchange_name_with_ddl_log() for details):
    1) rename swap table to temporary table,
    2) rename partition to swap table,
    3) rename temporary table to partition.
    
    On step (1) .frm file is renamed too. On step (2) the swap table does not
    have .frm file, as partition does not have it. On step (3) partition will have
    .frm file, because it will be renamed from temporary table. All of this causes
    error on different stages of the table access. To fix it, .frm is not touched
    at all for s3 during EXCHANGE PARTITION operation. This is implemented in
    ha_s3::rename_table() by additional checking of
    current_thd->lex->alter_info.partition_flags(see also ALTER_PARTITION_EXCHANGE
    in sql_yacc.yy).
    878ad986
partitions-master.opt 18 Bytes