Skip to content

Commit 2147951

Browse files
MDEV-37083: Fixed type mismatch in sys views
-Replaced incorrect string comparision in views for is_hashed and is_old as these columns are integer and not string Affected Views: -innodb_buffer_stats_by_schema -innodb_buffer_stats_by_table -x_innodb_buffer_stats_by_schema -x_innodb_buffer_stats_by_table
1 parent 852e451 commit 2147951

10 files changed

+74
-27
lines changed

mysql-test/suite/encryption/r/innochecksum.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,14 @@ CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
3535
# Run innochecksum on t6
3636
# Restore the original tables
3737
# restart
38+
# Trigger AHI and test pages_hashed, pages_old as non zero from sys view
39+
SELECT STRAIGHT_JOIN COUNT(t6a.a)
40+
FROM t6 AS t6a, t6 AS t6b
41+
WHERE t6a.a = t6b.a;
42+
COUNT(t6a.a)
43+
1000
44+
SELECT SUM(pages_hashed)>0 `1`, SUM(pages_old)>0 `1`
45+
FROM sys.innodb_buffer_stats_by_table;
46+
1 1
47+
1 1
3848
DROP TABLE t1, t2, t3, t4, t5, t6;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--innodb-adaptive-hash-index=ON
2+
--innodb-buffer-pool-size=64M

mysql-test/suite/encryption/t/innochecksum.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,14 @@ if (0 && $have_debug) { # these messages sometimes fail to appear
300300
--move_file $MYSQLD_DATADIR/test/t6.ibd.backup $MYSQLD_DATADIR/test/t6.ibd
301301

302302
--source include/start_mysqld.inc
303+
304+
--echo # Trigger AHI and test pages_hashed, pages_old as non zero from sys view
305+
306+
SELECT STRAIGHT_JOIN COUNT(t6a.a)
307+
FROM t6 AS t6a, t6 AS t6b
308+
WHERE t6a.a = t6b.a;
309+
310+
SELECT SUM(pages_hashed)>0 `1`, SUM(pages_old)>0 `1`
311+
FROM sys.innodb_buffer_stats_by_table;
312+
303313
DROP TABLE t1, t2, t3, t4, t5, t6;

mysql-test/suite/sysschema/r/v_innodb_buffer_stats_by_schema.result

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ pages bigint(21) NO 0
77
pages_hashed bigint(21) NO 0
88
pages_old bigint(21) NO 0
99
rows_cached decimal(44,0) YES NULL
10-
SELECT * FROM sys.innodb_buffer_stats_by_schema;
10+
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
11+
SELECT * FROM sys.innodb_buffer_stats_by_schema
12+
where object_schema = 'test';
13+
object_schema allocated data pages pages_hashed pages_old rows_cached
14+
test 16.00 KiB 0 bytes 1 0 0 0
1115
DESC sys.x$innodb_buffer_stats_by_schema;
1216
Field Type Null Key Default Extra
1317
object_schema text YES NULL
@@ -17,4 +21,8 @@ pages bigint(21) NO 0
1721
pages_hashed bigint(21) NO 0
1822
pages_old bigint(21) NO 0
1923
rows_cached decimal(44,0) NO 0
20-
SELECT * FROM sys.x$innodb_buffer_stats_by_schema;
24+
SELECT * FROM sys.x$innodb_buffer_stats_by_schema
25+
where object_schema = 'test';
26+
object_schema allocated data pages pages_hashed pages_old rows_cached
27+
test 16384 0 1 0 0 0
28+
DROP TABLE t1;

mysql-test/suite/sysschema/r/v_innodb_buffer_stats_by_table.result

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ pages bigint(21) NO 0
88
pages_hashed bigint(21) NO 0
99
pages_old bigint(21) NO 0
1010
rows_cached decimal(44,0) YES NULL
11-
SELECT * FROM sys.innodb_buffer_stats_by_table;
11+
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
12+
SELECT * FROM sys.innodb_buffer_stats_by_table
13+
where object_schema = 'test' and object_name = 't1';
14+
object_schema object_name allocated data pages pages_hashed pages_old rows_cached
15+
test t1 16.00 KiB 0 bytes 1 0 0 0
1216
DESC sys.x$innodb_buffer_stats_by_table;
1317
Field Type Null Key Default Extra
1418
object_schema text YES NULL
@@ -19,4 +23,8 @@ pages bigint(21) NO 0
1923
pages_hashed bigint(21) NO 0
2024
pages_old bigint(21) NO 0
2125
rows_cached decimal(44,0) NO 0
22-
SELECT * FROM sys.x$innodb_buffer_stats_by_table;
26+
SELECT * FROM sys.x$innodb_buffer_stats_by_table
27+
where object_schema = 'test' and object_name = 't1';
28+
object_schema object_name allocated data pages pages_hashed pages_old rows_cached
29+
test t1 16384 0 1 0 0 0
30+
DROP TABLE t1;

mysql-test/suite/sysschema/t/v_innodb_buffer_stats_by_schema.test

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@
88
# Ensure structure changes don't slip in
99
DESC sys.innodb_buffer_stats_by_schema;
1010

11-
# Make sure view select does not error, but ignore results
12-
--disable_result_log
13-
SELECT * FROM sys.innodb_buffer_stats_by_schema;
14-
--enable_result_log
11+
# Create an Empty table
12+
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
1513

14+
# Make sure view select does not error, and
15+
# is_hashed & is_old is 0 for empty table
16+
SELECT * FROM sys.innodb_buffer_stats_by_schema
17+
where object_schema = 'test';
1618

1719
# Ensure structure changes don't slip in
1820
DESC sys.x$innodb_buffer_stats_by_schema;
1921

20-
# Make sure view select does not error, but ignore results
21-
--disable_result_log
22-
SELECT * FROM sys.x$innodb_buffer_stats_by_schema;
23-
--enable_result_log
22+
# Make sure view select does not error, and
23+
# is_hashed & is_old is 0 for empty table
24+
SELECT * FROM sys.x$innodb_buffer_stats_by_schema
25+
where object_schema = 'test';
26+
27+
# Drop the table
28+
DROP TABLE t1;

mysql-test/suite/sysschema/t/v_innodb_buffer_stats_by_table.test

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@
88
# Ensure structure changes don't slip in
99
DESC sys.innodb_buffer_stats_by_table;
1010

11-
# Make sure view select does not error, but ignore results
12-
--disable_result_log
13-
SELECT * FROM sys.innodb_buffer_stats_by_table;
14-
--enable_result_log
11+
# Create an Empty table
12+
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
1513

14+
# Make sure view select does not error and
15+
# is_hashed & is_old is 0 for empty table
16+
SELECT * FROM sys.innodb_buffer_stats_by_table
17+
where object_schema = 'test' and object_name = 't1';
1618

1719
# Ensure structure changes don't slip in
1820
DESC sys.x$innodb_buffer_stats_by_table;
1921

20-
# Make sure view select does not error, but ignore results
21-
--disable_result_log
22-
SELECT * FROM sys.x$innodb_buffer_stats_by_table;
23-
--enable_result_log
22+
# Make sure view select does not error and
23+
# is_hashed & is_old is 0 for empty table
24+
SELECT * FROM sys.x$innodb_buffer_stats_by_table
25+
where object_schema = 'test' and object_name = 't1';
26+
27+
# Drop the table
28+
DROP TABLE t1;

scripts/sys_schema/views/i_s/innodb_buffer_stats_by_schema.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
5353
sys.format_bytes(SUM(IF(ibp.compressed_size = 0, 16384, compressed_size))) AS allocated,
5454
sys.format_bytes(SUM(ibp.data_size)) AS data,
5555
COUNT(ibp.page_number) AS pages,
56-
COUNT(IF(ibp.is_hashed = 'YES', 1, NULL)) AS pages_hashed,
57-
COUNT(IF(ibp.is_old = 'YES', 1, NULL)) AS pages_old,
56+
COUNT(IF(ibp.is_hashed, 1, NULL)) AS pages_hashed,
57+
COUNT(IF(ibp.is_old, 1, NULL)) AS pages_old,
5858
ROUND(SUM(ibp.number_records)/COUNT(DISTINCT ibp.index_name)) AS rows_cached
5959
FROM information_schema.innodb_buffer_page ibp
6060
WHERE table_name IS NOT NULL
6161
GROUP BY object_schema
6262
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC;
6363
END$$
6464
DELIMITER ;
65-

scripts/sys_schema/views/i_s/innodb_buffer_stats_by_table.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
5656
sys.format_bytes(SUM(IF(ibp.compressed_size = 0, 16384, compressed_size))) AS allocated,
5757
sys.format_bytes(SUM(ibp.data_size)) AS data,
5858
COUNT(ibp.page_number) AS pages,
59-
COUNT(IF(ibp.is_hashed = 'YES', 1, NULL)) AS pages_hashed,
60-
COUNT(IF(ibp.is_old = 'YES', 1, NULL)) AS pages_old,
59+
COUNT(IF(ibp.is_hashed, 1, NULL)) AS pages_hashed,
60+
COUNT(IF(ibp.is_old, 1, NULL)) AS pages_old,
6161
ROUND(SUM(ibp.number_records)/COUNT(DISTINCT ibp.index_name)) AS rows_cached
6262
FROM information_schema.innodb_buffer_page ibp
6363
WHERE table_name IS NOT NULL
6464
GROUP BY object_schema, object_name
6565
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC;
6666
END$$
67-
DELIMITER ;
67+
DELIMITER ;

scripts/sys_schema/views/i_s/x_innodb_buffer_stats_by_table.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
6363
GROUP BY object_schema, object_name
6464
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC;
6565
END$$
66-
DELIMITER ;
66+
DELIMITER ;

0 commit comments

Comments
 (0)