Merge lp:~laurynas-biveinis/percona-server/bug898306-5.5 into lp:percona-server/5.5

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 339
Proposed branch: lp:~laurynas-biveinis/percona-server/bug898306-5.5
Merge into: lp:percona-server/5.5
Prerequisite: lp:~laurynas-biveinis/percona-server/bug1064326-5.5
Diff against target: 258 lines (+200/-0)
7 files modified
Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_898306.result (+43/-0)
Percona-Server/mysql-test/t/percona_innodb_fake_changes.test (+75/-0)
Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_898306.test (+59/-0)
Percona-Server/sql/handler.h (+6/-0)
Percona-Server/sql/sql_insert.cc (+9/-0)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+7/-0)
Percona-Server/storage/innobase/handler/ha_innodb.h (+1/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug898306-5.5
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Review via email: mp+129430@code.launchpad.net

Description of the change

Add the already null-merged bug 898306 fix from 5.1, reusing 5.1 file
ids.

Tweak the percona_innodb_fake_changes_bug_898306 test case to check
for InnoDB correctly, also add CHECK TABLE to ensure that fake changes
have not violated data integrity.

http://jenkins.percona.com/job/percona-server-5.5-param/544/

26611

To post a comment you must log in.
Revision history for this message
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_898306.result'
2--- Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_898306.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_898306.result 2012-10-12 13:26:24 +0000
4@@ -0,0 +1,43 @@
5+DROP TABLE IF EXISTS t1;
6+CREATE TABLE t1 (a INT primary key, b int, unique key (b)) ENGINE=InnoDB;
7+INSERT INTO t1 VALUES (1,1);
8+SET autocommit=1;
9+SET innodb_fake_changes=1;
10+# Confirm that duplicate key errors on REPLACE works
11+REPLACE INTO t1 VALUES (1,1);
12+ERROR HY000: Got error 131 during COMMIT
13+REPLACE INTO t1 VALUES (1,2);
14+ERROR HY000: Got error 131 during COMMIT
15+# Confirm that duplicate key errors are OK
16+BEGIN;
17+REPLACE INTO t1 VALUES (1,2);
18+SELECT * from t1;
19+a b
20+1 1
21+REPLACE INTO t1 VALUES (1,1);
22+SELECT * from t1;
23+a b
24+1 1
25+ROLLBACK;
26+BEGIN;
27+REPLACE INTO t1 VALUES (2,1);
28+ERROR 23000: Duplicate entry '1' for key 'b'
29+INSERT INTO t1 VALUES (1,1);
30+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
31+INSERT INTO t1 VALUES (1,2);
32+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
33+INSERT INTO t1 VALUES (2,1);
34+ERROR 23000: Duplicate entry '1' for key 'b'
35+ROLLBACK;
36+INSERT INTO t1 VALUES (1,1) ON DUPLICATE KEY UPDATE b=b+10;
37+ERROR HY000: Got error 131 during COMMIT
38+INSERT INTO t1 VALUES (1,2) ON DUPLICATE KEY UPDATE b=b+10;
39+ERROR HY000: Got error 131 during COMMIT
40+SET innodb_fake_changes=0;
41+SELECT * from t1;
42+a b
43+1 1
44+CHECK TABLE t1;
45+Table Op Msg_type Msg_text
46+test.t1 check status OK
47+DROP TABLE t1;
48
49=== added file 'Percona-Server/mysql-test/t/percona_innodb_fake_changes.test'
50--- Percona-Server/mysql-test/t/percona_innodb_fake_changes.test 1970-01-01 00:00:00 +0000
51+++ Percona-Server/mysql-test/t/percona_innodb_fake_changes.test 2012-10-12 13:26:24 +0000
52@@ -0,0 +1,75 @@
53+--source include/have_innodb.inc
54+
55+--disable_warnings
56+DROP TABLE IF EXISTS t1, t2, t3;
57+--enable_warnings
58+
59+
60+--echo # Checking variables
61+SHOW VARIABLES LIKE 'innodb_fake_changes';
62+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='innodb_fake_changes';
63+SET innodb_fake_changes=1;
64+SHOW VARIABLES LIKE 'innodb_fake_changes';
65+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='innodb_fake_changes';
66+SET innodb_fake_changes=default;
67+SHOW VARIABLES LIKE 'innodb_fake_changes';
68+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='innodb_fake_changes';
69+
70+--echo # Explicit COMMIT should fail when innodb_fake_changes is enabled
71+--echo # DML should be fine
72+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
73+INSERT INTO t1 VALUES (1);
74+let $t1_checksum_1= `CHECKSUM TABLE t1 EXTENDED`;
75+SET autocommit=0;
76+SET innodb_fake_changes=1;
77+BEGIN;
78+INSERT INTO t1 VALUES (2);
79+UPDATE t1 SET a=0;
80+DELETE FROM t1 LIMIT 1;
81+SELECT * FROM t1;
82+--error 1180
83+COMMIT;
84+SET innodb_fake_changes=default;
85+--echo # Verify that the fake changes to t1 did not leak through
86+CHECK TABLE t1;
87+let $t1_checksum_2= `CHECKSUM TABLE t1 EXTENDED`;
88+--disable_query_log
89+eval SELECT "$t1_checksum_1" LIKE "$t1_checksum_2" AS should_be_1;
90+--enable_query_log
91+DROP TABLE t1;
92+
93+--echo # DDL must result in error
94+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
95+SET autocommit=0;
96+SET innodb_fake_changes=1;
97+BEGIN;
98+--error 1005
99+CREATE TABLE t2 (a INT) ENGINE=InnoDB;
100+--error 1051
101+DROP TABLE t1;
102+--error 1180
103+TRUNCATE TABLE t1;
104+--error 1180
105+ALTER TABLE t1 ENGINE=MyISAM;
106+ROLLBACK;
107+
108+# Test for bug 890404: uninitialized value warning in btr_cur_pessimistic_update
109+SET innodb_fake_changes=0;
110+CREATE TABLE t3 (a INT primary key, b text) ENGINE=InnoDB;
111+INSERT INTO t3 VALUES (1,'');
112+COMMIT;
113+let $t3_checksum_1= `CHECKSUM TABLE t3 EXTENDED`;
114+SET innodb_fake_changes=1;
115+
116+UPDATE t3 set b=lpad('b',11000,'c') where a=1;
117+--error ER_ERROR_DURING_COMMIT
118+COMMIT;
119+
120+SET innodb_fake_changes=default;
121+--echo # Verify that the fake changes to t3 did not leak through
122+CHECK TABLE t3;
123+let $t3_checksum_2= `CHECKSUM TABLE t3 EXTENDED`;
124+--disable_query_log
125+eval SELECT "$t3_checksum_1" LIKE "$t3_checksum_2" AS should_be_1;
126+--enable_query_log
127+DROP TABLE t1, t3;
128
129=== added file 'Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_898306.test'
130--- Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_898306.test 1970-01-01 00:00:00 +0000
131+++ Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_898306.test 2012-10-12 13:26:24 +0000
132@@ -0,0 +1,59 @@
133+# Test case for Bug #898306: innodb_fake_changes doesn't handle duplicate keys on REPLACE
134+# https://bugs.launchpad.net/percona-server/+bug/898306
135+# Test ensures that REPLACE statement behaviour respects innodb_fake_changes feature
136+--source include/have_innodb.inc
137+
138+--disable_warnings
139+DROP TABLE IF EXISTS t1;
140+--enable_warnings
141+
142+CREATE TABLE t1 (a INT primary key, b int, unique key (b)) ENGINE=InnoDB;
143+INSERT INTO t1 VALUES (1,1);
144+
145+SET autocommit=1;
146+SET innodb_fake_changes=1;
147+
148+--echo # Confirm that duplicate key errors on REPLACE works
149+
150+--error ER_ERROR_DURING_COMMIT
151+REPLACE INTO t1 VALUES (1,1);
152+
153+--error ER_ERROR_DURING_COMMIT
154+REPLACE INTO t1 VALUES (1,2);
155+
156+--echo # Confirm that duplicate key errors are OK
157+
158+BEGIN;
159+REPLACE INTO t1 VALUES (1,2);
160+SELECT * from t1;
161+REPLACE INTO t1 VALUES (1,1);
162+SELECT * from t1;
163+ROLLBACK;
164+
165+BEGIN;
166+
167+--error ER_DUP_ENTRY
168+REPLACE INTO t1 VALUES (2,1);
169+
170+--error ER_DUP_ENTRY
171+INSERT INTO t1 VALUES (1,1);
172+
173+--error ER_DUP_ENTRY
174+INSERT INTO t1 VALUES (1,2);
175+
176+--error ER_DUP_ENTRY
177+INSERT INTO t1 VALUES (2,1);
178+
179+ROLLBACK;
180+
181+--error ER_ERROR_DURING_COMMIT
182+INSERT INTO t1 VALUES (1,1) ON DUPLICATE KEY UPDATE b=b+10;
183+
184+--error ER_ERROR_DURING_COMMIT
185+INSERT INTO t1 VALUES (1,2) ON DUPLICATE KEY UPDATE b=b+10;
186+
187+SET innodb_fake_changes=0;
188+SELECT * from t1;
189+CHECK TABLE t1;
190+
191+DROP TABLE t1;
192
193=== modified file 'Percona-Server/sql/handler.h'
194--- Percona-Server/sql/handler.h 2012-05-18 04:37:44 +0000
195+++ Percona-Server/sql/handler.h 2012-10-12 13:26:24 +0000
196@@ -1923,6 +1923,12 @@
197 void update_global_table_stats();
198 void update_global_index_stats();
199
200+ /**
201+ Return true when innodb_fake_changes was set for the current transaction
202+ on this handler.
203+ */
204+ virtual my_bool is_fake_change_enabled(THD *thd) { return FALSE; }
205+
206 #define CHF_CREATE_FLAG 0
207 #define CHF_DELETE_FLAG 1
208 #define CHF_RENAME_FLAG 2
209
210=== modified file 'Percona-Server/sql/sql_insert.cc'
211--- Percona-Server/sql/sql_insert.cc 2012-08-13 13:42:13 +0000
212+++ Percona-Server/sql/sql_insert.cc 2012-10-12 13:26:24 +0000
213@@ -1752,6 +1752,15 @@
214 trg_error= 1;
215 goto ok_or_after_trg_err;
216 }
217+
218+ /*
219+ Avoid the infinite loop
220+ 1) get dup key on fake insert
221+ 2) do nothing on fake delete
222+ 3) goto #1
223+ */
224+ if (table->file->is_fake_change_enabled(thd))
225+ goto ok_or_after_trg_err;
226 /* Let us attempt do write_row() once more */
227 }
228 }
229
230=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
231--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-10-12 13:26:24 +0000
232+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-10-12 13:26:24 +0000
233@@ -1050,6 +1050,13 @@
234 return(*(trx_t**) thd_ha_data(thd, innodb_hton_ptr));
235 }
236
237+my_bool
238+ha_innobase::is_fake_change_enabled(THD* thd)
239+{
240+ trx_t* trx = thd_to_trx(thd);
241+ return(trx && trx->fake_changes);
242+}
243+
244 /********************************************************************//**
245 Call this function when mysqld passes control to the client. That is to
246 avoid deadlocks on the adaptive hash S-latch possibly held by thd. For more
247
248=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.h'
249--- Percona-Server/storage/innobase/handler/ha_innodb.h 2012-09-17 13:08:32 +0000
250+++ Percona-Server/storage/innobase/handler/ha_innodb.h 2012-10-12 13:26:24 +0000
251@@ -138,6 +138,7 @@
252 int close(void);
253 double scan_time();
254 double read_time(uint index, uint ranges, ha_rows rows);
255+ my_bool is_fake_change_enabled(THD *thd);
256 bool is_corrupt() const;
257
258 int write_row(uchar * buf);

Subscribers

People subscribed via source and target branches