1 ################################################################################
3 # Executes INSERT ... SELECT statements.
5 ################################################################################
10 # We need this to determine how many rows to update after insert (we may insert mulitple rows).
11 let $pk_before= `SELECT MAX(`pk`) FROM t1`;
13 # Insert rows unless we have duplicate values in unique indexes.
14 # WHERE conditions are more or less arbitrary.
15 --error 0, ER_LOCK_DEADLOCK, ER_LOCK_WAIT_TIMEOUT, ER_CHECKREAD, ER_DUP_ENTRY
16 INSERT INTO t1 (`id`, `int1`, `int1_key`, `int1_unique`,
17 `int2`, `int2_key`, `int2_unique`,
18 `for_update`, `is_uncommitted`, `is_consistent`)
19 SELECT src.`id`, src.`int1`, src.`int1_key`, src.`int1_unique`,
20 src.`int2`, src.`int2_key`, src.`int2_unique`,
21 src.`for_update`, src.`is_uncommitted`, src.`is_consistent`
23 WHERE (src.`pk` BETWEEN 1000 AND 1049) AND (src.`id` > 0) AND (src.`is_consistent` = 1) AND (src.`int1_unique` MOD 8 = 0)
24 ON DUPLICATE KEY UPDATE `int1_unique`= src.`int1_unique` + CONNECTION_ID() + 1000, `int2_unique`= src.`int2_unique` - (CONNECTION_ID()+1000);
26 --source suite/engines/rr_trx/include/check_for_error_rollback.inc
28 # ROW_COUNT may be negative. If positive (and non-zero), update the rows we inserted.
29 let $rows = `SELECT @rows:=ROW_COUNT()`;
31 # Make sure $rows is never negative (to avoid infitite loop below).
32 if(`SELECT IF(@rows < 1, 1, 0)`)
37 --echo *** Updating id and connection_id if we actually inserted something (query log disabled)...
38 # Conditional, so skip query log
40 # We risk duplicate entries... in that case @@last_insert_id is 0
43 # We actually inserted a row, so update id, conn_id, timestamp
44 --error 0, ER_LOCK_DEADLOCK, ER_LOCK_WAIT_TIMEOUT, ER_CHECKREAD
45 eval UPDATE t1 SET `connection_id` = CONNECTION_ID(), `id` = 2 WHERE `pk` = $pk_before + $rows;