mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fix for bug#13479 "REPLACE activates UPDATE trigger, not the DELETE and
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.
This commit is contained in:
@ -187,3 +187,26 @@ create view v1 as select * from t1;
|
||||
insert delayed into v1 values (1);
|
||||
drop table t1;
|
||||
drop view v1;
|
||||
|
||||
#
|
||||
# Test for values returned by ROW_COUNT() function
|
||||
# (and thus for values returned by mysql_affected_rows())
|
||||
# for various forms of INSERT
|
||||
#
|
||||
create table t1 (id int primary key, data int);
|
||||
insert into t1 values (1, 1), (2, 2), (3, 3);
|
||||
select row_count();
|
||||
insert ignore into t1 values (1, 1);
|
||||
select row_count();
|
||||
# Reports that 2 rows are affected (1 deleted + 1 inserted)
|
||||
replace into t1 values (1, 11);
|
||||
select row_count();
|
||||
replace into t1 values (4, 4);
|
||||
select row_count();
|
||||
# Reports that 2 rows are affected. This conforms to documentation.
|
||||
# (Useful for differentiating inserts from updates).
|
||||
insert into t1 values (2, 2) on duplicate key update data= data + 10;
|
||||
select row_count();
|
||||
insert into t1 values (5, 5) on duplicate key update data= data + 10;
|
||||
select row_count();
|
||||
drop table t1;
|
||||
|
Reference in New Issue
Block a user