Current Path : /usr/opt/mysql57/mysql-test/suite/query_rewrite_plugins/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/opt/mysql57/mysql-test/suite/query_rewrite_plugins/t/query_cache.test |
--echo # --echo # Test of query rewrites and query cache. --echo # SET sql_mode = 'PIPES_AS_CONCAT'; SHOW VARIABLES LIKE '%query_cache%'; --source suite/query_rewrite_plugins/include/have_plugin_rewriter.inc --source include/have_query_cache.inc FLUSH STATUS; CREATE TABLE t1 ( a INT ); INSERT INTO t1 VALUES (1), (2), (3); CREATE TABLE t2 ( a CHAR ); INSERT INTO t2 VALUES ('a'), ('b'), ('c'); SELECT * FROM t1; SELECT * FROM t1; SHOW STATUS LIKE "Qcache_queries_in_cache"; SHOW STATUS LIKE "Qcache_inserts"; SHOW STATUS LIKE "Qcache_hits"; --echo # Let's get this query cached, to make sure the cache is flushed when we --echo # load the rule below. SELECT * FROM test.t1; SHOW STATUS LIKE "Qcache_queries_in_cache"; FLUSH STATUS; --source suite/query_rewrite_plugins/include/install_rewriter.inc INSERT INTO query_rewrite.rewrite_rules( pattern, replacement ) VALUES( 'SELECT * FROM test.t1', 'SELECT * FROM test.t2' ); CALL query_rewrite.flush_rewrite_rules(); SELECT @@query_cache_size; --echo # No matter what we do, this query should not get cached. SELECT * FROM test.t1; SELECT * FROM test.t1; SHOW STATUS LIKE "Qcache_queries_in_cache"; SHOW STATUS LIKE "Qcache_inserts"; SHOW STATUS LIKE "Qcache_hits"; DELETE FROM query_rewrite.rewrite_rules; CALL query_rewrite.flush_rewrite_rules(); FLUSH STATUS; SELECT * FROM test.t1; SELECT * FROM test.t1; SHOW STATUS LIKE "Qcache_queries_in_cache"; SHOW STATUS LIKE "Qcache_inserts"; SHOW STATUS LIKE "Qcache_hits"; --echo # Now let's define a syntactically correct rule followed by one with a --echo # syntax error. The query cache should still be cleared even if --echo # flush_rewrite_rules() exits with an error. RESET QUERY CACHE; DELETE FROM query_rewrite.rewrite_rules; SELECT @@query_cache_size; SELECT * FROM test.t1; SELECT * FROM test.t1; CALL mtr.add_suppression("Plugin rewriter reported: " || "'Some rules failed to load.'"); INSERT INTO query_rewrite.rewrite_rules( pattern, replacement ) VALUES ( 'SELECT * FROM test.t1', 'SELECT "rewritten"' ), ( 'This rule has syntax error', 'so it never gets rewritten' ); --error ER_SIGNAL_EXCEPTION CALL query_rewrite.flush_rewrite_rules(); SELECT * FROM query_rewrite.rewrite_rules; FLUSH STATUS; --echo # The query matching the rule should be evicted from the cache. SHOW STATUS LIKE "Qcache_queries_in_cache"; SHOW STATUS LIKE "Qcache_inserts"; SHOW STATUS LIKE "Qcache_hits"; --echo # The query would not get rewritten if it were still cached. SELECT * FROM test.t1; DELETE FROM query_rewrite.rewrite_rules; --source suite/query_rewrite_plugins/include/uninstall_rewriter.inc --source include/disconnect_connections.inc SELECT * FROM test.t1; SELECT * FROM test.t1; SHOW STATUS LIKE "Qcache_queries_in_cache"; SHOW STATUS LIKE "Qcache_inserts"; SHOW STATUS LIKE "Qcache_hits"; DROP TABLE t1, t2; SET GLOBAL query_cache_size = DEFAULT; --source suite/query_rewrite_plugins/include/reload.inc SET sql_mode = DEFAULT;