Merge lp:~laurynas-biveinis/percona-server/fake-changes-from-fb-5.5 into lp:percona-server/5.5

Proposed by Laurynas Biveinis on 2013-07-29
Status: Merged
Approved by: Stewart Smith on 2013-10-17
Approved revision: no longer in the source branch.
Merged at revision: 587
Proposed branch: lp:~laurynas-biveinis/percona-server/fake-changes-from-fb-5.5
Merge into: lp:percona-server/5.5
Prerequisite: lp:~laurynas-biveinis/percona-server/fake-changes-binlog-5.5
Diff against target: 1888 lines (+1082/-193)
18 files modified
Percona-Server/mysql-test/include/start_fake_changes.inc (+42/-0)
Percona-Server/mysql-test/include/stop_fake_changes.inc (+34/-0)
Percona-Server/mysql-test/r/percona_innodb_fake_changes.result (+485/-40)
Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_898306.result (+37/-3)
Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_917942.result (+101/-0)
Percona-Server/mysql-test/t/percona_innodb_fake_changes.test (+302/-73)
Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_898306.test (+8/-4)
Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_917942.test (+14/-24)
Percona-Server/mysql-test/t/percona_innodb_fake_changes_locks.test (+1/-0)
Percona-Server/sql/handler.cc (+1/-1)
Percona-Server/sql/sql_insert.cc (+1/-1)
Percona-Server/storage/innobase/btr/btr0cur.c (+11/-11)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+12/-9)
Percona-Server/storage/innobase/handler/handler0alter.cc (+4/-4)
Percona-Server/storage/innobase/lock/lock0lock.c (+6/-6)
Percona-Server/storage/innobase/que/que0que.c (+1/-1)
Percona-Server/storage/innobase/row/row0ins.c (+7/-7)
Percona-Server/storage/innobase/row/row0upd.c (+15/-9)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/fake-changes-from-fb-5.5
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve on 2013-10-17
Vlad Lesin (community) g2 Approve on 2013-09-30
Sergei Glushchenko g2 2013-07-29 Pending
Laurynas Biveinis Pending
Review via email: mp+177311@code.launchpad.net

This proposal supersedes a proposal from 2013-07-25.

Description of the change

No BT or ST but BT 20439 prerequisite.

5th MP:

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

Redundant thr != NULL checks removed, added few missing branch prediction annotations.

4th MP:

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

Removed redundant thr != NULL check.

3rd MP:

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

Disabled SHOW INDEXES until bug 1201802 is fixed.

2nd MP:

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

Added ANALYZE TABLE to start_fake_changes.inc.

1st MP:

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

Fix bug 1190604 (Missing branch predictor annotations for fake
changes) by adding likely/unlikely/UNIV_LIKELY/UNIV_LIKELY annotations
to all the fake changes check branches that are missing them.

Fix bug 1200162 (Missing MTR tests for fake changes with BLOBs and
secondary indexes) by reviewing Facebook patch and adding
corresponding tests to our fake changes tests.

At the same time: create two new include files start_fake_changes.inc
and stop_fake_changes.inc. They start or stop fake changes and also
take the snapshot of the server state that should not change during
the fake changes workload. Use these files instead of setting
fake_changes session variable directly where applicable for additional
verification.

To post a comment you must log in.
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

start|stop_fake_changes.inc:

SELECT ROWS FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS and SHOW INDEXES may cause test instabilities if there is a non-fake-change session workload for the same table running in parallel to the fake change one and the automatic stat recalculation kicks in at a wrong time. This need either ANALYZE TABLE, either disabling auto recalc. Right now the former seems like a better option IMHO.

review: Needs Fixing
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

For 5.5 the index cardinality stats are unstable even with ANALYZE TABLE, innodb_stats_on_metadata=OFF, innodb_stats_sample_pages=30000, innodb_stats_auto_update=0. This is bug 1201802, and until it's fixed, the SHOW INDEXES have to be removed from there. 5.6 is OK.

review: Needs Fixing
Sergei Glushchenko (sergei.glushchenko) wrote : Posted in a previous version of this proposal

Hi Laurynas,

In general it looks good, but I have some sort of advice on even better optimization.

I imagine that "likely" and "unlikely" instructions are used to rearrange branches so that CPU will make less jumps during execution of "likely" case. Less jumps means less wasted CPU cycles evaluating what is not needed.

I see many checks like:
if (UNIV_UNLIKELY(thr && thr_get_trx(thr)->fake_changes))

I think that we can avoid check "thr is not NULL" in some places. Many places indeed allow thr to be NULL, but others don't. For example btr_cur_upd_lock_and_undo expect that thr is not NULL, line "ut_ad(cursor && update && thr && roll_ptr)" tells us about it. Avoiding to check thr here will give much better performance boost than giving a hint to compiler.

review: Needs Information (g2)
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

btr_cur_upd_lock_and_undo is the only such place in 5.5, will adjust.

review: Needs Fixing
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Same comments as for the 5.6 MP (or the previous comments on this MP).

review: Needs Fixing
558. By Laurynas Biveinis on 2013-08-06

Automerge lp:~ignacio-nin/percona-server/5.5-bug1201036

559. By Laurynas Biveinis on 2013-08-14

Automerge lp:~laurynas-biveinis/percona-server/merge-5.5.33

560. By Laurynas Biveinis on 2013-08-14

Null-merge lp:percona-server/5.1 revision 584

561. By Laurynas Biveinis on 2013-08-16

 Automerge lp:~laurynas-biveinis/percona-server/buf-mutex-split-fixes-5.5

562. By Laurynas Biveinis on 2013-08-22

Automerge lp:~laurynas-biveinis/percona-server/c-change-2013-5.5

563. By Laurynas Biveinis on 2013-08-22

Automerge lp:~laurynas-biveinis/percona-server/bug1214735-5.5

564. By Laurynas Biveinis on 2013-08-23

Automerge lp:~laurynas-biveinis/percona-server/fake-changes-binlog-5.5

565. By <email address hidden> on 2013-08-27

Merge lp:~hrvojem/percona-server/rn-5.1.71-14.9-5.5
http://jenkins.percona.com/job/merge-PS-5.5-docs-kickoff/44/

566. By Laurynas Biveinis on 2013-08-28

Automerge lp:~gl-az/percona-server/BT23597_utility-user-access_5.5

567. By Laurynas Biveinis on 2013-08-29

Automerge lp:~laurynas-biveinis/percona-server/ahi-partitions-5.6-5.5

568. By Laurynas Biveinis on 2013-09-06

Automerge lp:~percona-core/percona-server/release-5.5.33-31.1

569. By Laurynas Biveinis on 2013-09-06

Merge lp:~akopytov/percona-server/ahi-fixes-5.5

570. By Laurynas Biveinis on 2013-09-09

Automerge lp:~sergei.glushchenko/percona-server/5.5-ps-blueprint-rate-limit-to-slow-log

571. By Alexey Kopytov on 2013-09-16

Merged lp:~akopytov/percona-server/bug711817-5.5.

572. By Laurynas Biveinis on 2013-09-20

Automerge lp:~sergei.glushchenko/percona-server/5.5-BT34246-ps-blueprint-into-outfile-pipe-and-socket

573. By Laurynas Biveinis on 2013-09-24

Automerge lp:~laurynas-biveinis/percona-server/bug1217002-5.5

574. By Laurynas Biveinis on 2013-09-27

Automerge lp:~laurynas-biveinis/percona-server/bug1191580-1191589-5.5

575. By <email address hidden> on 2013-09-27

Merge lp:~hrvojem/percona-server/bug1206069-5.5
http://jenkins.percona.com/job/merge-PS-5.5-docs-kickoff/45/

576. By Laurynas Biveinis on 2013-09-28

Automerge lp:~ignacio-nin/percona-server/5.5-bug1002500

577. By Laurynas Biveinis on 2013-09-28

Automerge lp:~sergei.glushchenko/percona-server/5.5-ps-bug1204873

Vlad Lesin (vlad-lesin) :
review: Approve (g2)
Stewart Smith (stewart) :
review: Approve
586. By Laurynas Biveinis on 2013-10-17

Automerge lp:~sergei.glushchenko/percona-server/5.5-ps-bug1203567

587. By Laurynas Biveinis on 2013-10-17

Fix bug 1190604 (Missing branch predictor annotations for fake
changes) by adding likely/unlikely/UNIV_LIKELY/UNIV_LIKELY annotations
to all the fake changes check branches that are missing them.

588. By Laurynas Biveinis on 2013-10-17

Fix bug 1200162 (Missing MTR tests for fake changes with BLOBs and
secondary indexes) by reviewing Facebook patch and adding
corresponding tests to our fake changes tests.

At the same time: create two new include files start_fake_changes.inc
and stop_fake_changes.inc. They start or stop fake changes and also
take the snapshot of the server state that should not change during
the fake changes workload. Use these files instead of setting
fake_changes session variable directly where applicable for additional
verification.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Percona-Server/mysql-test/include/start_fake_changes.inc'
2--- Percona-Server/mysql-test/include/start_fake_changes.inc 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/include/start_fake_changes.inc 2013-10-17 07:55:49 +0000
4@@ -0,0 +1,42 @@
5+#
6+# Include this file in a session before fake changes workload. It will enable
7+# the fake changes for the current session and save the relevant server state
8+# to variables that will be used by stop_fake_changes.inc that it didn't change.
9+#
10+# Since some of the state checked is global InnoDB counters, do not issue a
11+# non-fake-changes workload in parallel.
12+#
13+
14+# Requires userstat
15+SELECT @@global.userstat = 1 AS should_be_1;
16+
17+# ANALYZE TABLE and SHOW INDEXES below are disabled until
18+# https://bugs.launchpad.net/percona-server/+bug/1201802
19+# is fixed.
20+#
21+# # Have up-to-date stats for the fake changes table, so that, if there is a
22+# # non-fake-changes session running in parallel, it does not trigger an auto
23+# # stat recalc which then fails these checks.
24+#
25+# # Requires large index dive sample pages values
26+# SELECT @@global.innodb_stats_sample_pages = 30000 AS should_be_1;
27+#
28+# eval ANALYZE TABLE $fake_changes_table;
29+
30+let $t_checksum_1= `CHECKSUM TABLE $fake_changes_table EXTENDED`;
31+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
32+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
33+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
34+eval SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE '$fake_changes_table';
35+eval SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE '$fake_changes_table';
36+eval SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE '$fake_changes_table';
37+
38+# Disabled until https://bugs.launchpad.net/percona-server/+bug/1201802 is fixed.
39+#
40+#
41+# Index stats should not change, but it's only possible to inspect them
42+# manually.
43+#
44+# eval SHOW INDEXES IN $fake_changes_table;
45+
46+SET innodb_fake_changes=1;
47
48=== added file 'Percona-Server/mysql-test/include/stop_fake_changes.inc'
49--- Percona-Server/mysql-test/include/stop_fake_changes.inc 1970-01-01 00:00:00 +0000
50+++ Percona-Server/mysql-test/include/stop_fake_changes.inc 2013-10-17 07:55:49 +0000
51@@ -0,0 +1,34 @@
52+#
53+# Include this file in a session after fake changes workload. It will disable the fake
54+# changes and assert that the relevant server state has not changed from the one saved
55+# by a previous start_fake_changes.inc.
56+#
57+SET innodb_fake_changes=0;
58+
59+eval CHECK TABLE $fake_changes_table;
60+
61+let $t_checksum_2= `CHECKSUM TABLE $fake_changes_table EXTENDED`;
62+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
63+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
64+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
65+eval SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE '$fake_changes_table';
66+eval SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE '$fake_changes_table';
67+eval SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE '$fake_changes_table';
68+
69+--disable_query_log
70+eval SELECT "$t_checksum_1" LIKE "$t_checksum_2" AS should_be_1;
71+--enable_query_log
72+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
73+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
74+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
75+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
76+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
77+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
78+
79+# Disabled until https://bugs.launchpad.net/percona-server/+bug/1201802 is fixed.
80+#
81+# #
82+# # Index stats should not change, but it's only possible to inspect them
83+# # manually.
84+# #
85+# eval SHOW INDEXES IN $fake_changes_table;
86
87=== modified file 'Percona-Server/mysql-test/r/percona_innodb_fake_changes.result'
88--- Percona-Server/mysql-test/r/percona_innodb_fake_changes.result 2012-10-17 11:56:00 +0000
89+++ Percona-Server/mysql-test/r/percona_innodb_fake_changes.result 2013-10-17 07:55:49 +0000
90@@ -22,10 +22,18 @@
91 OFF
92 # Explicit COMMIT should fail when innodb_fake_changes is enabled
93 # DML should be fine
94-SET @@GLOBAL.userstat= TRUE;
95+SET @@GLOBAL.userstat=TRUE;
96 CREATE TABLE t1 (a INT) ENGINE=InnoDB;
97 INSERT INTO t1 VALUES (1);
98-SET autocommit=0;
99+SELECT @@global.userstat = 1 AS should_be_1;
100+should_be_1
101+1
102+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
103+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
104+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
105+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
106+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
107+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
108 SET innodb_fake_changes=1;
109 BEGIN;
110 INSERT INTO t1 VALUES (2);
111@@ -36,29 +44,380 @@
112 1
113 COMMIT;
114 ERROR HY000: Got error 131 during COMMIT
115-SET innodb_fake_changes=default;
116-# Verify that the fake changes to t1 did not leak through
117-CHECK TABLE t1;
118-Table Op Msg_type Msg_text
119-test.t1 check status OK
120-should_be_1
121-1
122-should_be_0
123-0
124-should_be_0
125-0
126-should_be_0
127-0
128-should_be_0
129-0
130-should_be_0
131-0
132-should_be_0
133-0
134-DROP TABLE t1;
135+SET innodb_fake_changes=0;
136+CHECK TABLE t1;
137+Table Op Msg_type Msg_text
138+test.t1 check status OK
139+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
140+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
141+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
142+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
143+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
144+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
145+should_be_1
146+1
147+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
148+should_be_0
149+0
150+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
151+should_be_0
152+0
153+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
154+should_be_0
155+0
156+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
157+should_be_0
158+0
159+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
160+should_be_0
161+0
162+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
163+should_be_0
164+0
165+DROP TABLE t1;
166+CREATE TABLE t1 (a INT PRIMARY KEY, b INT, UNIQUE KEY (b)) ENGINE=InnoDB;
167+INSERT INTO t1 VALUES (1,1);
168+SELECT @@global.userstat = 1 AS should_be_1;
169+should_be_1
170+1
171+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
172+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
173+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
174+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
175+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
176+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
177+SET innodb_fake_changes=1;
178+SELECT * FROM t1;
179+ERROR HY000: Got error 131 during COMMIT
180+INSERT INTO t1 VALUES (2,2);
181+ERROR HY000: Got error 131 during COMMIT
182+UPDATE t1 SET a=0 where b=1;
183+ERROR 23000: Duplicate entry '1' for key 'b'
184+UPDATE t1 SET b=0 where a=1;
185+ERROR HY000: Got error 131 during COMMIT
186+UPDATE t1 SET b=0 where a=2;
187+ERROR HY000: Got error 131 during COMMIT
188+DELETE FROM t1 where b=2;
189+ERROR HY000: Got error 131 during COMMIT
190+DELETE FROM t1 where b=1;
191+ERROR HY000: Got error 131 during COMMIT
192+DELETE FROM t1 where a=2;
193+ERROR HY000: Got error 131 during COMMIT
194+DELETE FROM t1 where a=1;
195+ERROR HY000: Got error 131 during COMMIT
196+REPLACE INTO t1 values (2,3);
197+ERROR HY000: Got error 131 during COMMIT
198+BEGIN;
199+SELECT * FROM t1;
200+a b
201+1 1
202+COMMIT;
203+ERROR HY000: Got error 131 during COMMIT
204+BEGIN;
205+INSERT INTO t1 VALUES (2,2);
206+COMMIT;
207+ERROR HY000: Got error 131 during COMMIT
208+BEGIN;
209+UPDATE t1 SET a=0 where b=1;
210+ERROR 23000: Duplicate entry '1' for key 'b'
211+COMMIT;
212+ERROR HY000: Got error 131 during COMMIT
213+BEGIN;
214+UPDATE t1 SET b=0 where a=1;
215+COMMIT;
216+ERROR HY000: Got error 131 during COMMIT
217+BEGIN;
218+UPDATE t1 SET b=0 where a=2;
219+COMMIT;
220+ERROR HY000: Got error 131 during COMMIT
221+BEGIN;
222+DELETE FROM t1 where b=2;
223+COMMIT;
224+ERROR HY000: Got error 131 during COMMIT
225+BEGIN;
226+DELETE FROM t1 where b=1;
227+COMMIT;
228+ERROR HY000: Got error 131 during COMMIT
229+BEGIN;
230+DELETE FROM t1 where a=2;
231+COMMIT;
232+ERROR HY000: Got error 131 during COMMIT
233+BEGIN;
234+DELETE FROM t1 where a=1;
235+COMMIT;
236+ERROR HY000: Got error 131 during COMMIT
237+BEGIN;
238+REPLACE INTO t1 values (2,3);
239+COMMIT;
240+ERROR HY000: Got error 131 during COMMIT
241+INSERT INTO t1 VALUES (1,1) ON DUPLICATE KEY UPDATE b=2;
242+ERROR HY000: Got error 131 during COMMIT
243+CREATE INDEX bx ON t1(b);
244+ERROR HY000: Got error 131 during COMMIT
245+SET innodb_fake_changes=0;
246+CHECK TABLE t1;
247+Table Op Msg_type Msg_text
248+test.t1 check status OK
249+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
250+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
251+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
252+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
253+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
254+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
255+should_be_1
256+1
257+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
258+should_be_0
259+0
260+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
261+should_be_0
262+0
263+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
264+should_be_0
265+0
266+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
267+should_be_0
268+0
269+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
270+should_be_0
271+0
272+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
273+should_be_0
274+0
275+DROP TABLE t1;
276+CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
277+INSERT INTO t2 VALUES (1, 1);
278+SELECT @@global.userstat = 1 AS should_be_1;
279+should_be_1
280+1
281+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
282+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
283+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
284+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2';
285+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2';
286+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2';
287+SET innodb_fake_changes=1;
288+SELECT * FROM t2;
289+ERROR HY000: Got error 131 during COMMIT
290+INSERT INTO t2 VALUES (2,2);
291+ERROR HY000: Got error 131 during COMMIT
292+UPDATE t2 SET b=0 where a=1;
293+ERROR HY000: Got error 131 during COMMIT
294+UPDATE t2 SET b=0 where a=2;
295+ERROR HY000: Got error 131 during COMMIT
296+DELETE FROM t2 where b=2;
297+ERROR HY000: Got error 131 during COMMIT
298+DELETE FROM t2 where b=1;
299+ERROR HY000: Got error 131 during COMMIT
300+DELETE FROM t2 where a=2;
301+ERROR HY000: Got error 131 during COMMIT
302+DELETE FROM t2 where a=1;
303+ERROR HY000: Got error 131 during COMMIT
304+REPLACE INTO t2 values (2,3);
305+ERROR HY000: Got error 131 during COMMIT
306+REPLACE INTO t2 VALUES (1,1);
307+ERROR HY000: Got error 131 during COMMIT
308+REPLACE INTO t2 VALUES (1,2);
309+ERROR HY000: Got error 131 during COMMIT
310+BEGIN;
311+SELECT * FROM t2;
312+a b
313+1 1
314+COMMIT;
315+ERROR HY000: Got error 131 during COMMIT
316+BEGIN;
317+INSERT INTO t2 VALUES (2,2);
318+COMMIT;
319+ERROR HY000: Got error 131 during COMMIT
320+BEGIN;
321+UPDATE t2 SET b=0 where a=1;
322+COMMIT;
323+ERROR HY000: Got error 131 during COMMIT
324+BEGIN;
325+UPDATE t2 SET b=0 where a=2;
326+COMMIT;
327+ERROR HY000: Got error 131 during COMMIT
328+BEGIN;
329+DELETE FROM t2 where b=2;
330+COMMIT;
331+ERROR HY000: Got error 131 during COMMIT
332+BEGIN;
333+DELETE FROM t2 where b=1;
334+COMMIT;
335+ERROR HY000: Got error 131 during COMMIT
336+BEGIN;
337+DELETE FROM t2 where a=2;
338+COMMIT;
339+ERROR HY000: Got error 131 during COMMIT
340+BEGIN;
341+DELETE FROM t2 where a=1;
342+COMMIT;
343+ERROR HY000: Got error 131 during COMMIT
344+BEGIN;
345+REPLACE INTO t2 values (2,3);
346+COMMIT;
347+ERROR HY000: Got error 131 during COMMIT
348+BEGIN;
349+REPLACE INTO t2 VALUES (1,1);
350+COMMIT;
351+ERROR HY000: Got error 131 during COMMIT
352+BEGIN;
353+REPLACE INTO t2 VALUES (1,2);
354+COMMIT;
355+ERROR HY000: Got error 131 during COMMIT
356+BEGIN;
357+REPLACE INTO t2 VALUES (1,2);
358+SELECT * from t2;
359+a b
360+1 1
361+REPLACE INTO t2 VALUES (1,1);
362+SELECT * from t2;
363+a b
364+1 1
365+ROLLBACK;
366+BEGIN;
367+INSERT INTO t2 VALUES (1,1);
368+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
369+INSERT INTO t2 VALUES (1,2);
370+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
371+ROLLBACK;
372+INSERT INTO t2 VALUES (1,1) ON DUPLICATE KEY UPDATE b=2;
373+ERROR HY000: Got error 131 during COMMIT
374+INSERT INTO t2 VALUES (1,1) ON DUPLICATE KEY UPDATE b=b+10;
375+ERROR HY000: Got error 131 during COMMIT
376+INSERT INTO t2 VALUES (1,2) ON DUPLICATE KEY UPDATE b=b+10;
377+ERROR HY000: Got error 131 during COMMIT
378+CREATE INDEX bx ON t2(b);
379+ERROR HY000: Got error 131 during COMMIT
380+SET innodb_fake_changes=0;
381+CHECK TABLE t2;
382+Table Op Msg_type Msg_text
383+test.t2 check status OK
384+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
385+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
386+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
387+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2';
388+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2';
389+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2';
390+should_be_1
391+1
392+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
393+should_be_0
394+0
395+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
396+should_be_0
397+0
398+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
399+should_be_0
400+0
401+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
402+should_be_0
403+0
404+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
405+should_be_0
406+0
407+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
408+should_be_0
409+0
410+DROP TABLE t2;
411+CREATE TABLE t3 (a INT PRIMARY KEY, B TEXT) ENGINE=InnoDB;
412+INSERT INTO t3 VALUES (1, '');
413+SELECT @@global.userstat = 1 AS should_be_1;
414+should_be_1
415+1
416+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
417+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
418+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
419+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
420+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
421+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
422+SET innodb_fake_changes=1;
423+SELECT * FROM t3;
424+ERROR HY000: Got error 131 during COMMIT
425+INSERT INTO t3 VALUES (2,lpad('a',10000, 'b'));
426+ERROR HY000: Got error 131 during COMMIT
427+UPDATE t3 SET a=0 where a=1;
428+ERROR HY000: Got error 131 during COMMIT
429+DELETE FROM t3 where a=2;
430+ERROR HY000: Got error 131 during COMMIT
431+DELETE FROM t3 where a=1;
432+ERROR HY000: Got error 131 during COMMIT
433+REPLACE INTO t3 values (2,lpad('a',9000,'q'));
434+ERROR HY000: Got error 131 during COMMIT
435+INSERT INTO t3 VALUES (1,1) ON DUPLICATE KEY UPDATE b=lpad('b',11000,'c');
436+ERROR HY000: Got error 131 during COMMIT
437+BEGIN;
438+SELECT * FROM t3;
439+a B
440+1
441+COMMIT;
442+ERROR HY000: Got error 131 during COMMIT
443+BEGIN;
444+INSERT INTO t3 VALUES (2,lpad('a',10000, 'b'));
445+COMMIT;
446+ERROR HY000: Got error 131 during COMMIT
447+BEGIN;
448+UPDATE t3 SET a=0 where a=1;
449+COMMIT;
450+ERROR HY000: Got error 131 during COMMIT
451+BEGIN;
452+DELETE FROM t3 where a=2;
453+COMMIT;
454+ERROR HY000: Got error 131 during COMMIT
455+BEGIN;
456+DELETE FROM t3 where a=1;
457+COMMIT;
458+ERROR HY000: Got error 131 during COMMIT
459+BEGIN;
460+REPLACE INTO t3 values (2,lpad('a',9000,'q'));
461+COMMIT;
462+ERROR HY000: Got error 131 during COMMIT
463+BEGIN;
464+INSERT INTO t3 VALUES (1,1) ON DUPLICATE KEY UPDATE b=lpad('b',11000,'c');
465+COMMIT;
466+ERROR HY000: Got error 131 during COMMIT
467+SET innodb_fake_changes=0;
468+CHECK TABLE t3;
469+Table Op Msg_type Msg_text
470+test.t3 check status OK
471+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
472+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
473+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
474+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
475+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
476+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
477+should_be_1
478+1
479+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
480+should_be_0
481+0
482+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
483+should_be_0
484+0
485+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
486+should_be_0
487+0
488+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
489+should_be_0
490+0
491+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
492+should_be_0
493+0
494+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
495+should_be_0
496+0
497+DROP TABLE t3;
498 # DDL must result in error
499 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
500-SET autocommit=0;
501+SELECT @@global.userstat = 1 AS should_be_1;
502+should_be_1
503+1
504+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
505+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
506+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
507+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
508+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
509+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
510 SET innodb_fake_changes=1;
511 BEGIN;
512 CREATE TABLE t2 (a INT) ENGINE=InnoDB;
513@@ -66,50 +425,136 @@
514 DROP TABLE t1;
515 ERROR 42S02: Unknown table 't1'
516 TRUNCATE TABLE t1;
517-ERROR HY000: Got error 131 during COMMIT
518+ERROR HY000: Table storage engine for 't1' doesn't have this option
519 ALTER TABLE t1 ENGINE=MyISAM;
520 ERROR HY000: Got error 131 during COMMIT
521 ROLLBACK;
522 SET innodb_fake_changes=0;
523+CHECK TABLE t1;
524+Table Op Msg_type Msg_text
525+test.t1 check status OK
526+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
527+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
528+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
529+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
530+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
531+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
532+should_be_1
533+1
534+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
535+should_be_0
536+0
537+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
538+should_be_0
539+0
540+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
541+should_be_0
542+0
543+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
544+should_be_0
545+0
546+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
547+should_be_0
548+0
549+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
550+should_be_0
551+0
552 INSERT INTO t1 VALUES (1), (2);
553-COMMIT;
554 CREATE TABLE t2 (a INT PRIMARY KEY, b INT, INDEX b_ind (b),
555 FOREIGN KEY (b) REFERENCES t1(a) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
556 INSERT INTO t2 VALUES (1, 1);
557 INSERT INTO t2 VALUES (2, 2);
558-COMMIT;
559+SELECT @@global.userstat = 1 AS should_be_1;
560+should_be_1
561+1
562+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
563+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
564+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
565+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
566+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
567+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
568 SET innodb_fake_changes=1;
569+BEGIN;
570 DELETE FROM t1 WHERE a=1;
571 UPDATE t1 SET a=3 WHERE a=2;
572 COMMIT;
573 ERROR HY000: Got error 131 during COMMIT
574+SET innodb_fake_changes=0;
575+CHECK TABLE t1;
576+Table Op Msg_type Msg_text
577+test.t1 check status OK
578+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
579+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
580+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
581+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
582+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
583+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
584 should_be_1
585 1
586-should_be_0
587-0
588-should_be_0
589-0
590-should_be_0
591-0
592-should_be_0
593-0
594-should_be_0
595-0
596-SET innodb_fake_changes=0;
597+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
598+should_be_0
599+0
600+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
601+should_be_0
602+0
603+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
604+should_be_0
605+0
606+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
607+should_be_0
608+0
609+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
610+should_be_0
611+0
612+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
613+should_be_0
614+0
615 DROP TABLE t2;
616 CREATE TABLE t3 (a INT primary key, b text) ENGINE=InnoDB;
617 INSERT INTO t3 VALUES (1,'');
618-COMMIT;
619+SELECT @@global.userstat = 1 AS should_be_1;
620+should_be_1
621+1
622+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
623+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
624+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
625+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
626+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
627+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
628 SET innodb_fake_changes=1;
629+BEGIN;
630 UPDATE t3 set b=lpad('b',11000,'c') where a=1;
631 COMMIT;
632 ERROR HY000: Got error 131 during COMMIT
633-SET innodb_fake_changes=default;
634-# Verify that the fake changes to t3 did not leak through
635+SET innodb_fake_changes=0;
636 CHECK TABLE t3;
637 Table Op Msg_type Msg_text
638 test.t3 check status OK
639+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
640+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
641+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
642+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
643+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
644+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't3';
645 should_be_1
646 1
647+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
648+should_be_0
649+0
650+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
651+should_be_0
652+0
653+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
654+should_be_0
655+0
656+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
657+should_be_0
658+0
659+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
660+should_be_0
661+0
662+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
663+should_be_0
664+0
665 DROP TABLE t1, t3;
666 SET @@GLOBAL.userstat= default;
667
668=== modified file 'Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_898306.result'
669--- Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_898306.result 2012-10-17 11:30:19 +0000
670+++ Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_898306.result 2013-10-17 07:55:49 +0000
671@@ -1,7 +1,17 @@
672 DROP TABLE IF EXISTS t1;
673+SET @@GLOBAL.userstat=ON;
674 CREATE TABLE t1 (a INT primary key, b int, unique key (b)) ENGINE=InnoDB;
675 INSERT INTO t1 VALUES (1,1);
676 SET autocommit=1;
677+SELECT @@global.userstat = 1 AS should_be_1;
678+should_be_1
679+1
680+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
681+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
682+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
683+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
684+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
685+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
686 SET innodb_fake_changes=1;
687 # Confirm that duplicate key errors on REPLACE works
688 REPLACE INTO t1 VALUES (1,1);
689@@ -34,10 +44,34 @@
690 INSERT INTO t1 VALUES (1,2) ON DUPLICATE KEY UPDATE b=b+10;
691 ERROR HY000: Got error 131 during COMMIT
692 SET innodb_fake_changes=0;
693-SELECT * from t1;
694-a b
695-1 1
696 CHECK TABLE t1;
697 Table Op Msg_type Msg_text
698 test.t1 check status OK
699+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
700+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
701+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
702+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
703+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
704+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
705+should_be_1
706+1
707+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
708+should_be_0
709+0
710+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
711+should_be_0
712+0
713+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
714+should_be_0
715+0
716+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
717+should_be_0
718+0
719+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
720+should_be_0
721+0
722+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
723+should_be_0
724+0
725 DROP TABLE t1;
726+SET @@GLOBAL.userstat=default;
727
728=== modified file 'Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_917942.result'
729--- Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_917942.result 2012-10-16 11:18:45 +0000
730+++ Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_917942.result 2013-10-17 07:55:49 +0000
731@@ -1,7 +1,17 @@
732 DROP TABLE IF EXISTS t1;
733+SET @@GLOBAL.userstat=ON;
734 Test compressed
735 CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, v VARCHAR(200), t TEXT) ENGINE=INNODB KEY_BLOCK_SIZE=8;
736 INSERT INTO t1 VALUES(NULL, LPAD("v", 2, "b"), LPAD("a", 100, "b"));
737+SELECT @@global.userstat = 1 AS should_be_1;
738+should_be_1
739+1
740+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
741+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
742+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
743+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
744+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
745+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
746 SET innodb_fake_changes=1;
747 INSERT INTO t1 VALUES(1, "foo", LPAD("a", 4600, "b")) ON DUPLICATE KEY UPDATE T = VALUES(T);
748 ERROR HY000: Got error 131 during COMMIT
749@@ -11,12 +21,45 @@
750 CHECK TABLE t1;
751 Table Op Msg_type Msg_text
752 test.t1 check status OK
753+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
754+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
755+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
756+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
757+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
758+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
759 should_be_1
760 1
761+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
762+should_be_0
763+0
764+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
765+should_be_0
766+0
767+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
768+should_be_0
769+0
770+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
771+should_be_0
772+0
773+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
774+should_be_0
775+0
776+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
777+should_be_0
778+0
779 DROP TABLE t1;
780 Test for uncompressed
781 CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, v VARCHAR(200), t TEXT) ENGINE=INNODB;
782 INSERT INTO t1 VALUES(NULL, LPAD("v", 2, "b"), LPAD("a", 100, "b"));
783+SELECT @@global.userstat = 1 AS should_be_1;
784+should_be_1
785+1
786+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
787+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
788+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
789+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
790+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
791+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
792 SET innodb_fake_changes=1;
793 ERROR HY000: Got error 131 during COMMIT
794 ERROR HY000: Got error 131 during COMMIT
795@@ -122,11 +165,44 @@
796 CHECK TABLE t1;
797 Table Op Msg_type Msg_text
798 test.t1 check status OK
799+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
800+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
801+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
802+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
803+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
804+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
805 should_be_1
806 1
807+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
808+should_be_0
809+0
810+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
811+should_be_0
812+0
813+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
814+should_be_0
815+0
816+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
817+should_be_0
818+0
819+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
820+should_be_0
821+0
822+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
823+should_be_0
824+0
825 DROP TABLE t1;
826 CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, v VARCHAR(200), t TEXT) ENGINE=INNODB KEY_BLOCK_SIZE=8;
827 INSERT INTO t1 VALUES(2, LPAD("v", 2, "b"), LPAD("a", 200, "b"));
828+SELECT @@global.userstat = 1 AS should_be_1;
829+should_be_1
830+1
831+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
832+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_deleted';
833+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_updated';
834+SELECT ROWS INTO @table_rows_estimate_1 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
835+SELECT ROWS_CHANGED INTO @table_rows_changed_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
836+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_1 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
837 SET innodb_fake_changes=1;
838 INSERT INTO t1 VALUES (3, "foo", LPAD("a", 4600, "b"));
839 ERROR HY000: Got error 131 during COMMIT
840@@ -134,8 +210,32 @@
841 CHECK TABLE t1;
842 Table Op Msg_type Msg_text
843 test.t1 check status OK
844+SELECT VARIABLE_VALUE INTO @innodb_rows_inserted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_rows_inserted';
845+SELECT VARIABLE_VALUE INTO @innodb_rows_deleted_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted';
846+SELECT VARIABLE_VALUE INTO @innodb_rows_updated_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated';
847+SELECT ROWS INTO @table_rows_estimate_2 FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
848+SELECT ROWS_CHANGED INTO @table_rows_changed_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
849+SELECT ROWS_CHANGED_X_INDEXES INTO @table_rows_changed_x_indexes_2 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1';
850 should_be_1
851 1
852+SELECT @innodb_rows_inserted_2 - @innodb_rows_inserted_1 AS should_be_0;
853+should_be_0
854+0
855+SELECT @innodb_rows_deleted_2 - @innodb_rows_deleted_1 AS should_be_0;
856+should_be_0
857+0
858+SELECT @innodb_rows_updated_2 - @innodb_rows_updated_1 AS should_be_0;
859+should_be_0
860+0
861+SELECT @table_rows_estimate_2 - @table_rows_estimate_1 AS should_be_0;
862+should_be_0
863+0
864+SELECT @table_rows_changed_2 - @table_rows_changed_1 AS should_be_0;
865+should_be_0
866+0
867+SELECT @table_rows_changed_x_indexes_2 - @table_rows_changed_x_indexes_1 AS should_be_0;
868+should_be_0
869+0
870 DROP TABLE t1;
871 CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, v VARCHAR(200), t TEXT) ENGINE=INNODB;
872 INSERT INTO t1 VALUES(2, LPAD("v", 3, "b"), LPAD("a", 100, "b"));
873@@ -149,3 +249,4 @@
874 should_be_1
875 1
876 DROP TABLE t1;
877+SET @@GLOBAL.userstat=default;
878
879=== modified file 'Percona-Server/mysql-test/t/percona_innodb_fake_changes.test'
880--- Percona-Server/mysql-test/t/percona_innodb_fake_changes.test 2012-10-17 11:56:00 +0000
881+++ Percona-Server/mysql-test/t/percona_innodb_fake_changes.test 2013-10-17 07:55:49 +0000
882@@ -4,7 +4,6 @@
883 DROP TABLE IF EXISTS t1, t2, t3;
884 --enable_warnings
885
886-
887 --echo # Checking variables
888 SHOW VARIABLES LIKE 'innodb_fake_changes';
889 SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='innodb_fake_changes';
890@@ -17,20 +16,13 @@
891
892 --echo # Explicit COMMIT should fail when innodb_fake_changes is enabled
893 --echo # DML should be fine
894-SET @@GLOBAL.userstat= TRUE;
895+SET @@GLOBAL.userstat=TRUE;
896 CREATE TABLE t1 (a INT) ENGINE=InnoDB;
897 INSERT INTO t1 VALUES (1);
898
899-let $t1_checksum_1= `CHECKSUM TABLE t1 EXTENDED`;
900-let $innodb_rows_inserted_1= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_inserted'`;
901-let $innodb_rows_deleted_1= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted'`;
902-let $innodb_rows_updated_1= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated'`;
903-let $table_rows_estimate_1= `SELECT ROWS FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1'`;
904-let $table_rows_changed_1= `SELECT ROWS_CHANGED FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1'`;
905-let $table_rows_changed_x_indexes_1= `SELECT ROWS_CHANGED_X_INDEXES FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1'`;
906+--let $fake_changes_table=t1
907+--source include/start_fake_changes.inc
908
909-SET autocommit=0;
910-SET innodb_fake_changes=1;
911 BEGIN;
912 INSERT INTO t1 VALUES (2);
913 UPDATE t1 SET a=0;
914@@ -38,102 +30,339 @@
915 SELECT * FROM t1;
916 --error 1180
917 COMMIT;
918-SET innodb_fake_changes=default;
919---echo # Verify that the fake changes to t1 did not leak through
920-CHECK TABLE t1;
921-let $t1_checksum_2= `CHECKSUM TABLE t1 EXTENDED`;
922-let $innodb_rows_inserted_2= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_inserted'`;
923-let $innodb_rows_deleted_2= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted'`;
924-let $innodb_rows_updated_2= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated'`;
925-let $table_rows_estimate_2= `SELECT ROWS FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1'`;
926-let $table_rows_changed_2= `SELECT ROWS_CHANGED FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1'`;
927-let $table_rows_changed_x_indexes_2= `SELECT ROWS_CHANGED_X_INDEXES FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't1'`;
928---disable_query_log
929-eval SELECT "$t1_checksum_1" LIKE "$t1_checksum_2" AS should_be_1;
930-eval SELECT "$innodb_rows_inserted_2" - "$innodb_rows_inserted_1" AS should_be_0;
931-eval SELECT "$innodb_rows_deleted_2" - "$innodb_rows_deleted_1" AS should_be_0;
932-eval SELECT "$innodb_rows_updated_2" - "$innodb_rows_updated_1" AS should_be_0;
933-eval SELECT "$table_rows_estimate_2" - "$table_rows_estimate_1" AS should_be_0;
934-eval SELECT "$table_rows_changed_2" - "$table_rows_changed_1" AS should_be_0;
935-eval SELECT "$table_rows_changed_x_indexes_2" - "$table_rows_changed_x_indexes_1" AS should_be_0;
936---enable_query_log
937-DROP TABLE t1;
938+
939+--source include/stop_fake_changes.inc
940+
941+DROP TABLE t1;
942+
943+#
944+# Test primary and secondary index access
945+#
946+CREATE TABLE t1 (a INT PRIMARY KEY, b INT, UNIQUE KEY (b)) ENGINE=InnoDB;
947+INSERT INTO t1 VALUES (1,1);
948+
949+--source include/start_fake_changes.inc
950+
951+# Test with autocommit
952+--error ER_ERROR_DURING_COMMIT
953+SELECT * FROM t1;
954+--error ER_ERROR_DURING_COMMIT
955+INSERT INTO t1 VALUES (2,2);
956+--error ER_DUP_ENTRY
957+UPDATE t1 SET a=0 where b=1;
958+--error ER_ERROR_DURING_COMMIT
959+UPDATE t1 SET b=0 where a=1;
960+--error ER_ERROR_DURING_COMMIT
961+UPDATE t1 SET b=0 where a=2;
962+--error ER_ERROR_DURING_COMMIT
963+DELETE FROM t1 where b=2;
964+--error ER_ERROR_DURING_COMMIT
965+DELETE FROM t1 where b=1;
966+--error ER_ERROR_DURING_COMMIT
967+DELETE FROM t1 where a=2;
968+--error ER_ERROR_DURING_COMMIT
969+DELETE FROM t1 where a=1;
970+--error ER_ERROR_DURING_COMMIT
971+REPLACE INTO t1 values (2,3);
972+
973+# Test with transactions
974+BEGIN;
975+SELECT * FROM t1;
976+--error ER_ERROR_DURING_COMMIT
977+COMMIT;
978+
979+BEGIN;
980+INSERT INTO t1 VALUES (2,2);
981+--error ER_ERROR_DURING_COMMIT
982+COMMIT;
983+
984+BEGIN;
985+--error ER_DUP_ENTRY
986+UPDATE t1 SET a=0 where b=1;
987+--error ER_ERROR_DURING_COMMIT
988+COMMIT;
989+
990+BEGIN;
991+UPDATE t1 SET b=0 where a=1;
992+--error ER_ERROR_DURING_COMMIT
993+COMMIT;
994+
995+BEGIN;
996+UPDATE t1 SET b=0 where a=2;
997+--error ER_ERROR_DURING_COMMIT
998+COMMIT;
999+
1000+BEGIN;
1001+DELETE FROM t1 where b=2;
1002+--error ER_ERROR_DURING_COMMIT
1003+COMMIT;
1004+
1005+BEGIN;
1006+DELETE FROM t1 where b=1;
1007+--error ER_ERROR_DURING_COMMIT
1008+COMMIT;
1009+
1010+BEGIN;
1011+DELETE FROM t1 where a=2;
1012+--error ER_ERROR_DURING_COMMIT
1013+COMMIT;
1014+
1015+BEGIN;
1016+DELETE FROM t1 where a=1;
1017+--error ER_ERROR_DURING_COMMIT
1018+COMMIT;
1019+
1020+BEGIN;
1021+REPLACE INTO t1 values (2,3);
1022+--error ER_ERROR_DURING_COMMIT
1023+COMMIT;
1024+
1025+--error ER_ERROR_DURING_COMMIT
1026+INSERT INTO t1 VALUES (1,1) ON DUPLICATE KEY UPDATE b=2;
1027+--error ER_ERROR_DURING_COMMIT
1028+CREATE INDEX bx ON t1(b);
1029+
1030+--source include/stop_fake_changes.inc
1031+
1032+DROP TABLE t1;
1033+
1034+#
1035+# Test all accesses through the primary index
1036+#
1037+CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
1038+INSERT INTO t2 VALUES (1, 1);
1039+
1040+--let $fake_changes_table=t2
1041+--source include/start_fake_changes.inc
1042+
1043+# Test with autocommit
1044+--error ER_ERROR_DURING_COMMIT
1045+SELECT * FROM t2;
1046+--error ER_ERROR_DURING_COMMIT
1047+INSERT INTO t2 VALUES (2,2);
1048+--error ER_ERROR_DURING_COMMIT
1049+UPDATE t2 SET b=0 where a=1;
1050+--error ER_ERROR_DURING_COMMIT
1051+UPDATE t2 SET b=0 where a=2;
1052+--error ER_ERROR_DURING_COMMIT
1053+DELETE FROM t2 where b=2;
1054+--error ER_ERROR_DURING_COMMIT
1055+DELETE FROM t2 where b=1;
1056+--error ER_ERROR_DURING_COMMIT
1057+DELETE FROM t2 where a=2;
1058+--error ER_ERROR_DURING_COMMIT
1059+DELETE FROM t2 where a=1;
1060+--error ER_ERROR_DURING_COMMIT
1061+REPLACE INTO t2 values (2,3);
1062+--error ER_ERROR_DURING_COMMIT
1063+REPLACE INTO t2 VALUES (1,1);
1064+--error ER_ERROR_DURING_COMMIT
1065+REPLACE INTO t2 VALUES (1,2);
1066+
1067+# Test with transactions
1068+BEGIN;
1069+SELECT * FROM t2;
1070+--error ER_ERROR_DURING_COMMIT
1071+COMMIT;
1072+
1073+BEGIN;
1074+INSERT INTO t2 VALUES (2,2);
1075+--error ER_ERROR_DURING_COMMIT
1076+COMMIT;
1077+
1078+BEGIN;
1079+UPDATE t2 SET b=0 where a=1;
1080+--error ER_ERROR_DURING_COMMIT
1081+COMMIT;
1082+
1083+BEGIN;
1084+UPDATE t2 SET b=0 where a=2;
1085+--error ER_ERROR_DURING_COMMIT
1086+COMMIT;
1087+
1088+BEGIN;
1089+DELETE FROM t2 where b=2;
1090+--error ER_ERROR_DURING_COMMIT
1091+COMMIT;
1092+
1093+BEGIN;
1094+DELETE FROM t2 where b=1;
1095+--error ER_ERROR_DURING_COMMIT
1096+COMMIT;
1097+
1098+BEGIN;
1099+DELETE FROM t2 where a=2;
1100+--error ER_ERROR_DURING_COMMIT
1101+COMMIT;
1102+
1103+BEGIN;
1104+DELETE FROM t2 where a=1;
1105+--error ER_ERROR_DURING_COMMIT
1106+COMMIT;
1107+
1108+BEGIN;
1109+REPLACE INTO t2 values (2,3);
1110+--error ER_ERROR_DURING_COMMIT
1111+COMMIT;
1112+
1113+BEGIN;
1114+REPLACE INTO t2 VALUES (1,1);
1115+--error ER_ERROR_DURING_COMMIT
1116+COMMIT;
1117+
1118+BEGIN;
1119+REPLACE INTO t2 VALUES (1,2);
1120+--error ER_ERROR_DURING_COMMIT
1121+COMMIT;
1122+
1123+# Confirm that duplicate key errors are OK
1124+BEGIN;
1125+REPLACE INTO t2 VALUES (1,2);
1126+SELECT * from t2;
1127+REPLACE INTO t2 VALUES (1,1);
1128+SELECT * from t2;
1129+ROLLBACK;
1130+
1131+BEGIN;
1132+--error ER_DUP_ENTRY
1133+INSERT INTO t2 VALUES (1,1);
1134+--error ER_DUP_ENTRY
1135+INSERT INTO t2 VALUES (1,2);
1136+ROLLBACK;
1137+
1138+--error ER_ERROR_DURING_COMMIT
1139+INSERT INTO t2 VALUES (1,1) ON DUPLICATE KEY UPDATE b=2;
1140+--error ER_ERROR_DURING_COMMIT
1141+INSERT INTO t2 VALUES (1,1) ON DUPLICATE KEY UPDATE b=b+10;
1142+--error ER_ERROR_DURING_COMMIT
1143+INSERT INTO t2 VALUES (1,2) ON DUPLICATE KEY UPDATE b=b+10;
1144+--error ER_ERROR_DURING_COMMIT
1145+CREATE INDEX bx ON t2(b);
1146+
1147+--source include/stop_fake_changes.inc
1148+
1149+DROP TABLE t2;
1150+
1151+#
1152+# Test TEXT
1153+#
1154+CREATE TABLE t3 (a INT PRIMARY KEY, B TEXT) ENGINE=InnoDB;
1155+INSERT INTO t3 VALUES (1, '');
1156+
1157+--let $fake_changes_table=t3
1158+--source include/start_fake_changes.inc
1159+
1160+# Test with autocommit
1161+--error ER_ERROR_DURING_COMMIT
1162+SELECT * FROM t3;
1163+--error ER_ERROR_DURING_COMMIT
1164+INSERT INTO t3 VALUES (2,lpad('a',10000, 'b'));
1165+--error ER_ERROR_DURING_COMMIT
1166+UPDATE t3 SET a=0 where a=1;
1167+--error ER_ERROR_DURING_COMMIT
1168+DELETE FROM t3 where a=2;
1169+--error ER_ERROR_DURING_COMMIT
1170+DELETE FROM t3 where a=1;
1171+--error ER_ERROR_DURING_COMMIT
1172+REPLACE INTO t3 values (2,lpad('a',9000,'q'));
1173+--error ER_ERROR_DURING_COMMIT
1174+INSERT INTO t3 VALUES (1,1) ON DUPLICATE KEY UPDATE b=lpad('b',11000,'c');
1175+
1176+# Test with transactions
1177+BEGIN;
1178+SELECT * FROM t3;
1179+--error ER_ERROR_DURING_COMMIT
1180+COMMIT;
1181+
1182+BEGIN;
1183+INSERT INTO t3 VALUES (2,lpad('a',10000, 'b'));
1184+--error ER_ERROR_DURING_COMMIT
1185+COMMIT;
1186+
1187+BEGIN;
1188+UPDATE t3 SET a=0 where a=1;
1189+--error ER_ERROR_DURING_COMMIT
1190+COMMIT;
1191+
1192+BEGIN;
1193+DELETE FROM t3 where a=2;
1194+--error ER_ERROR_DURING_COMMIT
1195+COMMIT;
1196+
1197+BEGIN;
1198+DELETE FROM t3 where a=1;
1199+--error ER_ERROR_DURING_COMMIT
1200+COMMIT;
1201+
1202+BEGIN;
1203+REPLACE INTO t3 values (2,lpad('a',9000,'q'));
1204+--error ER_ERROR_DURING_COMMIT
1205+COMMIT;
1206+
1207+BEGIN;
1208+INSERT INTO t3 VALUES (1,1) ON DUPLICATE KEY UPDATE b=lpad('b',11000,'c');
1209+--error ER_ERROR_DURING_COMMIT
1210+COMMIT;
1211+
1212+--source include/stop_fake_changes.inc
1213+
1214+DROP TABLE t3;
1215
1216 --echo # DDL must result in error
1217 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
1218-SET autocommit=0;
1219-SET innodb_fake_changes=1;
1220+
1221+--let $fake_changes_table=t1
1222+--source include/start_fake_changes.inc
1223+
1224 BEGIN;
1225 --error 1005
1226 CREATE TABLE t2 (a INT) ENGINE=InnoDB;
1227 --error 1051
1228 DROP TABLE t1;
1229---error 1180
1230+--error 1031
1231 TRUNCATE TABLE t1;
1232 --error 1180
1233 ALTER TABLE t1 ENGINE=MyISAM;
1234 ROLLBACK;
1235
1236+--source include/stop_fake_changes.inc
1237+
1238 # Test stat counters foreign key constraints
1239-SET innodb_fake_changes=0;
1240 INSERT INTO t1 VALUES (1), (2);
1241-COMMIT;
1242+
1243 CREATE TABLE t2 (a INT PRIMARY KEY, b INT, INDEX b_ind (b),
1244 FOREIGN KEY (b) REFERENCES t1(a) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
1245 INSERT INTO t2 VALUES (1, 1);
1246 INSERT INTO t2 VALUES (2, 2);
1247-COMMIT;
1248-
1249-let $t2_checksum_1= `CHECKSUM TABLE t2 EXTENDED`;
1250-let $innodb_rows_deleted_1= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted'`;
1251-let $innodb_rows_updated_1= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated'`;
1252-let $table_rows_estimate_1= `SELECT ROWS FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2'`;
1253-let $table_rows_changed_1= `SELECT ROWS_CHANGED FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2'`;
1254-let $table_rows_changed_x_indexes_1= `SELECT ROWS_CHANGED_X_INDEXES FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2'`;
1255-
1256-SET innodb_fake_changes=1;
1257+
1258+--let $fake_changes_table=t1
1259+--source include/start_fake_changes.inc
1260+
1261+BEGIN;
1262 DELETE FROM t1 WHERE a=1;
1263 UPDATE t1 SET a=3 WHERE a=2;
1264 --error 1180
1265 COMMIT;
1266
1267-let $t2_checksum_2= `CHECKSUM TABLE t2 EXTENDED`;
1268-let $innodb_rows_deleted_2= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_deleted'`;
1269-let $innodb_rows_updated_2= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Innodb_rows_updated'`;
1270-let $table_rows_estimate_2= `SELECT ROWS FROM INFORMATION_SCHEMA.INNODB_TABLE_STATS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2'`;
1271-let $table_rows_changed_2= `SELECT ROWS_CHANGED FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2'`;
1272-let $table_rows_changed_x_indexes_2= `SELECT ROWS_CHANGED_X_INDEXES FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_SCHEMA LIKE 'test' AND TABLE_NAME LIKE 't2'`;
1273-
1274---disable_query_log
1275-eval SELECT "$t2_checksum_1" LIKE "$t2_checksum_2" AS should_be_1;
1276-eval SELECT "$innodb_rows_deleted_2" - "$innodb_rows_deleted_1" AS should_be_0;
1277-eval SELECT "$innodb_rows_updated_2" - "$innodb_rows_updated_1" AS should_be_0;
1278-eval SELECT "$table_rows_estimate_2" - "$table_rows_estimate_1" AS should_be_0;
1279-eval SELECT "$table_rows_changed_2" - "$table_rows_changed_1" AS should_be_0;
1280-eval SELECT "$table_rows_changed_x_indexes_2" - "$table_rows_changed_x_indexes_1" AS should_be_0;
1281---enable_query_log
1282-
1283-SET innodb_fake_changes=0;
1284+--source include/stop_fake_changes.inc
1285+
1286 DROP TABLE t2;
1287
1288 # Test for bug 890404: uninitialized value warning in btr_cur_pessimistic_update
1289 CREATE TABLE t3 (a INT primary key, b text) ENGINE=InnoDB;
1290 INSERT INTO t3 VALUES (1,'');
1291-COMMIT;
1292 let $t3_checksum_1= `CHECKSUM TABLE t3 EXTENDED`;
1293-SET innodb_fake_changes=1;
1294-
1295+
1296+--let $fake_changes_table=t3
1297+--source include/start_fake_changes.inc
1298+
1299+BEGIN;
1300 UPDATE t3 set b=lpad('b',11000,'c') where a=1;
1301 --error ER_ERROR_DURING_COMMIT
1302 COMMIT;
1303
1304-SET innodb_fake_changes=default;
1305---echo # Verify that the fake changes to t3 did not leak through
1306-CHECK TABLE t3;
1307-let $t3_checksum_2= `CHECKSUM TABLE t3 EXTENDED`;
1308---disable_query_log
1309-eval SELECT "$t3_checksum_1" LIKE "$t3_checksum_2" AS should_be_1;
1310---enable_query_log
1311+--source include/stop_fake_changes.inc
1312+
1313 DROP TABLE t1, t3;
1314
1315 SET @@GLOBAL.userstat= default;
1316
1317=== modified file 'Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_898306.test'
1318--- Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_898306.test 2012-10-17 11:30:19 +0000
1319+++ Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_898306.test 2013-10-17 07:55:49 +0000
1320@@ -7,11 +7,15 @@
1321 DROP TABLE IF EXISTS t1;
1322 --enable_warnings
1323
1324+SET @@GLOBAL.userstat=ON;
1325+
1326 CREATE TABLE t1 (a INT primary key, b int, unique key (b)) ENGINE=InnoDB;
1327 INSERT INTO t1 VALUES (1,1);
1328
1329 SET autocommit=1;
1330-SET innodb_fake_changes=1;
1331+
1332+--let $fake_changes_table=t1
1333+--source include/start_fake_changes.inc
1334
1335 --echo # Confirm that duplicate key errors on REPLACE works
1336
1337@@ -52,8 +56,8 @@
1338 --error ER_ERROR_DURING_COMMIT
1339 INSERT INTO t1 VALUES (1,2) ON DUPLICATE KEY UPDATE b=b+10;
1340
1341-SET innodb_fake_changes=0;
1342-SELECT * from t1;
1343-CHECK TABLE t1;
1344+--source include/stop_fake_changes.inc
1345
1346 DROP TABLE t1;
1347+
1348+SET @@GLOBAL.userstat=default;
1349
1350=== modified file 'Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_917942.test'
1351--- Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_917942.test 2012-10-17 11:30:19 +0000
1352+++ Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_917942.test 2013-10-17 07:55:49 +0000
1353@@ -7,6 +7,8 @@
1354 DROP TABLE IF EXISTS t1;
1355 --enable_warnings
1356
1357+SET @@GLOBAL.userstat=ON;
1358+
1359 #
1360 # Confirm that cursor->tree_height is initialized when calling btr_cur_pessimistic_update
1361 # for transactions with innodb_fake_changes set
1362@@ -16,30 +18,25 @@
1363 CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, v VARCHAR(200), t TEXT) ENGINE=INNODB KEY_BLOCK_SIZE=8;
1364
1365 INSERT INTO t1 VALUES(NULL, LPAD("v", 2, "b"), LPAD("a", 100, "b"));
1366-let $t1_checksum_1= `CHECKSUM TABLE t1 EXTENDED`;
1367
1368-SET innodb_fake_changes=1;
1369+--let $fake_changes_table=t1
1370+--source include/start_fake_changes.inc
1371
1372 --error 1180
1373 INSERT INTO t1 VALUES(1, "foo", LPAD("a", 4600, "b")) ON DUPLICATE KEY UPDATE T = VALUES(T);
1374 --error 1180
1375 UPDATE t1 SET T = LPAD("A", 4600, "b");
1376
1377-SET innodb_fake_changes=0;
1378-CHECK TABLE t1;
1379-let $t1_checksum_2= `CHECKSUM TABLE t1 EXTENDED`;
1380---disable_query_log
1381-eval SELECT "$t1_checksum_1" LIKE "$t1_checksum_2" AS should_be_1;
1382---enable_query_log
1383+--source include/stop_fake_changes.inc
1384+
1385 DROP TABLE t1;
1386
1387 --echo Test for uncompressed
1388 CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, v VARCHAR(200), t TEXT) ENGINE=INNODB;
1389
1390 INSERT INTO t1 VALUES(NULL, LPAD("v", 2, "b"), LPAD("a", 100, "b"));
1391-let $t1_checksum_1= `CHECKSUM TABLE t1 EXTENDED`;
1392
1393-SET innodb_fake_changes=1;
1394+--source include/start_fake_changes.inc
1395
1396 --disable_query_log
1397 let $x = 50;
1398@@ -53,12 +50,8 @@
1399 }
1400 --enable_query_log
1401
1402-SET innodb_fake_changes=0;
1403-CHECK TABLE t1;
1404-let $t1_checksum_2= `CHECKSUM TABLE t1 EXTENDED`;
1405---disable_query_log
1406-eval SELECT "$t1_checksum_1" LIKE "$t1_checksum_2" AS should_be_1;
1407---enable_query_log
1408+--source include/stop_fake_changes.inc
1409+
1410 DROP TABLE t1;
1411
1412 #
1413@@ -69,19 +62,14 @@
1414 CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, v VARCHAR(200), t TEXT) ENGINE=INNODB KEY_BLOCK_SIZE=8;
1415
1416 INSERT INTO t1 VALUES(2, LPAD("v", 2, "b"), LPAD("a", 200, "b"));
1417-let $t1_checksum_1= `CHECKSUM TABLE t1 EXTENDED`;
1418
1419-SET innodb_fake_changes=1;
1420+--source include/start_fake_changes.inc
1421
1422 --error 1180
1423 INSERT INTO t1 VALUES (3, "foo", LPAD("a", 4600, "b"));
1424
1425-SET innodb_fake_changes=0;
1426-CHECK TABLE t1;
1427-let $t1_checksum_2= `CHECKSUM TABLE t1 EXTENDED`;
1428---disable_query_log
1429-eval SELECT "$t1_checksum_1" LIKE "$t1_checksum_2" AS should_be_1;
1430---enable_query_log
1431+--source include/stop_fake_changes.inc
1432+
1433 DROP TABLE t1;
1434
1435 CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, v VARCHAR(200), t TEXT) ENGINE=INNODB;
1436@@ -101,3 +89,5 @@
1437 eval SELECT "$t1_checksum_1" LIKE "$t1_checksum_2" AS should_be_1;
1438 --enable_query_log
1439 DROP TABLE t1;
1440+
1441+SET @@GLOBAL.userstat=default;
1442
1443=== modified file 'Percona-Server/mysql-test/t/percona_innodb_fake_changes_locks.test'
1444--- Percona-Server/mysql-test/t/percona_innodb_fake_changes_locks.test 2012-10-11 14:18:34 +0000
1445+++ Percona-Server/mysql-test/t/percona_innodb_fake_changes_locks.test 2013-10-17 07:55:49 +0000
1446@@ -16,6 +16,7 @@
1447 --connection conn1
1448 --echo # Verifying that X_LOCK not acquired
1449 SET autocommit=0;
1450+# Cannot use start_fake_changes.inc as conn2 issues real workload before reverting
1451 SET innodb_fake_changes=1;
1452 BEGIN;
1453 SELECT * FROM t1 FOR UPDATE;
1454
1455=== modified file 'Percona-Server/sql/handler.cc'
1456--- Percona-Server/sql/handler.cc 2013-08-22 13:16:55 +0000
1457+++ Percona-Server/sql/handler.cc 2013-10-17 07:55:49 +0000
1458@@ -1367,7 +1367,7 @@
1459 and committing the transaction in other engines.
1460 */
1461 if (! hi->is_trx_read_write()
1462- && !(ht->is_fake_change && ht->is_fake_change(ht, thd)))
1463+ && likely(!(ht->is_fake_change && ht->is_fake_change(ht, thd))))
1464 continue;
1465 /*
1466 Sic: we know that prepare() is not NULL since otherwise
1467
1468=== modified file 'Percona-Server/sql/sql_insert.cc'
1469--- Percona-Server/sql/sql_insert.cc 2013-06-27 15:35:20 +0000
1470+++ Percona-Server/sql/sql_insert.cc 2013-10-17 07:55:49 +0000
1471@@ -1758,7 +1758,7 @@
1472 2) do nothing on fake delete
1473 3) goto #1
1474 */
1475- if (table->file->is_fake_change_enabled(thd))
1476+ if (unlikely(table->file->is_fake_change_enabled(thd)))
1477 goto ok_or_after_trg_err;
1478 /* Let us attempt do write_row() once more */
1479 }
1480
1481=== modified file 'Percona-Server/storage/innobase/btr/btr0cur.c'
1482--- Percona-Server/storage/innobase/btr/btr0cur.c 2013-09-02 09:59:53 +0000
1483+++ Percona-Server/storage/innobase/btr/btr0cur.c 2013-10-17 07:55:49 +0000
1484@@ -1190,7 +1190,7 @@
1485 rec_t* rec;
1486 roll_ptr_t roll_ptr;
1487
1488- if (thr && thr_get_trx(thr)->fake_changes) {
1489+ if (UNIV_UNLIKELY(thr && thr_get_trx(thr)->fake_changes)) {
1490 /* skip LOCK, UNDO */
1491 return(DB_SUCCESS);
1492 }
1493@@ -1428,7 +1428,7 @@
1494 goto fail_err;
1495 }
1496
1497- if (thr && thr_get_trx(thr)->fake_changes) {
1498+ if (UNIV_UNLIKELY(thr && thr_get_trx(thr)->fake_changes)) {
1499 /* skip CHANGE, LOG */
1500 *big_rec = big_rec_vec;
1501 return(err); /* == DB_SUCCESS */
1502@@ -1642,7 +1642,7 @@
1503 }
1504 }
1505
1506- if (thr && thr_get_trx(thr)->fake_changes) {
1507+ if (UNIV_UNLIKELY(thr && thr_get_trx(thr)->fake_changes)) {
1508 /* skip CHANGE, LOG */
1509 if (n_extents > 0) {
1510 fil_space_release_free_extents(index->space,
1511@@ -1708,7 +1708,7 @@
1512
1513 ut_ad(cursor && update && thr && roll_ptr);
1514
1515- if (thr && thr_get_trx(thr)->fake_changes) {
1516+ if (UNIV_UNLIKELY(thr_get_trx(thr)->fake_changes)) {
1517 /* skip LOCK, UNDO */
1518 return(DB_SUCCESS);
1519 }
1520@@ -1915,7 +1915,7 @@
1521 return(FALSE);
1522 }
1523
1524- if (trx && trx->fake_changes) {
1525+ if (UNIV_UNLIKELY(trx && trx->fake_changes)) {
1526 /* Don't call page_zip_compress_write_log_no_data as that has
1527 assert which would fail. Assume there won't be a compression
1528 failure. */
1529@@ -2022,7 +2022,7 @@
1530 return(err);
1531 }
1532
1533- if (trx->fake_changes) {
1534+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1535 /* skip CHANGE, LOG */
1536 if (UNIV_LIKELY_NULL(heap)) {
1537 mem_heap_free(heap);
1538@@ -2257,7 +2257,7 @@
1539 goto err_exit;
1540 }
1541
1542- if (thr && thr_get_trx(thr)->fake_changes) {
1543+ if (UNIV_UNLIKELY(thr && thr_get_trx(thr)->fake_changes)) {
1544 /* skip CHANGE, LOG */
1545 goto err_exit; /* == DB_SUCCESS */
1546 }
1547@@ -2495,7 +2495,7 @@
1548 itself. Thus the following call is safe. */
1549 row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update,
1550 FALSE, *heap);
1551- if (!(flags & BTR_KEEP_SYS_FLAG) && !trx->fake_changes) {
1552+ if (!(flags & BTR_KEEP_SYS_FLAG) && UNIV_LIKELY(!trx->fake_changes)) {
1553 row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR,
1554 roll_ptr);
1555 row_upd_index_entry_sys_field(new_entry, index, DATA_TRX_ID,
1556@@ -2553,7 +2553,7 @@
1557 ut_ad(flags & BTR_KEEP_POS_FLAG);
1558 }
1559
1560- if (trx->fake_changes) {
1561+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1562 /* skip CHANGE, LOG */
1563 err = DB_SUCCESS;
1564 goto return_after_reservations;
1565@@ -2889,7 +2889,7 @@
1566 ut_ad(dict_index_is_clust(index));
1567 ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets)));
1568
1569- if (thr && thr_get_trx(thr)->fake_changes) {
1570+ if (UNIV_UNLIKELY(thr && thr_get_trx(thr)->fake_changes)) {
1571 /* skip LOCK, UNDO, CHANGE, LOG */
1572 return(DB_SUCCESS);
1573 }
1574@@ -3028,7 +3028,7 @@
1575 rec_t* rec;
1576 ulint err;
1577
1578- if (thr && thr_get_trx(thr)->fake_changes) {
1579+ if (UNIV_UNLIKELY(thr && thr_get_trx(thr)->fake_changes)) {
1580 /* skip LOCK, CHANGE, LOG */
1581 return(DB_SUCCESS);
1582 }
1583
1584=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
1585--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-10-14 11:43:25 +0000
1586+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-10-17 07:55:49 +0000
1587@@ -1097,7 +1097,7 @@
1588 ha_innobase::is_fake_change_enabled(THD* thd)
1589 {
1590 trx_t* trx = thd_to_trx(thd);
1591- return(trx && trx->fake_changes);
1592+ return(trx && UNIV_UNLIKELY(trx->fake_changes));
1593 }
1594
1595 /********************************************************************//**
1596@@ -3374,7 +3374,7 @@
1597 whom the transaction is being committed */
1598 {
1599 trx_t* trx = check_trx_exists(thd);
1600- return trx->fake_changes;
1601+ return UNIV_UNLIKELY(trx->fake_changes);
1602 }
1603
1604
1605@@ -3616,7 +3616,10 @@
1606 /* No-op in XtraDB */
1607 trx_search_latch_release_if_reserved(trx);
1608
1609- if (trx->fake_changes && (all || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
1610+ if (UNIV_UNLIKELY(trx->fake_changes
1611+ && (all || (!thd_test_options(thd,
1612+ OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))))) {
1613+
1614 innobase_rollback(hton, thd, all); /* rollback implicitly */
1615 thd->stmt_da->reset_diagnostics_area(); /* because debug assertion code complains, if something left */
1616 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
1617@@ -8195,7 +8198,7 @@
1618
1619 trx = innobase_trx_allocate(thd);
1620
1621- if (trx->fake_changes) {
1622+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1623 innobase_commit_low(trx);
1624 trx_free_for_mysql(trx);
1625 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
1626@@ -8422,7 +8425,7 @@
1627 DBUG_RETURN(HA_ERR_CRASHED);
1628 }
1629
1630- if (prebuilt->trx->fake_changes) {
1631+ if (UNIV_UNLIKELY(prebuilt->trx->fake_changes)) {
1632 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
1633 }
1634
1635@@ -8487,7 +8490,7 @@
1636
1637 trx = innobase_trx_allocate(thd);
1638
1639- if (trx->fake_changes) {
1640+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1641 innobase_commit_low(trx);
1642 trx_free_for_mysql(trx);
1643 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
1644@@ -8579,13 +8582,13 @@
1645 trx->mysql_thd = NULL;
1646 #else
1647 trx = innobase_trx_allocate(thd);
1648- if (trx->fake_changes) {
1649+#endif
1650+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1651 my_free(namebuf);
1652 innobase_commit_low(trx);
1653 trx_free_for_mysql(trx);
1654 return; /* ignore */
1655 }
1656-#endif
1657 row_drop_database_for_mysql(namebuf, trx);
1658 my_free(namebuf);
1659
1660@@ -8698,7 +8701,7 @@
1661 trx_search_latch_release_if_reserved(parent_trx);
1662
1663 trx = innobase_trx_allocate(thd);
1664- if (trx->fake_changes) {
1665+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1666 innobase_commit_low(trx);
1667 trx_free_for_mysql(trx);
1668 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
1669
1670=== modified file 'Percona-Server/storage/innobase/handler/handler0alter.cc'
1671--- Percona-Server/storage/innobase/handler/handler0alter.cc 2013-08-02 09:40:55 +0000
1672+++ Percona-Server/storage/innobase/handler/handler0alter.cc 2013-10-17 07:55:49 +0000
1673@@ -697,7 +697,7 @@
1674 possible adaptive hash latch to avoid deadlocks of threads. */
1675 trx_search_latch_release_if_reserved(prebuilt->trx);
1676
1677- if (prebuilt->trx->fake_changes) {
1678+ if (UNIV_UNLIKELY(prebuilt->trx->fake_changes)) {
1679 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
1680 }
1681
1682@@ -743,7 +743,7 @@
1683 /* Create a background transaction for the operations on
1684 the data dictionary tables. */
1685 trx = innobase_trx_allocate(user_thd);
1686- if (trx->fake_changes) {
1687+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1688 mem_heap_free(heap);
1689 trx_general_rollback_for_mysql(trx, NULL);
1690 trx_free_for_mysql(trx);
1691@@ -1117,7 +1117,7 @@
1692 trx_search_latch_release_if_reserved(prebuilt->trx);
1693 trx = prebuilt->trx;
1694
1695- if (trx->fake_changes) {
1696+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1697 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
1698 }
1699
1700@@ -1329,7 +1329,7 @@
1701 /* Create a background transaction for the operations on
1702 the data dictionary tables. */
1703 trx = innobase_trx_allocate(user_thd);
1704- if (trx->fake_changes) {
1705+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1706 trx_general_rollback_for_mysql(trx, NULL);
1707 trx_free_for_mysql(trx);
1708 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
1709
1710=== modified file 'Percona-Server/storage/innobase/lock/lock0lock.c'
1711--- Percona-Server/storage/innobase/lock/lock0lock.c 2013-08-14 03:52:04 +0000
1712+++ Percona-Server/storage/innobase/lock/lock0lock.c 2013-10-17 07:55:49 +0000
1713@@ -4019,7 +4019,7 @@
1714
1715 trx = thr_get_trx(thr);
1716
1717- if (trx->fake_changes && mode == LOCK_IX) {
1718+ if (UNIV_UNLIKELY(trx->fake_changes && mode == LOCK_IX)) {
1719 mode = LOCK_IS;
1720 }
1721
1722@@ -5268,7 +5268,7 @@
1723
1724 trx = thr_get_trx(thr);
1725
1726- if (trx->fake_changes) {
1727+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1728 return(DB_SUCCESS);
1729 }
1730
1731@@ -5453,7 +5453,7 @@
1732 return(DB_SUCCESS);
1733 }
1734
1735- if (thr && thr_get_trx(thr)->fake_changes) {
1736+ if (UNIV_UNLIKELY(thr_get_trx(thr)->fake_changes)) {
1737 return(DB_SUCCESS);
1738 }
1739
1740@@ -5515,7 +5515,7 @@
1741 return(DB_SUCCESS);
1742 }
1743
1744- if (thr && thr_get_trx(thr)->fake_changes) {
1745+ if (UNIV_UNLIKELY(thr_get_trx(thr)->fake_changes)) {
1746 return(DB_SUCCESS);
1747 }
1748
1749@@ -5606,7 +5606,7 @@
1750 return(DB_SUCCESS);
1751 }
1752
1753- if (UNIV_UNLIKELY((thr && thr_get_trx(thr)->fake_changes))) {
1754+ if (UNIV_UNLIKELY(thr_get_trx(thr)->fake_changes)) {
1755 if (!srv_fake_changes_locks) {
1756 return(DB_SUCCESS);
1757 }
1758@@ -5691,7 +5691,7 @@
1759 return(DB_SUCCESS);
1760 }
1761
1762- if (UNIV_UNLIKELY((thr && thr_get_trx(thr)->fake_changes))) {
1763+ if (UNIV_UNLIKELY(thr_get_trx(thr)->fake_changes)) {
1764 if (!srv_fake_changes_locks) {
1765 return(DB_SUCCESS);
1766 }
1767
1768=== modified file 'Percona-Server/storage/innobase/que/que0que.c'
1769--- Percona-Server/storage/innobase/que/que0que.c 2013-08-14 03:52:04 +0000
1770+++ Percona-Server/storage/innobase/que/que0que.c 2013-10-17 07:55:49 +0000
1771@@ -1417,7 +1417,7 @@
1772
1773 ut_a(trx->error_state == DB_SUCCESS);
1774
1775- if (trx->fake_changes) {
1776+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1777 /* fake_changes should not access to system tables */
1778 fprintf(stderr, "InnoDB: ERROR: innodb_fake_changes tried to access to system tables.\n");
1779 return(DB_ERROR);
1780
1781=== modified file 'Percona-Server/storage/innobase/row/row0ins.c'
1782--- Percona-Server/storage/innobase/row/row0ins.c 2013-08-02 09:40:55 +0000
1783+++ Percona-Server/storage/innobase/row/row0ins.c 2013-10-17 07:55:49 +0000
1784@@ -1512,7 +1512,7 @@
1785 mem_heap_free(heap);
1786 }
1787
1788- if (trx->fake_changes) {
1789+ if (UNIV_UNLIKELY(trx->fake_changes)) {
1790 err = DB_SUCCESS;
1791 }
1792
1793@@ -2093,11 +2093,11 @@
1794 transaction. Let us now reposition the cursor and
1795 continue the insertion. */
1796
1797- btr_cur_search_to_nth_level(index, 0, entry,
1798- PAGE_CUR_LE,
1799- thr_get_trx(thr)->fake_changes ? BTR_SEARCH_LEAF : (mode | BTR_INSERT),
1800- &cursor, 0,
1801- __FILE__, __LINE__, &mtr);
1802+ btr_cur_search_to_nth_level(
1803+ index, 0, entry, PAGE_CUR_LE,
1804+ (UNIV_UNLIKELY(thr_get_trx(thr)->fake_changes)
1805+ ? BTR_SEARCH_LEAF : (mode | BTR_INSERT)),
1806+ &cursor, 0, __FILE__, __LINE__, &mtr);
1807 }
1808 }
1809
1810@@ -2215,7 +2215,7 @@
1811 rec_t* rec;
1812 ulint* offsets;
1813
1814- if (thr_get_trx(thr)->fake_changes) {
1815+ if (UNIV_UNLIKELY(thr_get_trx(thr)->fake_changes)) {
1816 /* skip store extern */
1817 if (modify) {
1818 dtuple_big_rec_free(big_rec);
1819
1820=== modified file 'Percona-Server/storage/innobase/row/row0upd.c'
1821--- Percona-Server/storage/innobase/row/row0upd.c 2013-08-02 09:40:55 +0000
1822+++ Percona-Server/storage/innobase/row/row0upd.c 2013-10-17 07:55:49 +0000
1823@@ -1607,7 +1607,8 @@
1824 }
1825
1826 search_result = row_search_index_entry(index, entry,
1827- trx->fake_changes ? BTR_SEARCH_LEAF : mode,
1828+ UNIV_UNLIKELY(trx->fake_changes)
1829+ ? BTR_SEARCH_LEAF : mode,
1830 &pcur, &mtr);
1831
1832 btr_cur = btr_pcur_get_btr_cur(&pcur);
1833@@ -1855,7 +1856,7 @@
1834 the previous invocation of this function. Mark the
1835 off-page columns in the entry inherited. */
1836
1837- if (!(trx->fake_changes)) {
1838+ if (UNIV_LIKELY(!trx->fake_changes)) {
1839 change_ownership = row_upd_clust_rec_by_insert_inherit(
1840 NULL, NULL, entry, node->update);
1841 ut_a(change_ownership);
1842@@ -1889,7 +1890,8 @@
1843 delete-marked old record, mark them disowned by the
1844 old record and owned by the new entry. */
1845
1846- if (rec_offs_any_extern(offsets) && !(trx->fake_changes)) {
1847+ if (rec_offs_any_extern(offsets)
1848+ && UNIV_LIKELY(!(trx->fake_changes))) {
1849 change_ownership = row_upd_clust_rec_by_insert_inherit(
1850 rec, offsets, entry, node->update);
1851
1852@@ -2019,9 +2021,10 @@
1853 the same transaction do not modify the record in the meantime.
1854 Therefore we can assert that the restoration of the cursor succeeds. */
1855
1856- ut_a(btr_pcur_restore_position(thr_get_trx(thr)->fake_changes
1857- ? BTR_SEARCH_TREE : BTR_MODIFY_TREE,
1858- pcur, mtr));
1859+ ut_a(btr_pcur_restore_position(
1860+ (UNIV_UNLIKELY(thr_get_trx(thr)->fake_changes)
1861+ ? BTR_SEARCH_TREE : BTR_MODIFY_TREE),
1862+ pcur, mtr));
1863
1864 ut_ad(!rec_get_deleted_flag(btr_pcur_get_rec(pcur),
1865 dict_table_is_comp(index->table)));
1866@@ -2032,7 +2035,8 @@
1867 node->cmpl_info, thr, mtr);
1868
1869 /* skip store extern for fake_changes */
1870- if (err == DB_SUCCESS && big_rec && !(thr_get_trx(thr)->fake_changes)) {
1871+ if (err == DB_SUCCESS && big_rec
1872+ && UNIV_LIKELY(!(thr_get_trx(thr)->fake_changes))) {
1873 ulint offsets_[REC_OFFS_NORMAL_SIZE];
1874 rec_t* rec;
1875 rec_offs_init(offsets_);
1876@@ -2192,8 +2196,10 @@
1877
1878 ut_a(pcur->rel_pos == BTR_PCUR_ON);
1879
1880- success = btr_pcur_restore_position(thr_get_trx(thr)->fake_changes ? BTR_SEARCH_LEAF : BTR_MODIFY_LEAF,
1881- pcur, mtr);
1882+ success = btr_pcur_restore_position(
1883+ (UNIV_UNLIKELY(thr_get_trx(thr)->fake_changes)
1884+ ? BTR_SEARCH_LEAF : BTR_MODIFY_LEAF),
1885+ pcur, mtr);
1886
1887 if (!success) {
1888 err = DB_RECORD_NOT_FOUND;

Subscribers

People subscribed via source and target branches