1#
2# UPDATE LIMIT should not cause any issues with row-based Galera replication
3# regardless of the order in which the rows were updated
4#
5
6--source include/galera_cluster.inc
7--source include/have_innodb.inc
8
9#
10# With a PK
11#
12
13--connection node_1
14CREATE TABLE ten (f1 INTEGER) Engine=InnoDB;
15INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
16
17CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB;
18INSERT INTO t1 SELECT f1 FROM ten ORDER BY RAND();
19
20--connection node_2
21--disable_warnings
22UPDATE IGNORE t1 SET f1 = FLOOR(1 + (RAND() * 10)) ORDER BY RAND() LIMIT 5;
23--enable_warnings
24
25# Check that the sum of all elements and the max element are identical across nodes
26# as this will indicate that the same UPDATE was applied to both nodes
27
28--let $sum_rows = `SELECT SUM(f1) FROM t1`
29--let $max_row = `SELECT MAX(f1) FROM t1`
30
31--connection node_1
32--disable_query_log
33--eval SELECT (SELECT SUM(f1) FROM t1) = $sum_rows AS sum_matches;
34--eval SELECT f1 = $max_row AS max_matches FROM t1 WHERE f1 = $max_row;
35--enable_query_log
36
37DROP TABLE t1;
38
39#
40# Without a PK
41#
42
43CREATE TABLE t2 (f1 INTEGER) Engine=InnoDB;
44INSERT INTO t2 SELECT f1 FROM ten ORDER BY RAND();
45
46--connection node_2
47UPDATE IGNORE t2 SET f1 = FLOOR(1 + (RAND() * 10)) ORDER BY RAND() LIMIT 5;
48
49--let $sum_rows = `SELECT SUM(f1) FROM t2`
50
51--connection node_1
52--disable_query_log
53--eval SELECT (SELECT SUM(f1) FROM t2) = $sum_rows AS sum_matches;
54--enable_query_log
55
56DROP TABLE t2;
57DROP TABLE ten;
58