• Marko Mäkelä's avatar
    MDEV-12358 Work around what looks like a bug in GCC 7.1.0 · 9f89b94b
    Marko Mäkelä authored
    The parameter thr of the function btr_cur_optimistic_insert()
    is not declared as nonnull, but GCC 7.1.0 with -O3 is wrongly
    optimizing away the first part of the condition
    UNIV_UNLIKELY(thr && thr_get_trx(thr)->fake_changes)
    when the function is being called by row_merge_insert_index_tuples()
    with thr==NULL.
    
    The fake_changes is an XtraDB addition. This GCC bug only appears
    to have an impact on XtraDB, not InnoDB.
    
    We work around the problem by not attempting to dereference thr
    when both BTR_NO_LOCKING_FLAG and BTR_NO_UNDO_LOG_FLAG are set
    in the flags. Probably BTR_NO_LOCKING_FLAG alone should suffice.
    
    btr_cur_optimistic_insert(), btr_cur_pessimistic_insert(),
    btr_cur_pessimistic_update(): Correct comments that disagree with
    usage and with nonnull attributes. No other parameter than thr can
    actually be NULL.
    
    row_ins_duplicate_error_in_clust(): Remove an unused parameter.
    
    innobase_is_fake_change(): Unused function; remove.
    
    ibuf_insert_low(), row_log_table_apply(), row_log_apply(),
    row_undo_mod_clust_low():
    Because we will be passing BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG
    in the flags, the trx->fake_changes flag will be treated as false,
    which is the right thing to do at these low-level operations
    (change buffer merge, ALTER TABLE…LOCK=NONE, or ROLLBACK).
    This might be fixing actual XtraDB bugs.
    
    Other callers that pass these two flags are also passing thr=NULL,
    implying fake_changes=false. (Some callers in ROLLBACK are passing
    BTR_NO_LOCKING_FLAG and a nonnull thr. In these callers, fake_changes
    better be false, to avoid corruption.)
    9f89b94b
row0ins.cc 89.5 KB