• Nikita Malyavin's avatar
    MDEV-23597 Assertion `marked_for_read()' failed while evaluating DEFAULT · c47e4aab
    Nikita Malyavin authored
    The columns that are part of DEFAULT expression were not read-marked
    in statements like UPDATE...SET b=DEFAULT.
    
    The problem is `F(DEFAULT)` expression depends of the left-hand side of an
    assignment. However, setup_fields accepts only right-hand side value.
    Neither Item::fix_fields does.
    
    Suchwise, b=DEFAULT(b) works fine, because Item_default_field has
    information on what field it is default of:
        if (thd->mark_used_columns != MARK_COLUMNS_NONE)
          def_field->default_value->expr->update_used_tables();
    
    in Item_default_value::fix_fields().
    
    It is not reasonable to pass a left-hand side to Item:fix_fields, because
    the case is rare, so the rewrite
      b= F(DEFAULT)  ->  b= F(DEFAULT(b))
    
    is made instead.
    
    Both UPDATE and multi-UPDATE are affected, however any form of INSERT
    is not: it marks all the fields in DEFAULT expressions for read in
    TABLE::mark_default_fields_for_write().
    c47e4aab
sql_yacc.yy 520 KB