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

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: 479
Proposed branch: lp:~laurynas-biveinis/percona-server/fake-changes-from-fb-5.6
Merge into: lp:percona-server/5.6
Prerequisite: lp:~laurynas-biveinis/percona-server/fake-changes-binlog-5.6
Diff against target: 2012 lines (+1268/-191)
17 files modified
Percona-Server/mysql-test/include/start_fake_changes.inc (+37/-0)
Percona-Server/mysql-test/include/stop_fake_changes.inc (+34/-0)
Percona-Server/mysql-test/r/percona_innodb_fake_changes.result (+606/-43)
Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_898306.result (+58/-3)
Percona-Server/mysql-test/r/percona_innodb_fake_changes_bug_917942.result (+154/-0)
Percona-Server/mysql-test/t/percona_innodb_fake_changes.test (+303/-76)
Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_898306.test (+10/-4)
Percona-Server/mysql-test/t/percona_innodb_fake_changes_bug_917942.test (+16/-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.cc (+19/-16)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+11/-9)
Percona-Server/storage/innobase/lock/lock0lock.cc (+4/-4)
Percona-Server/storage/innobase/que/que0que.cc (+1/-1)
Percona-Server/storage/innobase/row/row0ins.cc (+3/-2)
Percona-Server/storage/innobase/row/row0upd.cc (+9/-7)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/fake-changes-from-fb-5.6
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve on 2013-10-17
Vlad Lesin (community) g2 2013-07-29 Approve on 2013-09-30
Laurynas Biveinis Pending
Review via email: mp+177312@code.launchpad.net

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

Description of the change

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

Same comment as for the 5.5 MP.

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

The 5.5 review comment re. redundant thr checks does not apply here, it's still reviewable.

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

Layrynas,

I think I see some places

btr0cur.cc line 2397, btr_cur_optimistic_update
lock0lock.cc line 6162, lock_clust_rec_modify_check_and_lock
lock0lock.cc line 6228, lock_sec_rec_modify_check_and_lock
que0que.cc line 6228, que_eval_sql

also, regardless this MP, there is

btr0cur.cc line 1394 -- double check of
 ut_ad((thr && thr_get_trx(thr)->fake_changes)
       || mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));

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

Laurynas, sorry for misspelling

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

Sergei -

> btr0cur.cc line 2397, btr_cur_optimistic_update
> lock0lock.cc line 6162, lock_clust_rec_modify_check_and_lock
> lock0lock.cc line 6228, lock_sec_rec_modify_check_and_lock
> que0que.cc line 6228, que_eval_sql

I reviewed them yesterday. Please show how each of them guarantees thr != NULL, because I was not able to prove that.

> btr0cur.cc line 1394 -- double check of
> ut_ad((thr && thr_get_trx(thr)->fake_changes)
> || mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));

Yup, bug 1204443.

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

thr_get_trx expects that thr is NULL

btr0cur.cc line 2397, btr_cur_optimistic_update

line 2260:
ut_ad(thr_get_trx(thr)->id == trx_id
      || (flags & ~(BTR_KEEP_POS_FLAG | BTR_KEEP_IBUF_BITMAP))
      == (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG
   | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG));
is either bug or thr should never be NULL here

lock0lock.cc line 6162, lock_clust_rec_modify_check_and_lock

line 6177:
ut_ad(lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));

lock0lock.cc line 6228, lock_sec_rec_modify_check_and_lock

line 6241:
ut_ad(lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));

que0que.cc line 6228, que_eval_sql

line 1294:
graph->trx = trx;

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

Nevermind of que0que.cc line 6228, que_eval_sql :)

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

> thr_get_trx expects that thr is NULL

(_not_ NULL)

You are right, thanks, I have reviewed and updated accordingly.

> btr0cur.cc line 2397, btr_cur_optimistic_update
>
> line 2260:
> ut_ad(thr_get_trx(thr)->id == trx_id
> || (flags & ~(BTR_KEEP_POS_FLAG | BTR_KEEP_IBUF_BITMAP))
> == (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG
> | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG));
> is either bug or thr should never be NULL here

Thanks, http://bugs.mysql.com/bug.php?id=69847.

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

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

409. By Laurynas Biveinis on 2013-08-14

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

410. By Laurynas Biveinis on 2013-08-14

Null-merge lp:percona-server/5.5 revision 558

411. By Laurynas Biveinis on 2013-08-16

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

412. By Laurynas Biveinis on 2013-08-22

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

413. By Laurynas Biveinis on 2013-08-22

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

414. By Laurynas Biveinis on 2013-08-23

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

415. By Laurynas Biveinis on 2013-08-27

Automerge lp:~laurynas-biveinis/percona-server/bug1186974

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

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

417. By <email address hidden> on 2013-08-28

Merge lp:~hrvojem/percona-server/bug1186987-5.6
http://jenkins.percona.com/job/merge-PS-5.6-docs-kickoff/24/

418. By Laurynas Biveinis on 2013-08-28

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

419. By <email address hidden> on 2013-08-28

Merge lp:~hrvojem/percona-server/rn-5.6.13-60.5
http://jenkins.percona.com/job/merge-PS-5.6-docs-kickoff/25/

420. By Laurynas Biveinis on 2013-08-29

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

421. By Laurynas Biveinis on 2013-09-06

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

422. By Laurynas Biveinis on 2013-09-09

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

423. By Laurynas Biveinis on 2013-09-09

Automerge lp:~percona-core/percona-server/release-5.6.13-60.5

424. By Alexey Kopytov on 2013-09-16

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

425. By Laurynas Biveinis on 2013-09-20

Automerge lp:~laurynas-biveinis/percona-server/bp-split-5.6

426. By Laurynas Biveinis on 2013-09-20

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

427. By <email address hidden> on 2013-09-20

Merge lp:~hrvojem/percona-server/rn-5.6.13-60.6
http://jenkins.percona.com/job/merge-PS-5.6-docs-kickoff/26/

428. By Alexey Kopytov on 2013-09-21

Merged lp:~vlad-lesin/percona-server/5.6-sql_timeout_twitter.

429. By Laurynas Biveinis on 2013-09-24

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

430. By Laurynas Biveinis on 2013-09-25

Automerge lp:~laurynas-biveinis/percona-server/bug1227581

431. By Laurynas Biveinis on 2013-09-26

Automerge lp:~ignacio-nin/percona-server/5.6-bug1159621

432. By Laurynas Biveinis on 2013-09-27

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

433. By Laurynas Biveinis on 2013-09-27

Automere lp:~gl-az/percona-server/port_ALL_O_DIRECT_to_5.6

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

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

435. By Laurynas Biveinis on 2013-09-27

Automerge lp:~laurynas-biveinis/percona-server/xtradb-thread-priority-flag

436. By Laurynas Biveinis on 2013-09-28

Merge lp:~ignacio-nin/percona-server/5.6-bug1002500

437. By Laurynas Biveinis on 2013-09-28

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

Vlad Lesin (vlad-lesin) :
review: Approve (g2)
Vlad Lesin (vlad-lesin) wrote :
438. By Laurynas Biveinis on 2013-09-30

Automerge lp:~ignacio-nin/percona-server/5.6-bug1174300

439. By Laurynas Biveinis on 2013-09-30

Automerge lp:~gl-az/percona-server/BT-23597-bug1166638-5.6

440. By <email address hidden> on 2013-10-01

Merge lp:~hrvojem/percona-server/bug1229583-5.6
http://jenkins.percona.com/job/merge-PS-5.6-docs-kickoff/29/

441. By Laurynas Biveinis on 2013-10-01

Automerge lp:~sergei.glushchenko/percona-server/5.6-ps-bug1196383

442. By Laurynas Biveinis on 2013-10-01

Automerge lp:~percona-core/percona-server/release-5.6.13-60.6

443. By Laurynas Biveinis on 2013-10-01

Automerge lp:~sergei.glushchenko/percona-server/5.6-ps-bug1194097

444. By <email address hidden> on 2013-10-01

Merge lp:~hrvojem/percona-server/bug1154619-5.6
http://jenkins.percona.com/job/merge-PS-5.6-docs-kickoff/30/

445. By Laurynas Biveinis on 2013-10-01

Automerge lp:~laurynas-biveinis/percona-server/xtradb-cleaner-tuning-5.6

446. By Laurynas Biveinis on 2013-10-02

Automerge lp:~sergei.glushchenko/percona-server/5.6-ps-bug1201033

447. By Laurynas Biveinis on 2013-10-02

Automerge lp:~sergei.glushchenko/percona-server/5.6-ps-bug1205196

448. By <email address hidden> on 2013-10-02

Merge lp:~hrvojem/percona-server/bug1133569-5.6
http://jenkins.percona.com/job/merge-PS-5.6-docs-kickoff/31/

449. By Laurynas Biveinis on 2013-10-02

Automerge lp:~laurynas-biveinis/percona-server/bug1234029

450. By Laurynas Biveinis on 2013-10-03

Automerge lp:~laurynas-biveinis/percona-server/bug1234513

451. By Laurynas Biveinis on 2013-10-03

Automerge lp:~laurynas-biveinis/percona-server/xtradb-thread-nice

452. By Laurynas Biveinis on 2013-10-03

Automerge lp:~laurynas-biveinis/percona-server/xtradb-af-lsn-age-tuning-5.6

453. By Laurynas Biveinis on 2013-10-03

Automerge lp:~laurynas-biveinis/percona-server/xtradb-srv-activity-fixes

454. By Laurynas Biveinis on 2013-10-03

Automerge lp:~laurynas-biveinis/percona-server/xtradb-preflush-backoff

455. By Laurynas Biveinis on 2013-10-04

Automerge lp:~laurynas-biveinis/percona-server/bug1234848

456. By Laurynas Biveinis on 2013-10-04

Automerge lp:~laurynas-biveinis/percona-server/bug1224432

457. By Laurynas Biveinis on 2013-10-04

Automerge lp:~laurynas-biveinis/percona-server/xtradb-empty-free-list-backoff

458. By Laurynas Biveinis on 2013-10-04

Automerge lp:~laurynas-biveinis/percona-server/bug1235114

459. By Laurynas Biveinis on 2013-10-04

Automerge lp:~laurynas-biveinis/percona-server/bug1235265

460. By Laurynas Biveinis on 2013-10-04

Automerge lp:~laurynas-biveinis/percona-server/bug1235285

461. By Laurynas Biveinis on 2013-10-05

Automerge lp:~laurynas-biveinis/percona-server/bug1235396

462. By Laurynas Biveinis on 2013-10-06

Automerge lp:~laurynas-biveinis/percona-server/bug1235379

463. By Hrvoje Matijakovic on 2013-10-07

Merged lp:~hrvojem/percona-server/page_cleaner_docs-5.6

464. By Hrvoje Matijakovic on 2013-10-07

Merged lp:~hrvojem/percona-server/bug1227611-5.6

465. By Hrvoje Matijakovic on 2013-10-07

Merged lp:~hrvojem/percona-server/rn-5.6.13-61.0

466. By Hrvoje Matijakovic on 2013-10-07

Merged lp:~hrvojem/percona-server/remove_rc-note-5.6

467. By Laurynas Biveinis on 2013-10-09

Automerge lp:~gl-az/percona-server/BT-23310-bug1218664-5.6

468. By Laurynas Biveinis on 2013-10-09

Automerge lp:~gl-az/percona-server/BT-23598-bug1167487-5.6

469. By Hrvoje Matijakovic on 2013-10-09

Merged lp:~hrvojem/percona-server/rn-5.6.13-61.0-update

470. By Laurynas Biveinis on 2013-10-10

Automerge lp:~ignacio-nin/percona-server/5.6-libmysqlclient.so

471. By Laurynas Biveinis on 2013-10-10

Automerge lp:~ignacio-nin/percona-server/5.6-bug1225189

472. By Laurynas Biveinis on 2013-10-10

Merge lp:~percona-core/percona-server/release-5.6.13-61.0

473. By Laurynas Biveinis on 2013-10-11

Automerge lp:~laurynas-biveinis/percona-server/bug1238008

474. By Laurynas Biveinis on 2013-10-14

Automerge lp:~laurynas-biveinis/percona-server/bug1239418

475. By Laurynas Biveinis on 2013-10-16

Automerge lp:~laurynas-biveinis/percona-server/bug1214727

476. By Laurynas Biveinis on 2013-10-16

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

477. By Alexey Kopytov on 2013-10-16

Automerged lp:~vlad-lesin/percona-server/5.6-per_query_variables_settings.

Stewart Smith (stewart) :
review: Approve
478. By Laurynas Biveinis on 2013-10-17

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

479. By Laurynas Biveinis on 2013-10-17

Merge bug 1190604 fix from 5.5.

480. By Laurynas Biveinis on 2013-10-17

Merge bug 1200162 changes from 5.5.

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

Subscribers

People subscribed via source and target branches