Skip to content

Commit af689d3

Browse files
author
Shaohua Wang
committed
Merge branch 'mysql-5.6' into mysql-5.7
2 parents 7f57665 + 04531c9 commit af689d3

File tree

3 files changed

+77
-7
lines changed

3 files changed

+77
-7
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CREATE PROCEDURE populate_t1()
2+
BEGIN
3+
DECLARE i int DEFAULT 1;
4+
START TRANSACTION;
5+
WHILE (i <= 1000000) DO
6+
INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
7+
SET i = i + 1;
8+
END WHILE;
9+
COMMIT;
10+
END|
11+
CREATE TABLE t1(
12+
class INT,
13+
id INT,
14+
title VARCHAR(100)
15+
) ENGINE=InnoDB;
16+
SELECT COUNT(*) FROM t1;
17+
COUNT(*)
18+
1000000
19+
SET GLOBAL innodb_stats_persistent_sample_pages=2000;
20+
ANALYZE TABLE t1;
21+
Table Op Msg_type Msg_text
22+
test.t1 analyze status OK
23+
DROP TABLE t1;
24+
DROP PROCEDURE populate_t1;
25+
SET GLOBAL innodb_stats_persistent_sample_pages=default;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# BUG#22385442 - INNODB: DIFFICULT TO FIND FREE BLOCKS IN THE BUFFER POOL
3+
#
4+
5+
--source include/have_innodb.inc
6+
--source include/big_test.inc
7+
8+
DELIMITER |;
9+
CREATE PROCEDURE populate_t1()
10+
BEGIN
11+
DECLARE i int DEFAULT 1;
12+
13+
START TRANSACTION;
14+
WHILE (i <= 1000000) DO
15+
INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
16+
SET i = i + 1;
17+
END WHILE;
18+
COMMIT;
19+
END|
20+
DELIMITER ;|
21+
22+
CREATE TABLE t1(
23+
class INT,
24+
id INT,
25+
title VARCHAR(100)
26+
) ENGINE=InnoDB;
27+
28+
-- disable_query_log
29+
CALL populate_t1();
30+
-- enable_query_log
31+
32+
SELECT COUNT(*) FROM t1;
33+
34+
SET GLOBAL innodb_stats_persistent_sample_pages=2000;
35+
36+
ANALYZE TABLE t1;
37+
38+
DROP TABLE t1;
39+
40+
DROP PROCEDURE populate_t1;
41+
42+
SET GLOBAL innodb_stats_persistent_sample_pages=default;

storage/innobase/dict/dict0stats.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,16 +1417,14 @@ on the leaf page.
14171417
when comparing records
14181418
@param[out] n_diff number of distinct records
14191419
@param[out] n_external_pages number of external pages
1420-
@param[in,out] mtr mini-transaction
14211420
@return number of distinct records on the leaf page */
14221421
static
14231422
void
14241423
dict_stats_analyze_index_below_cur(
14251424
const btr_cur_t* cur,
14261425
ulint n_prefix,
14271426
ib_uint64_t* n_diff,
1428-
ib_uint64_t* n_external_pages,
1429-
mtr_t* mtr)
1427+
ib_uint64_t* n_external_pages)
14301428
{
14311429
dict_index_t* index;
14321430
buf_block_t* block;
@@ -1437,6 +1435,7 @@ dict_stats_analyze_index_below_cur(
14371435
ulint* offsets2;
14381436
ulint* offsets_rec;
14391437
ulint size;
1438+
mtr_t mtr;
14401439

14411440
index = btr_cur_get_index(cur);
14421441

@@ -1475,12 +1474,14 @@ dict_stats_analyze_index_below_cur(
14751474
function without analyzing any leaf pages */
14761475
*n_external_pages = 0;
14771476

1477+
mtr_start(&mtr);
1478+
14781479
/* descend to the leaf level on the B-tree */
14791480
for (;;) {
14801481

14811482
block = buf_page_get_gen(page_id, page_size, RW_S_LATCH,
14821483
NULL /* no guessed block */,
1483-
BUF_GET, __FILE__, __LINE__, mtr);
1484+
BUF_GET, __FILE__, __LINE__, &mtr);
14841485

14851486
page = buf_block_get_frame(block);
14861487

@@ -1502,6 +1503,8 @@ dict_stats_analyze_index_below_cur(
15021503
ut_a(*n_diff > 0);
15031504

15041505
if (*n_diff == 1) {
1506+
mtr_commit(&mtr);
1507+
15051508
/* page has all keys equal and the end of the page
15061509
was reached by dict_stats_scan_page(), no need to
15071510
descend to the leaf level */
@@ -1527,7 +1530,7 @@ dict_stats_analyze_index_below_cur(
15271530
}
15281531

15291532
/* make sure we got a leaf page as a result from the above loop */
1530-
ut_ad(btr_page_get_level(page, mtr) == 0);
1533+
ut_ad(btr_page_get_level(page, &mtr) == 0);
15311534

15321535
/* scan the leaf page and find the number of distinct keys,
15331536
when looking only at the first n_prefix columns; also estimate
@@ -1544,6 +1547,7 @@ dict_stats_analyze_index_below_cur(
15441547
__func__, page_no, n_diff);
15451548
#endif
15461549

1550+
mtr_commit(&mtr);
15471551
mem_heap_free(heap);
15481552
}
15491553

@@ -1753,8 +1757,7 @@ dict_stats_analyze_index_for_n_prefix(
17531757
dict_stats_analyze_index_below_cur(btr_pcur_get_btr_cur(&pcur),
17541758
n_prefix,
17551759
&n_diff_on_leaf_page,
1756-
&n_external_pages,
1757-
mtr);
1760+
&n_external_pages);
17581761

17591762
/* We adjust n_diff_on_leaf_page here to avoid counting
17601763
one value twice - once as the last on some page and once

0 commit comments

Comments
 (0)