Skip to content

Commit

Permalink
Guard the statements for the InnoDB buffer related views by version c…
Browse files Browse the repository at this point in the history
…omments for 5.5.28 and above.
  • Loading branch information
MarkLeith committed Sep 17, 2013
1 parent dda77eb commit bb17c7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions views/i_s/innodb_buffer_stats_by_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
* Versions: 5.5.28+
*/

DROP VIEW IF EXISTS innodb_buffer_stats_by_schema;
/*!50528 DROP VIEW IF EXISTS innodb_buffer_stats_by_schema */;

/*!50528
CREATE SQL SECURITY INVOKER VIEW innodb_buffer_stats_by_schema AS
SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_INDEX(ibp.table_name, '.', 1), '`', '')) AS object_schema,
format_bytes(SUM(IF(ibp.compressed_size = 0, 16384, compressed_size))) AS allocated,
Expand All @@ -30,7 +31,7 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
FROM information_schema.innodb_buffer_page ibp
WHERE table_name IS NOT NULL
GROUP BY object_schema
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC;
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC */;

/*
* View: innodb_buffer_stats_by_schema_raw
Expand All @@ -51,8 +52,9 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
* Versions: 5.5.28+
*/

DROP VIEW IF EXISTS innodb_buffer_stats_by_schema_raw;
/*!50528 DROP VIEW IF EXISTS innodb_buffer_stats_by_schema_raw */;

/*!50528
CREATE SQL SECURITY INVOKER VIEW innodb_buffer_stats_by_schema_raw AS
SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_INDEX(ibp.table_name, '.', 1), '`', '')) AS object_schema,
SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) AS allocated,
Expand All @@ -64,4 +66,4 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
FROM information_schema.innodb_buffer_page ibp
WHERE table_name IS NOT NULL
GROUP BY object_schema
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC;
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC */;
10 changes: 6 additions & 4 deletions views/i_s/innodb_buffer_stats_by_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
* Versions: 5.5.28+
*/

DROP VIEW IF EXISTS innodb_buffer_stats_by_table;
/*!50528 DROP VIEW IF EXISTS innodb_buffer_stats_by_table */;

/*!50528
CREATE SQL SECURITY INVOKER VIEW innodb_buffer_stats_by_table AS
SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_INDEX(ibp.table_name, '.', 1), '`', '')) AS object_schema,
REPLACE(SUBSTRING_INDEX(ibp.table_name, '.', -1), '`', '') AS object_name,
Expand All @@ -32,7 +33,7 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
FROM information_schema.innodb_buffer_page ibp
WHERE table_name IS NOT NULL
GROUP BY object_schema, object_name
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC;
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC */;

/* View: innodb_buffer_stats_by_table_raw
*
Expand All @@ -54,8 +55,9 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
* Versions: 5.5.28+
*/

DROP VIEW IF EXISTS innodb_buffer_stats_by_table_raw;
/*!50528 DROP VIEW IF EXISTS innodb_buffer_stats_by_table_raw */;

/*!50528
CREATE SQL SECURITY INVOKER VIEW innodb_buffer_stats_by_table_raw AS
SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_INDEX(ibp.table_name, '.', 1), '`', '')) AS object_schema,
REPLACE(SUBSTRING_INDEX(ibp.table_name, '.', -1), '`', '') AS object_name,
Expand All @@ -68,4 +70,4 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
FROM information_schema.innodb_buffer_page ibp
WHERE table_name IS NOT NULL
GROUP BY object_schema, object_name
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC;
ORDER BY SUM(IF(ibp.compressed_size = 0, 16384, compressed_size)) DESC */;

0 comments on commit bb17c7c

Please sign in to comment.