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.

122 lines
3.5 KiB

  1. -- source include/have_query_cache.inc
  2. -- source include/have_ndb.inc
  3. -- source include/not_embedded.inc
  4. --disable_warnings
  5. drop table if exists t1;
  6. --enable_warnings
  7. # Turn on and reset query cache
  8. set GLOBAL query_cache_type=on;
  9. set GLOBAL query_cache_size=1355776;
  10. reset query cache;
  11. flush status;
  12. # Create test table in NDB
  13. CREATE TABLE t1 ( pk int not null primary key,
  14. a int, b int not null, c varchar(20)) ENGINE=ndbcluster;
  15. insert into t1 value (1, 2, 3, 'First row');
  16. # Perform one query which should be inerted in query cache
  17. select * from t1;
  18. show status like "Qcache_queries_in_cache";
  19. show status like "Qcache_inserts";
  20. show status like "Qcache_hits";
  21. # Perform the same query and make sure the query cache is hit
  22. select * from t1;
  23. show status like "Qcache_hits";
  24. # Update the table and make sure the correct data is returned
  25. update t1 set a=3 where pk=1;
  26. select * from t1;
  27. show status like "Qcache_inserts";
  28. show status like "Qcache_hits";
  29. # Insert a new record and make sure the correct data is returned
  30. insert into t1 value (2, 7, 8, 'Second row');
  31. insert into t1 value (4, 5, 6, 'Fourth row');
  32. select * from t1 order by pk;
  33. show status like "Qcache_inserts";
  34. show status like "Qcache_hits";
  35. select * from t1 order by pk;
  36. show status like "Qcache_hits";
  37. # Perform a "new" query and make sure the query cache is not hit
  38. select * from t1 where b=3;
  39. show status like "Qcache_queries_in_cache";
  40. show status like "Qcache_hits";
  41. # Same query again...
  42. select * from t1 where b=3;
  43. show status like "Qcache_hits";
  44. # Delete from the table
  45. delete from t1 where c='Fourth row';
  46. show status like "Qcache_queries_in_cache";
  47. select * from t1 where b=3;
  48. show status like "Qcache_hits";
  49. # Start another connection and check that the query cache is hit
  50. connect (con1,localhost,root,,);
  51. connection con1;
  52. use test;
  53. select * from t1 order by pk;
  54. select * from t1 where b=3;
  55. show status like "Qcache_hits";
  56. # Update the table and switch to other connection
  57. update t1 set a=4 where b=3;
  58. connect (con2,localhost,root,,);
  59. connection con2;
  60. use test;
  61. show status like "Qcache_queries_in_cache";
  62. select * from t1 order by pk desc;
  63. select * from t1 order by pk desc;
  64. show status like "Qcache_inserts";
  65. show status like "Qcache_hits";
  66. connection con1;
  67. select * from t1 order by pk desc;
  68. select * from t1 order by pk desc;
  69. show status like "Qcache_queries_in_cache";
  70. show status like "Qcache_inserts";
  71. show status like "Qcache_hits";
  72. # Use transactions and make sure the query cache is not updated until
  73. # transaction is commited
  74. begin;
  75. update t1 set a=5 where pk=1;
  76. # Note!! the below test shows that table is invalidated
  77. # before transaction is committed
  78. # TODO Fix so that cache is not invalidated HERE!
  79. show status like "Qcache_queries_in_cache";
  80. show status like "Qcache_inserts";
  81. show status like "Qcache_hits";
  82. connection con2;
  83. select * from t1 order by pk desc;
  84. show status like "Qcache_queries_in_cache";
  85. show status like "Qcache_inserts";
  86. show status like "Qcache_hits";
  87. connection con1;
  88. commit;
  89. # TODO Here query is invalidated once again, commit count in NDB has changed
  90. show status like "Qcache_queries_in_cache";
  91. show status like "Qcache_inserts";
  92. show status like "Qcache_hits";
  93. connection con2;
  94. select * from t1 order by pk desc;
  95. show status like "Qcache_inserts";
  96. show status like "Qcache_hits";
  97. connection con1;
  98. select * from t1 order by pk desc;
  99. show status like "Qcache_queries_in_cache";
  100. show status like "Qcache_inserts";
  101. show status like "Qcache_hits";
  102. drop table t1;
  103. show status like "Qcache_queries_in_cache";
  104. SET GLOBAL query_cache_size=0;
  105. # End of 4.1 tests