Not the answer you need?
Register and ask your own question!

Query rewrite on VERSION() function

stofa.kenidastofa.kenida ContributorCurrent User Role Novice
Hi There,

By using the query rewrite plugin in 5.7.25-28-log Percona Server (GPL), Release 28, Revision c335905 version, i saw tha following strange behaviour.

Below are the steps excuted :

1. Load and enable the plugin :

mysql -S /var/lib/mysql57-25/mysql.sock < /usr/local/Percona-Server-5.7.25/share/install_rewriter.sql

2. Load two patterns in query_rewrite.rewrite_rules table

insert into rewrite_rules ( pattern,replacement) values ('SELECT version()','select \'5.6.81-4-log\'');

insert into rewrite_rules ( pattern,replacement) values ('SELECT PASSWORD(\'pippo\')','select \'5.6.81-4-log\'');

3. Load the rules in memory :

CALL query_rewrite.flush_rewrite_rules();

When i execute the following query and the uppercase is used for version() function, it seems that the pattern in not matched :


mysql> select version();
+
+
| 5.6.81-40-log |
+
+
| 5.6.81-40-log |
+
+
1 row in set, 1 warning (0.00 sec)

mysql> select VERSION();
+
+
| VERSION() |
+
+
| 5.7.25-28-log |
+
+

By doing the same query but using the second pattern :

mysql> select password('pippo');
+
+
| 5.6.81-4-log |
+
+
| 5.6.81-4-log |
+
+
1 row in set, 1 warning (0.00 sec)

mysql> select PASSWORD('pippo');
+
+
| 5.6.81-4-log |
+
+
| 5.6.81-4-log |
+
+
1 row in set, 1 warning (0.00 sec)

The result is as expected. The rule is hit and the query is rewritten.

My question is why only by using version() call funtion , the rule is escaped and works only if the exact matching between the query and the pattern in rewrite_rules table.

Thanks

Stofa.

Comments

  • stofa.kenidastofa.kenida Contributor Current User Role Novice
    Hi,

    Is someone has an idea about this issue?

    Thanks.
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.