Browse Source
WL#5710 : mysql_plugin - enable or disable plugins
WL#5710 : mysql_plugin - enable or disable plugins
This patch adds a new client utility that enables or disables plugin features. The utility disables or enables a plugin using values (name, soname, and symbols) provided via a configuration file by the same name. For example, to ENABLE the daemon_example plugin, the utility will read the daemon_example.ini configuration file and use the values contained to enable or disable the plugin.pull/73/head
12 changed files with 1416 additions and 1 deletions
-
5client/CMakeLists.txt
-
1077client/mysql_plugin.c
-
4include/my_global.h
-
8mysql-test/include/daemon_example.ini
-
8mysql-test/include/daemon_example_bad_format.ini
-
1mysql-test/include/plugin.defs
-
3mysql-test/mysql-test-run.pl
-
97mysql-test/r/mysql_plugin.result
-
1mysql-test/t/mysql_plugin-master.opt
-
205mysql-test/t/mysql_plugin.test
-
2plugin/daemon_example/CMakeLists.txt
-
6plugin/daemon_example/daemon_example.ini
1077
client/mysql_plugin.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,8 @@ |
|||
# |
|||
# Plugin initialization file. Format using comma-separated values: |
|||
# name, libname, symbol, [symbol, ] |
|||
# Note: trailing comma is required. |
|||
# |
|||
# File is used by mysql_plugin.test for testing missing library error. |
|||
# |
|||
daemon_example, libdaemon_example, daemon_example, |
|||
@ -0,0 +1,8 @@ |
|||
# |
|||
# Plugin initialization file. Format using comma-separated values: |
|||
# name, libname, symbol, [symbol, ] |
|||
# Note: trailing comma is required. |
|||
# |
|||
# File is used by mysql_plugin.test for testing bad library name. |
|||
# |
|||
daemon_BADNAME, libdaemon_example, daemon_example, |
|||
@ -0,0 +1,97 @@ |
|||
# |
|||
# Ensure the plugin isn't loaded. |
|||
# |
|||
SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; |
|||
name dl |
|||
# |
|||
# Enable the plugin... |
|||
# |
|||
# |
|||
# Ensure the plugin is now loaded. |
|||
# |
|||
SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; |
|||
name dl |
|||
daemon_example libdaemon_example.so |
|||
# |
|||
# Disable the plugin... |
|||
# |
|||
# |
|||
# Ensure the plugin isn't loaded. |
|||
# |
|||
SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; |
|||
name dl |
|||
# |
|||
# Attempt to load non-existant plugin |
|||
# |
|||
ERROR: Cannot read plugin config file NOT_THERE_AT_ALL.ini. |
|||
# |
|||
# Attempt to use non-existant plugin.ini file |
|||
# |
|||
ERROR: Cannot read plugin config file daemon_example.ini. |
|||
# |
|||
# Attempt to omit the plugin |
|||
# |
|||
ERROR: No plugin specified. |
|||
# |
|||
# Attempt to omit DISABLE|ENABLE |
|||
# |
|||
ERROR: missing operation. Please specify either '<plugin> ENABLE' or '<plugin> DISABLE'. |
|||
# |
|||
# Attempt to use bad paths - datadir |
|||
# |
|||
ERROR: Cannot access datadir at '/data_not_there/'. |
|||
# |
|||
# Attempt to use bad paths - basedir |
|||
# |
|||
ERROR: Cannot access basedir at '/basedir_not_there/'. |
|||
# |
|||
# Attempt to use bad paths - plugin_dir |
|||
# |
|||
ERROR: Cannot read plugin config file daemon_example.ini. |
|||
# |
|||
# Missing library |
|||
# |
|||
ERROR: The plugin library is missing or in a different location. |
|||
# |
|||
# Bad format for config file |
|||
# |
|||
ERROR: plugin name requested does not match config file data. |
|||
# |
|||
# Missing base_dir option |
|||
# |
|||
ERROR: Missing --basedir option. |
|||
# |
|||
# Missing data_dir option |
|||
# |
|||
ERROR: Missing --datadir option. |
|||
# |
|||
# Missing plugin_dir option |
|||
# |
|||
ERROR: Missing --plugin_dir option. |
|||
# |
|||
# Show the help. |
|||
# |
|||
mysql_plugin Ver 1.0.0 Distrib XX.XX.XX |
|||
Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
|||
|
|||
Enable or disable plugins. |
|||
|
|||
Usage: mysql_plugin [options] <plugin> ENABLE|DISABLE |
|||
|
|||
Options: |
|||
-?, --help Display this help and exit. |
|||
-b, --basedir=name The basedir for the server. |
|||
-d, --datadir=name The datadir for the server. |
|||
-p, --plugin-dir=name |
|||
The plugin dir for the server. |
|||
-i, --plugin-ini=name |
|||
Read plugin information from configuration file specified |
|||
instead of from <plugin-dir>/<plugin_name>.ini. |
|||
-n, --no-defaults Do not read values from configuration file. |
|||
-P, --print-defaults |
|||
Show default values from configuration file. |
|||
-v, --verbose More verbose output; you can use this multiple times to |
|||
get even more verbose output. |
|||
-V, --version Output version information and exit. |
|||
|
|||
|
|||
@ -0,0 +1 @@ |
|||
--plugin-dir=$DAEMONEXAMPLE_DIR |
|||
@ -0,0 +1,205 @@ |
|||
# |
|||
# Test mysql_plugin tool |
|||
# |
|||
|
|||
# |
|||
# Test currently does not run on Windows because in Windows build trees, |
|||
# mysqld.exe is not placed in the ./sql folder - it is placed either |
|||
# in ./sql/Debug or ./sql/release. If this behaviour is changed, this test |
|||
# can run on Windows. |
|||
# |
|||
--source include/not_windows.inc |
|||
|
|||
# Add the datadir, basedir, plugin_dir to the bootstrap command |
|||
let $MYSQLD_DATADIR= `select @@datadir`; |
|||
let $MYSQLD_BASEDIR= `select @@basedir`; |
|||
let $MYSQLD_BOOTSTRAP_CMD= $MYSQL_PLUGIN --datadir=$MYSQLD_DATADIR --basedir=$MYSQLD_BASEDIR/sql --plugin-dir=$DAEMONEXAMPLE_DIR; |
|||
|
|||
--echo # |
|||
--echo # Ensure the plugin isn't loaded. |
|||
--echo # |
|||
SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; |
|||
|
|||
--echo # |
|||
--echo # Enable the plugin... |
|||
--echo # |
|||
let $expect_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; |
|||
# MTR will remove this file later, but this might be too late. |
|||
--error 0,1 |
|||
--remove_file $expect_file |
|||
--write_file $expect_file |
|||
wait |
|||
EOF |
|||
--shutdown_server 10 |
|||
--source include/wait_until_disconnected.inc |
|||
|
|||
# |
|||
# Enable the plugin |
|||
# |
|||
--exec $MYSQLD_BOOTSTRAP_CMD ENABLE daemon_example |
|||
|
|||
# |
|||
# Ensure enabling an enabled plugin doesn't fail |
|||
--exec $MYSQLD_BOOTSTRAP_CMD ENABLE daemon_example |
|||
|
|||
# |
|||
# Restart the server |
|||
# |
|||
--append_file $expect_file |
|||
restart |
|||
EOF |
|||
--enable_reconnect |
|||
--source include/wait_until_connected_again.inc |
|||
|
|||
--echo # |
|||
--echo # Ensure the plugin is now loaded. |
|||
--echo # |
|||
--replace_regex /\.dll/.so/ |
|||
SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; |
|||
|
|||
--echo # |
|||
--echo # Disable the plugin... |
|||
--echo # |
|||
# MTR will remove this file later, but this might be too late. |
|||
--error 0,1 |
|||
--remove_file $expect_file |
|||
--write_file $expect_file |
|||
wait |
|||
EOF |
|||
--shutdown_server 10 |
|||
--source include/wait_until_disconnected.inc |
|||
|
|||
# |
|||
# Disable the plugin |
|||
# |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example |
|||
|
|||
# |
|||
# Restart the server |
|||
# |
|||
--append_file $expect_file |
|||
restart |
|||
EOF |
|||
--enable_reconnect |
|||
--source include/wait_until_connected_again.inc |
|||
|
|||
--echo # |
|||
--echo # Ensure the plugin isn't loaded. |
|||
--echo # |
|||
SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; |
|||
|
|||
# |
|||
# Stop the server for error conditions |
|||
# |
|||
let $expect_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; |
|||
# MTR will remove this file later, but this might be too late. |
|||
--error 0,1 |
|||
--remove_file $expect_file |
|||
--write_file $expect_file |
|||
wait |
|||
EOF |
|||
--shutdown_server 10 |
|||
--source include/wait_until_disconnected.inc |
|||
|
|||
--echo # |
|||
--echo # Attempt to load non-existant plugin |
|||
--echo # |
|||
--error 1,2,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE NOT_THERE_AT_ALL 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Attempt to use non-existant plugin.ini file |
|||
--echo # |
|||
--error 1,2,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example --plugin-ini=/NOT/THERE/pi.ini 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Attempt to omit the plugin |
|||
--echo # |
|||
--error 1,2,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Attempt to omit DISABLE|ENABLE |
|||
--echo # |
|||
--error 1,2,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD daemon_example 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Attempt to use bad paths - datadir |
|||
--echo # |
|||
let $MYSQLD_BOOTSTRAP_CMD= $MYSQL_PLUGIN -n --datadir=/data_not_there/ --basedir=$MYSQLD_BASEDIR/sql --plugin-dir=$DAEMONEXAMPLE_DIR; |
|||
--error 1,2,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Attempt to use bad paths - basedir |
|||
--echo # |
|||
let $MYSQLD_BOOTSTRAP_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=/basedir_not_there/ --plugin-dir=$DAEMONEXAMPLE_DIR; |
|||
--error 1,2,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Attempt to use bad paths - plugin_dir |
|||
--echo # |
|||
let $MYSQLD_BOOTSTRAP_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQLD_BASEDIR/sql --plugin-dir=/plugin_not_there/; |
|||
--error 1,2,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Missing library |
|||
--echo # |
|||
let $MYSQLD_BOOTSTRAP_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQLD_BASEDIR/sql --plugin-dir=$MYSQL_TEST_DIR/include/; |
|||
--error 1,2,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Bad format for config file |
|||
--echo # |
|||
let $MYSQLD_BOOTSTRAP_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQLD_BASEDIR/sql --plugin-dir=$DAEMONEXAMPLE_DIR --plugin-ini=$MYSQL_TEST_DIR/include/daemon_example_bad_format.ini; |
|||
--error 1,2,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Missing base_dir option |
|||
--echo # |
|||
let $MYSQLD_BOOTSTRAP_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --plugin-dir=$DAEMONEXAMPLE_DIR; |
|||
--error 1,2,139,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Missing data_dir option |
|||
--echo # |
|||
let $MYSQLD_BOOTSTRAP_CMD= $MYSQL_PLUGIN -n --basedir=$MYSQLD_BASEDIR/sql --plugin-dir=$DAEMONEXAMPLE_DIR; |
|||
--error 1,2,139,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Missing plugin_dir option |
|||
--echo # |
|||
let $MYSQLD_BOOTSTRAP_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQLD_BASEDIR/sql; |
|||
--error 1,2,139,256 |
|||
--exec $MYSQLD_BOOTSTRAP_CMD DISABLE daemon_example 2>&1 |
|||
|
|||
--echo # |
|||
--echo # Show the help. |
|||
--echo # |
|||
replace_result $MYSQL_PLUGIN mysql_plugin; |
|||
--replace_regex /Distrib [0-9.]+/Distrib XX.XX.XX/ |
|||
--exec $MYSQL_PLUGIN --help |
|||
|
|||
# |
|||
# Restart the server |
|||
# |
|||
--append_file $expect_file |
|||
restart |
|||
EOF |
|||
--enable_reconnect |
|||
--source include/wait_until_connected_again.inc |
|||
|
|||
# |
|||
# Cleanup |
|||
# MTR will remove this file later, but this might be too late. |
|||
--error 0,1 |
|||
--remove_file $expect_file |
|||
|
|||
@ -0,0 +1,6 @@ |
|||
# |
|||
# Plugin initialization file. Format using comma-separated values: |
|||
# name, libname, symbol, [symbol, ] |
|||
# Note: trailing comma is required. |
|||
# |
|||
daemon_example, libdaemon_example, daemon_example, |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue