Server IP : 172.67.216.182 / Your IP : 172.71.81.52 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/mysql-test/suite/query_rewrite_plugins/t/ |
Upload File : |
--echo # --echo # Test of rewrites of queries where the database (a.k.a. schema) is not --echo # specified in the pattern. --echo # --echo # MySQL behaves in the most peculiar way in this respect. Some --echo # explanation is order here: When a query is parsed, the --echo # parser injects the current database when parsing a table name, i.e. --echo # 'table' is _parsed_ as '<current database>.table'. --echo # --echo # The session that loads the rules has no current database, so the rule --echo # has to specify it if there are unqualified table names in the pattern. --echo # CALL mtr.add_suppression("Plugin rewriter reported: 'Some rules failed to load.'"); --source suite/query_rewrite_plugins/include/have_plugin_rewriter.inc CREATE DATABASE db1; CREATE DATABASE db2; CREATE TABLE t1 ( a VARCHAR(23) ); INSERT INTO t1 VALUES ( 'This was not rewritten.' ); --source suite/query_rewrite_plugins/include/install_rewriter.inc 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' ); --error ER_SIGNAL_EXCEPTION CALL query_rewrite.flush_rewrite_rules(); SELECT * FROM query_rewrite.rewrite_rules; USE test; SELECT * FROM db1.nonexistent_table1; SELECT * FROM db2.nonexistent_table2; --error ER_NO_SUCH_TABLE SELECT * FROM nonexistent_table_db1; --error ER_NO_SUCH_TABLE SELECT * FROM nonexistent_table_db2; SELECT * FROM test.t1; SELECT 1 FROM t1; USE db1; SELECT * FROM db1.nonexistent_table1; SELECT * FROM db2.nonexistent_table2; SELECT * FROM nonexistent_table_db1; --error ER_NO_SUCH_TABLE SELECT * FROM nonexistent_table_db2; SELECT * FROM test.t1; --error ER_NO_SUCH_TABLE SELECT 1 FROM t1; USE db2; SELECT * FROM db1.nonexistent_table1; SELECT * FROM db2.nonexistent_table2; --error ER_NO_SUCH_TABLE SELECT * FROM nonexistent_table_db1; SELECT * FROM nonexistent_table_db2; SELECT * FROM test.t1; --error ER_NO_SUCH_TABLE SELECT 1 FROM t1; DROP DATABASE db1; DROP DATABASE db2; USE test; DROP TABLE t1; --source suite/query_rewrite_plugins/include/uninstall_rewriter.inc