• unknown's avatar
    Fix for bug#13479 "REPLACE activates UPDATE trigger, not the DELETE and · e08a2b32
    unknown authored
    INSERT triggers".
    
    In cases when REPLACE was internally executed via update and table had
    on update (on delete) triggers defined we exposed the fact that such
    optimization used by callng on update (not calling on delete) triggers.
    Such behavior contradicts our documentation which describes REPLACE as
    INSERT with optional DELETE.
    
    This fix just disables this optimization for tables with on delete triggers.
    The optimization is still applied for tables which have on update but have
    no on delete triggers, we just don't invoke on update triggers in this case
    and thus don't expose information about optimization to user.
    
    Also added test coverage for values returned by ROW_COUNT() function (and
    thus for values returned by mysql_affected_rows()) for various forms of
    INSERT.
    
    
    mysql-test/r/insert.result:
      Added test for values returned by ROW_COUNT() function (and thus for values
      returned by mysql_affected_rows()) for various forms of INSERT. We didn't
      have coverage for this before and since this fix touches related code it is
      better to add it now.
    mysql-test/r/trigger.result:
      Adjusted test after fixing bug#13479 "REPLACE activates UPDATE trigger, not
      the DELETE and INSERT triggers".
    mysql-test/t/insert.test:
      Added test for values returned by ROW_COUNT() function (and thus for values
      returned by mysql_affected_rows()) for various forms of INSERT. We didn't
      have coverage for this before and since this fix touches related code it is
      better to add it now.
    mysql-test/t/trigger.test:
      Adjusted test after fixing bug#13479 "REPLACE activates UPDATE trigger, not
      the DELETE and INSERT triggers".
    sql/sql_insert.cc:
      write_record():
        We should not expose that internally we sometimes execute REPLACE
        via UPDATE instead of documented INSERT + DELETE pair. So we should not
        use this optimization for tables with on delete triggers. OTOH it is ok
        to use it for tables which have on update but have no on delete triggers,
        we just should not invoke on update triggers in this case.
    e08a2b32
trigger.test 40.2 KB