Loading mysql-test/r/insert_select.result +9 −0 Original line number Diff line number Diff line Loading @@ -625,3 +625,12 @@ select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); ID NO SEQ 1 1 1 drop table t1; create table t1 (f1 int); create table t2 (ff1 int unique, ff2 int default 1); insert into t1 values (1),(1),(2); insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1; select * from t2; ff1 ff2 1 2 2 1 drop table t1, t2; mysql-test/t/insert_select.test +9 −0 Original line number Diff line number Diff line Loading @@ -164,3 +164,12 @@ INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); drop table t1; # # Bug#10886 - Have to restore default values after update ON DUPLICATE KEY # create table t1 (f1 int); create table t2 (ff1 int unique, ff2 int default 1); insert into t1 values (1),(1),(2); insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1; select * from t2; drop table t1, t2; sql/sql_insert.cc +4 −1 Original line number Diff line number Diff line Loading @@ -2119,9 +2119,12 @@ bool select_insert::send_data(List<Item> &values) } if (!(error= write_record(thd, table, &info))) { if (table->triggers) if (table->triggers || info.handle_duplicates == DUP_UPDATE) { /* Restore fields of the record since it is possible that they were changed by ON DUPLICATE KEY UPDATE clause. If triggers exist then whey can modify some fields which were not originally touched by INSERT ... SELECT, so we have to restore their original values for the next row. Loading Loading
mysql-test/r/insert_select.result +9 −0 Original line number Diff line number Diff line Loading @@ -625,3 +625,12 @@ select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); ID NO SEQ 1 1 1 drop table t1; create table t1 (f1 int); create table t2 (ff1 int unique, ff2 int default 1); insert into t1 values (1),(1),(2); insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1; select * from t2; ff1 ff2 1 2 2 1 drop table t1, t2;
mysql-test/t/insert_select.test +9 −0 Original line number Diff line number Diff line Loading @@ -164,3 +164,12 @@ INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); drop table t1; # # Bug#10886 - Have to restore default values after update ON DUPLICATE KEY # create table t1 (f1 int); create table t2 (ff1 int unique, ff2 int default 1); insert into t1 values (1),(1),(2); insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1; select * from t2; drop table t1, t2;
sql/sql_insert.cc +4 −1 Original line number Diff line number Diff line Loading @@ -2119,9 +2119,12 @@ bool select_insert::send_data(List<Item> &values) } if (!(error= write_record(thd, table, &info))) { if (table->triggers) if (table->triggers || info.handle_duplicates == DUP_UPDATE) { /* Restore fields of the record since it is possible that they were changed by ON DUPLICATE KEY UPDATE clause. If triggers exist then whey can modify some fields which were not originally touched by INSERT ... SELECT, so we have to restore their original values for the next row. Loading