| 1 |
# === Purpose === |
| 2 |
# |
| 3 |
# This test verifies that update events are properly applied by the slave when |
| 4 |
# same row is updated one than once within an Update_rows_log_event. |
| 5 |
# |
| 6 |
# === Implementation === |
| 7 |
# |
| 8 |
# 1. Intital setup includes creating two tables - with and without primary key |
| 9 |
# and a stored function that updates same row more than once. |
| 10 |
# 2. For each allowed value of slave_rows_search_algorithms, |
| 11 |
# 2.1 Insert a row and invoke the stored function. |
| 12 |
# 2.2 Verify that there is no difference between tables of master and |
| 13 |
# slave. |
| 14 |
# |
| 15 |
# === References === |
| 16 |
# |
| 17 |
# Bug#28846386: RBR + STORED FUNCTION WITHOUT PRIMARY KEY - CAN'T FIND RECORD IN |
| 18 |
# |
| 19 |
|
| 20 |
--source include/have_binlog_format_row.inc |
| 21 |
--source include/set_privilege_checks_user_as_system_user.inc |
| 22 |
--source include/master-slave.inc |
| 23 |
|
| 24 |
--source include/rpl_connection_slave.inc |
| 25 |
SET @saved_slave_rows_search_algorithms= @@global.slave_rows_search_algorithms; |
| 26 |
|
| 27 |
--source include/rpl_connection_master.inc |
| 28 |
# Create a table, with no primary key. |
| 29 |
CREATE TABLE t1 (i INT); |
| 30 |
# Create a table, with primary key. |
| 31 |
CREATE TABLE t2 (j INT NOT NULL PRIMARY KEY); |
| 32 |
|
| 33 |
# Create a stored function so that only one Update_rows_log_event is generated. |
| 34 |
--delimiter | |
| 35 |
CREATE FUNCTION f1 () RETURNS INT BEGIN |
| 36 |
UPDATE t1 SET i = 2 WHERE i = 1; |
| 37 |
UPDATE t1 SET i = 3 WHERE i = 2; |
| 38 |
UPDATE t1 SET i = 4 WHERE i = 3; |
| 39 |
UPDATE t1 SET i = 5 WHERE i = 4; |
| 40 |
UPDATE t2 SET j = 2 WHERE j = 1; |
| 41 |
UPDATE t2 SET j = 3 WHERE j = 2; |
| 42 |
UPDATE t2 SET j = 4 WHERE j = 3; |
| 43 |
UPDATE t2 SET j = 5 WHERE j = 4; |
| 44 |
RETURN 0; |
| 45 |
END| |
| 46 |
--delimiter ; |
| 47 |
--source include/sync_slave_sql_with_master.inc |
| 48 |
|
| 49 |
--let $i= 0 |
| 50 |
while ($i < 7) { |
| 51 |
|
| 52 |
if ($i == 0){ |
| 53 |
SET GLOBAL slave_rows_search_algorithms= 'HASH_SCAN'; |
| 54 |
} |
| 55 |
|
| 56 |
if ($i == 1){ |
| 57 |
SET GLOBAL slave_rows_search_algorithms= 'TABLE_SCAN'; |
| 58 |
} |
| 59 |
|
| 60 |
if ($i == 2){ |
| 61 |
SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN'; |
| 62 |
} |
| 63 |
|
| 64 |
if ($i == 3){ |
| 65 |
SET GLOBAL slave_rows_search_algorithms= 'HASH_SCAN,TABLE_SCAN'; |
| 66 |
} |
| 67 |
|
| 68 |
if ($i == 4){ |
| 69 |
SET GLOBAL slave_rows_search_algorithms= 'HASH_SCAN,INDEX_SCAN'; |
| 70 |
} |
| 71 |
|
| 72 |
if ($i == 5){ |
| 73 |
SET GLOBAL slave_rows_search_algorithms= 'TABLE_SCAN,INDEX_SCAN'; |
| 74 |
} |
| 75 |
|
| 76 |
if ($i == 6){ |
| 77 |
SET GLOBAL slave_rows_search_algorithms= 'HASH_SCAN,TABLE_SCAN,INDEX_SCAN'; |
| 78 |
} |
| 79 |
|
| 80 |
--source include/rpl_connection_master.inc |
| 81 |
|
| 82 |
# Insert a row and invoke the stored function. |
| 83 |
INSERT INTO t1 VALUES (1); |
| 84 |
INSERT INTO t2 VALUES (1); |
| 85 |
SELECT f1(); |
| 86 |
|
| 87 |
--source include/sync_slave_sql_with_master.inc |
| 88 |
--let $assert_text= 'There is only one row in table t1' |
| 89 |
--let $assert_cond= [SELECT COUNT(*) FROM t1] = 1 |
| 90 |
--source include/assert.inc |
| 91 |
|
| 92 |
--let $assert_text= 'There is only one row in table t2' |
| 93 |
--let $assert_cond= [SELECT COUNT(*) FROM t2] = 1 |
| 94 |
--source include/assert.inc |
| 95 |
|
| 96 |
--source include/rpl_connection_master.inc |
| 97 |
|
| 98 |
# Verify that there is no difference between tables of master and slave. |
| 99 |
--let diff_tables=master:test.t1, slave:test.t1 |
| 100 |
--source include/diff_tables.inc |
| 101 |
|
| 102 |
--let diff_tables=master:test.t2, slave:test.t2 |
| 103 |
--source include/diff_tables.inc |
| 104 |
|
| 105 |
# Truncate the table for the next test. |
| 106 |
TRUNCATE TABLE t1; |
| 107 |
TRUNCATE TABLE t2; |
| 108 |
--source include/sync_slave_sql_with_master.inc |
| 109 |
--inc $i |
| 110 |
} |
| 111 |
|
| 112 |
# Cleanup |
| 113 |
--source include/rpl_connection_master.inc |
| 114 |
DROP FUNCTION f1; |
| 115 |
DROP TABLE t1,t2; |
| 116 |
|
| 117 |
--source include/rpl_connection_slave.inc |
| 118 |
SET GLOBAL slave_rows_search_algorithms= @saved_slave_rows_search_algorithms; |
| 119 |
|
| 120 |
--source include/rpl_end.inc |