Thread

  1. Re: COPY ON_CONFLICT TABLE; save duplicated record to another table.

    Zsolt Parragi <zsolt.parragi@percona.com> — 2026-05-11T20:40:18Z

    Hello!
    
    > One other thing I just noticed in BINARY mode. I believe we're missing a
    > check in ProcessCopyOptions() with ON_CONFLICT TABLE to show a proper
    > error message, e.g.
    
    It is possible to crash the current patch with binary mode, that check
    is definitely needed.
    
    
    + MakeTransitionCaptureState(cstate->conflictRel->trigdesc,
    +    RelationGetRelid(cstate->conflictRel),
    +    CMD_INSERT);
    
    Shouldn't this update mtstate->mt_transition_capture?
    
    + if (cstate->opts.on_conflict == ONCONFLICT_TABLE)
    ...
    + if (conflict_mstate->fireBSTriggers)
    + {
    + ExecBSInsertTriggers(conflict_mstate->ps.state,
    conflict_mstate->rootResultRelInfo);
    +
    + conflict_mstate->fireBSTriggers = false;
    + }
    +
    
    and
    
    + if (cstate->num_conflicts > 0)
    + {
    ...
    + /* Execute AFTER STATEMENT insertion triggers */
    + ExecASInsertTriggers(cstate->mtcontext->estate,
    + on_conflict_mtstate->rootResultRelInfo,
    + on_conflict_mtstate->mt_transition_capture);
    
    
    * Doesn't statements typically fire triggers unconditionally? INSERT
    ON CONFLICT DO NOTHING; fires BS+AS triggers even if it doesn't insert
    any rows.
    * Isn't firing a before statement trigger after some before/after row
    triggers were already fired (for non conflicting rows) strange?
    
    + if (valid_col_count != 4)
    + errdetail_msg = _("The conflict_table is incomplete; exactly four
    columns are required.");
    
    if valid_col_count > 4, is it still incomplete, shouldn't the error
    message change in that case?