Commit 575013fa authored by unknown's avatar unknown

Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.1

into  mysql.com:/home/kent/bk/tmp/mysql-5.1-build
parents 550ed5e0 c50f7219
...@@ -1398,18 +1398,19 @@ id val ...@@ -1398,18 +1398,19 @@ id val
1 test1 1 test1
2 test2 2 test2
INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val); INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val);
INSERT INTO t1 VALUES (3,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); INSERT INTO t1 VALUES (2,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val);
INSERT INTO t1 VALUES (3,'test4') ON DUPLICATE KEY UPDATE val=VALUES(val);
SELECT * FROM t1; SELECT * FROM t1;
id val id val
1 test1 1 test1
2 test2 2 test3
3 test3 3 test4
SELECT * FROM t2; SELECT * FROM t2;
id val id val
1 test1 1 test1
2 test2 2 test2
3 test2 3 test3
4 test3 4 test4
DROP TRIGGER trg27006_a_insert; DROP TRIGGER trg27006_a_insert;
DROP TRIGGER trg27006_a_update; DROP TRIGGER trg27006_a_update;
drop table t1,t2; drop table t1,t2;
......
...@@ -1700,8 +1700,7 @@ DROP PROCEDURE bug22580_proc_1; ...@@ -1700,8 +1700,7 @@ DROP PROCEDURE bug22580_proc_1;
DROP PROCEDURE bug22580_proc_2; DROP PROCEDURE bug22580_proc_2;
# #
# Bug#27006: AFTER UPDATE triggers not fired with INSERT ... ON DUPLICATE KEY # Bug#27006: AFTER UPDATE triggers not fired with INSERT ... ON DUPLICATE
# UPDATE if the row wasn't actually changed.
# #
--disable_warnings --disable_warnings
DROP TRIGGER IF EXISTS trg27006_a_update; DROP TRIGGER IF EXISTS trg27006_a_update;
...@@ -1730,7 +1729,8 @@ INSERT INTO t1(val) VALUES ('test1'),('test2'); ...@@ -1730,7 +1729,8 @@ INSERT INTO t1(val) VALUES ('test1'),('test2');
SELECT * FROM t1; SELECT * FROM t1;
SELECT * FROM t2; SELECT * FROM t2;
INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val); INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val);
INSERT INTO t1 VALUES (3,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); INSERT INTO t1 VALUES (2,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val);
INSERT INTO t1 VALUES (3,'test4') ON DUPLICATE KEY UPDATE val=VALUES(val);
SELECT * FROM t1; SELECT * FROM t1;
SELECT * FROM t2; SELECT * FROM t2;
DROP TRIGGER trg27006_a_insert; DROP TRIGGER trg27006_a_insert;
......
...@@ -1260,22 +1260,23 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) ...@@ -1260,22 +1260,23 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
compare_record(table)) compare_record(table))
{ {
info->updated++; info->updated++;
/*
If ON DUP KEY UPDATE updates a row instead of inserting one, it's
like a regular UPDATE statement: it should not affect the value of a
next SELECT LAST_INSERT_ID() or mysql_insert_id().
Except if LAST_INSERT_ID(#) was in the INSERT query, which is
handled separately by THD::arg_of_last_insert_id_function.
*/
insert_id_for_cur_row= table->file->insert_id_for_cur_row= 0;
if (table->next_number_field)
table->file->adjust_next_insert_id_after_explicit_value(
table->next_number_field->val_int());
trg_error= (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
TRG_ACTION_AFTER, TRUE));
info->copied++; info->copied++;
} }
/*
If ON DUP KEY UPDATE updates a row instead of inserting one, it's
like a regular UPDATE statement: it should not affect the value of a
next SELECT LAST_INSERT_ID() or mysql_insert_id().
Except if LAST_INSERT_ID(#) was in the INSERT query, which is
handled separately by THD::arg_of_last_insert_id_function.
*/
insert_id_for_cur_row= table->file->insert_id_for_cur_row= 0;
if (table->next_number_field)
table->file->adjust_next_insert_id_after_explicit_value(
table->next_number_field->val_int());
trg_error= (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
TRG_ACTION_AFTER, TRUE));
goto ok_or_after_trg_err; goto ok_or_after_trg_err;
} }
else /* DUP_REPLACE */ else /* DUP_REPLACE */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment