Query Rewrite Plugins

[root@ZST1 ~] mysql --login-path=3306 </usr/local/mysql/share/install_rewriter.sql

mydba@192.168.85.132,3306 [(none)]> create database qrp_drop;
Query OK, 1 row affected (0.00 sec)

mydba@192.168.85.132,3306 [(none)]> insert into query_rewrite.rewrite_rules(pattern,pattern_database,replacement) 
    -> values('select 3','qrp_drop','drop database qrp_drop');
Query OK, 1 row affected (0.01 sec)

mydba@192.168.85.132,3306 [(none)]> call query_rewrite.flush_rewrite_rules;
Query OK, 0 rows affected (0.01 sec)

mydba@192.168.85.132,3306 [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| qrp_drop           |
| query_rewrite      |
| replcrash          |
| sbtest             |
| sys                |
+--------------------+
8 rows in set (0.00 sec)

mydba@192.168.85.132,3306 [(none)]> select 3;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mydba@192.168.85.132,3306 [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| query_rewrite      |
| replcrash          |
| sbtest             |
| sys                |
+--------------------+
7 rows in set (0.00 sec)

mydba@192.168.85.132,3306 [(none)]> 
posted @ 2018-04-26 14:01  醒嘞  阅读(323)  评论(0编辑  收藏  举报