You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.3 KiB

  1. #
  2. # Test information_schema.innodb_cmp_per_index
  3. #
  4. -- source include/have_innodb.inc
  5. # Using innodb_log_compressed=0 leads to a larger number of page
  6. # compressions, because page_cur_insert_rec_zip() will reorganize the
  7. # page before attempting an insert followed by page compression and
  8. # page_zip_compress_write_log_no_data().
  9. if (`SELECT @@innodb_log_compressed_pages = 0`)
  10. {
  11. --skip Needs innodb_log_compressed_pages
  12. }
  13. # numbers read in this test depend on the page size
  14. -- source include/have_innodb_16k.inc
  15. # include/restart_mysqld.inc does not work in embedded mode
  16. -- source include/not_embedded.inc
  17. -- vertical_results
  18. SET @save_enabled= @@GLOBAL.innodb_cmp_per_index_enabled;
  19. SET GLOBAL innodb_cmp_per_index_enabled=ON;
  20. # reset any leftover stats from previous tests
  21. -- disable_query_log
  22. -- disable_result_log
  23. SELECT * FROM information_schema.innodb_cmp_per_index_reset;
  24. -- enable_result_log
  25. -- enable_query_log
  26. # see that the table is empty
  27. SELECT * FROM information_schema.innodb_cmp_per_index;
  28. # create a table that uses compression
  29. CREATE TABLE t (
  30. a INT,
  31. b VARCHAR(512),
  32. c VARCHAR(16),
  33. PRIMARY KEY (a),
  34. INDEX (b(512)),
  35. INDEX (c(16))
  36. ) ENGINE=INNODB KEY_BLOCK_SIZE=2;
  37. SELECT
  38. database_name,
  39. table_name,
  40. index_name,
  41. compress_ops,
  42. compress_ops_ok,
  43. uncompress_ops
  44. FROM information_schema.innodb_cmp_per_index
  45. ORDER BY 1, 2, 3;
  46. # insert some data into it
  47. BEGIN;
  48. -- disable_query_log
  49. let $i=128;
  50. while ($i)
  51. {
  52. -- eval INSERT INTO t VALUES ($i, REPEAT('x', 512), NULL);
  53. dec $i;
  54. }
  55. -- enable_query_log
  56. COMMIT;
  57. ALTER TABLE t DROP INDEX c;
  58. GRANT USAGE ON *.* TO 'tuser01'@'localhost' IDENTIFIED BY 'cDJvI9s_Uq';
  59. FLUSH PRIVILEGES;
  60. -- connect (con1,localhost,tuser01,cDJvI9s_Uq,)
  61. -- connection con1
  62. -- error ER_SPECIFIC_ACCESS_DENIED_ERROR
  63. SELECT * FROM information_schema.innodb_cmp_per_index;
  64. -- connection default
  65. -- disconnect con1
  66. DROP USER 'tuser01'@'localhost';
  67. SELECT
  68. database_name,
  69. table_name,
  70. index_name,
  71. CASE WHEN compress_ops=47 and @@innodb_compression_level IN (4,8,9) THEN 65
  72. ELSE compress_ops END as compress_ops,
  73. CASE WHEN compress_ops_ok=47 and @@innodb_compression_level IN (4,8,9) THEN 65
  74. ELSE compress_ops_ok END as compress_ops_ok,
  75. uncompress_ops
  76. FROM information_schema.innodb_cmp_per_index
  77. ORDER BY 1, 2, 3;
  78. DROP TABLE t;
  79. SET GLOBAL innodb_cmp_per_index_enabled=@save_enabled;