• Aleksey Midenkov's avatar
    MDEV-16210 FK constraints on versioned tables use historical rows, which may... · 75ba5c81
    Aleksey Midenkov authored
    MDEV-16210 FK constraints on versioned tables use historical rows, which may cause constraint violation
    
    Constraint check is done on secondary index update.
    F.ex. DELETE does row_upd_sec_index_entry() and checks constraints in
    row_upd_check_references_constraints(). UPDATE is optimized for the
    case when order is not changed (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)
    and doesn't do row_upd_sec_index_entry(), so it doesn't check constraints.
    
    Since for versioned DELETE we do UPDATE actually, but expect behaviour
    of DELETE in terms of constraints, we should deny this optimization to
    get constraints checked.
    
    Fix wrong referenced table check when versioned DELETE inserts history in parent
    table. Set check_ref to false in this case.
    
    Removed unused dup_chk_only argument for row_ins_sec_index_entry() and
    added check_ref argument.
    
    MDEV-18057 fix was superseded by this fix and reverted.
    
    foreign.test:
    All key_type combinations: pk, unique, sec(ondary).
    75ba5c81
foreign.result 13.4 KB