Server IP : 172.67.216.182 / Your IP : 162.158.88.20 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/server/mysql/src/mysql-test/suite/query_rewrite_plugins/r/ |
Upload File : |
# # Test of rewrites of queries where the database (a.k.a. schema) is not # specified in the pattern. # # MySQL behaves in the most peculiar way in this respect. Some # explanation is order here: When a query is parsed, the # parser injects the current database when parsing a table name, i.e. # 'table' is _parsed_ as '<current database>.table'. # # The session that loads the rules has no current database, so the rule # has to specify it if there are unqualified table names in the pattern. # CALL mtr.add_suppression("Plugin rewriter reported: 'Some rules failed to load.'"); CREATE DATABASE db1; CREATE DATABASE db2; CREATE TABLE t1 ( a VARCHAR(23) ); INSERT INTO t1 VALUES ( 'This was not rewritten.' ); Warnings: Warning 1681 'RESET QUERY CACHE' is deprecated and will be removed in a future release. Warnings: Warning 1681 'RESET QUERY CACHE' is deprecated and will be removed in a future release. # Query rewrite plugin was installed. INSERT INTO query_rewrite.rewrite_rules ( pattern, pattern_database, replacement ) VALUES ( 'SELECT * FROM db1.nonexistent_table1', NULL, 'SELECT "Rule #1"' ), ( 'SELECT * FROM db2.nonexistent_table2', NULL, 'SELECT "Rule #2"' ), ( 'SELECT * FROM nonexistent_table_db1', 'db1', 'SELECT "Rule #3"' ), ( 'SELECT * FROM nonexistent_table_db2', 'db2', 'SELECT "Rule #4"' ), ( 'SELECT * FROM nonexistent_table', NULL, 'SELECT "Rule #5"' ), ( 'SELECT * FROM test.t1', 'test', 'SELECT "Rule #6"' ), ( 'SELECT 1 FROM t1', 'test', 'SELECT 4 FROM t1' ), ( 'SELECT 2 FROM t1', NULL, 'SELECT 5 FROM t1' ), ( 'SELECT 3 FROM test.t1', NULL, 'SELECT 6 FROM t1' ); CALL query_rewrite.flush_rewrite_rules(); ERROR 45000: Loading of some rule(s) failed. SELECT * FROM query_rewrite.rewrite_rules; id pattern pattern_database replacement enabled message 1 SELECT * FROM db1.nonexistent_table1 NULL SELECT "Rule #1" YES NULL 2 SELECT * FROM db2.nonexistent_table2 NULL SELECT "Rule #2" YES NULL 3 SELECT * FROM nonexistent_table_db1 db1 SELECT "Rule #3" YES NULL 4 SELECT * FROM nonexistent_table_db2 db2 SELECT "Rule #4" YES NULL 5 SELECT * FROM nonexistent_table NULL SELECT "Rule #5" YES Parse error in pattern: >>No database selected<< 6 SELECT * FROM test.t1 test SELECT "Rule #6" YES NULL 7 SELECT 1 FROM t1 test SELECT 4 FROM t1 YES NULL 8 SELECT 2 FROM t1 NULL SELECT 5 FROM t1 YES Parse error in pattern: >>No database selected<< 9 SELECT 3 FROM test.t1 NULL SELECT 6 FROM t1 YES Parse error in replacement: >>No database selected<< USE test; SELECT * FROM db1.nonexistent_table1; Rule #1 Rule #1 Warnings: Note 1105 Query 'SELECT * FROM db1.nonexistent_table1' rewritten to 'SELECT "Rule #1"' by a query rewrite plugin SELECT * FROM db2.nonexistent_table2; Rule #2 Rule #2 Warnings: Note 1105 Query 'SELECT * FROM db2.nonexistent_table2' rewritten to 'SELECT "Rule #2"' by a query rewrite plugin SELECT * FROM nonexistent_table_db1; ERROR 42S02: Table 'test.nonexistent_table_db1' doesn't exist SELECT * FROM nonexistent_table_db2; ERROR 42S02: Table 'test.nonexistent_table_db2' doesn't exist SELECT * FROM test.t1; Rule #6 Rule #6 Warnings: Note 1105 Query 'SELECT * FROM test.t1' rewritten to 'SELECT "Rule #6"' by a query rewrite plugin SELECT 1 FROM t1; 4 4 Warnings: Note 1105 Query 'SELECT 1 FROM t1' rewritten to 'SELECT 4 FROM t1' by a query rewrite plugin USE db1; SELECT * FROM db1.nonexistent_table1; Rule #1 Rule #1 Warnings: Note 1105 Query 'SELECT * FROM db1.nonexistent_table1' rewritten to 'SELECT "Rule #1"' by a query rewrite plugin SELECT * FROM db2.nonexistent_table2; Rule #2 Rule #2 Warnings: Note 1105 Query 'SELECT * FROM db2.nonexistent_table2' rewritten to 'SELECT "Rule #2"' by a query rewrite plugin SELECT * FROM nonexistent_table_db1; Rule #3 Rule #3 Warnings: Note 1105 Query 'SELECT * FROM nonexistent_table_db1' rewritten to 'SELECT "Rule #3"' by a query rewrite plugin SELECT * FROM nonexistent_table_db2; ERROR 42S02: Table 'db1.nonexistent_table_db2' doesn't exist SELECT * FROM test.t1; Rule #6 Rule #6 Warnings: Note 1105 Query 'SELECT * FROM test.t1' rewritten to 'SELECT "Rule #6"' by a query rewrite plugin SELECT 1 FROM t1; ERROR 42S02: Table 'db1.t1' doesn't exist USE db2; SELECT * FROM db1.nonexistent_table1; Rule #1 Rule #1 Warnings: Note 1105 Query 'SELECT * FROM db1.nonexistent_table1' rewritten to 'SELECT "Rule #1"' by a query rewrite plugin SELECT * FROM db2.nonexistent_table2; Rule #2 Rule #2 Warnings: Note 1105 Query 'SELECT * FROM db2.nonexistent_table2' rewritten to 'SELECT "Rule #2"' by a query rewrite plugin SELECT * FROM nonexistent_table_db1; ERROR 42S02: Table 'db2.nonexistent_table_db1' doesn't exist SELECT * FROM nonexistent_table_db2; Rule #4 Rule #4 Warnings: Note 1105 Query 'SELECT * FROM nonexistent_table_db2' rewritten to 'SELECT "Rule #4"' by a query rewrite plugin SELECT * FROM test.t1; Rule #6 Rule #6 Warnings: Note 1105 Query 'SELECT * FROM test.t1' rewritten to 'SELECT "Rule #6"' by a query rewrite plugin SELECT 1 FROM t1; ERROR 42S02: Table 'db2.t1' doesn't exist DROP DATABASE db1; DROP DATABASE db2; USE test; DROP TABLE t1; Warnings: Warning 1620 Plugin is busy and will be uninstalled on shutdown # Query rewrite plugin was queued for uninstalling.