• Nikita Malyavin's avatar
    MDEV-34632 Assertion failed in handler::assert_icp_limitations · 25e2d0a6
    Nikita Malyavin authored
    Assertion `table->field[0]->ptr >= table->record[0] &&
    table->field[0]->ptr <= table->record[0] + table->s->reclength' failed in
    handler::assert_icp_limitations.
    
    table->move_fields has some limitations:
    1. It cannot be used in cascade
    2. It should always have a restoring pair.
    
    Rule 1 is covered by assertions in handler::assert_icp_limitations
    and handler::ptr_in_record (commit 30894fe9).
    
    Rule 2 should be manually maintained with care. Hopefully, the rule 1 assertions
    may sometimes help as well.
    
    In ha_myisam::repair, both rules are broken. table->move_fields is used
    asymmetrically there: it is set on every param->fix_record call
    (i.e. in compute_vcols) but is restored only once, in the end of repair.
    
    The reason to updating field ptr's for every call is that compute_vcols can
    (supposedly) be called in parallel, that is, with the same table, but different
    records.
    
    The condition to "unmove" the pointers in ha_myisam::restore_vcos_after_repair
    is incorrect, when stored vcols are available, and myisam stores a VIRTUAL field
    if it's the only field in the table (the record cannot be of zero length).
    
    This patch solves the problem by "unmoving" the pointers symmetrically, in
    compute_vcols. That is, both rules will be preserved maintained.
    25e2d0a6
ha_myisam.h 7.77 KB