This is a simple preparse MySQL Rewrite Query Plugin that replaces the query SELECT @@storage_engine by SELECT @@default_storage_engine.
C++ CMake
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
rewrite_status_storage_engine
LICENSE
README.md
rewrite_status_storage_engine.so

README.md

MySQL Plugin: Rewrite Status Variable Storage Engine

Synopsis

This is a simple preparse MySQL Rewrite Query Plugin that replaces the query SELECT @@storage_engine by SELECT @@default_storage_engine. Works with MySQL 5.7.

Example

mysql>  SELECT @@storage_engine;
+--------------------------+
| @@default_storage_engine |
+--------------------------+
| InnoDB                   |
+--------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+-------+------+----------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                  |
+-------+------+----------------------------------------------------------------------------------------------------------+
| Note  | 1105 | Query 'SELECT @@storage_engine' rewritten to 'SELECT @@default_storage_engine' by a query rewrite plugin |
+-------+------+----------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Motivation

Some applications will try to query SELECT @@storage_engine; in MySQL 5.7 and will receive the error ERROR 1193 (HY000): Unknown system variable 'storage_engine'. This plugin will replace the query with SELECT @@default_storage_engine preventing the error.

Installation of compiled library

  1. Put the rewrite_status_storage_engine.so library in your mysql plugin directory (the directory named by the MySQL plugin_dir system variable)
  1. Make sure the library has the right permissions:
    chmod 755 rewrite_status_storage_engine.so
  2. Install the plugin in MySQL:
    INSTALL PLUGIN rewrite_status_storage_engine SONAME 'rewrite_status_storage_engine.so';
  3. Check if plugin is installed and active:
mysql> SHOW PLUGINS\G  

   Name: rewrite_status_storage_engine
 Status: ACTIVE
   Type: AUDIT
Library: rewrite_status_storage_engine.so
License: GPL  

How to use

After installation, just try it!

mysql> select @@version;
+-------------------------------------------+
| @@version                                 |
+-------------------------------------------+
| 5.7.15-enterprise-commercial-advanced-log |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql>  SELECT @@storage_engine;
+--------------------------+
| @@default_storage_engine |
+--------------------------+
| InnoDB                   |
+--------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+-------+------+----------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                  |
+-------+------+----------------------------------------------------------------------------------------------------------+
| Note  | 1105 | Query 'SELECT @@storage_engine' rewritten to 'SELECT @@default_storage_engine' by a query rewrite plugin |
+-------+------+----------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Uninstall

You can remove the plugin with:
mysql> UNINSTALL PLUGIN plugin 'rewrite_status_storage_engine';

Optionally remove the library:
rm rewrite_status_storage_engine.so

Contributors

The code of this plugin was based on Oracle MySQL 5.7 rewrite_example plugin.

License

GNU General Public License (GPL) version 2