summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/include/install_plugin_if_exists.inc41
-rw-r--r--mysql-test/main/plugin.result2
-rw-r--r--mysql-test/main/plugin.test40
-rw-r--r--mysql-test/suite/compat/oracle/r/plugin.result48
-rw-r--r--mysql-test/suite/compat/oracle/t/plugin.test3
-rw-r--r--sql/sql_lex.cc47
-rw-r--r--sql/sql_lex.h10
-rw-r--r--sql/sql_yacc.yy25
-rw-r--r--sql/sql_yacc_ora.yy34
9 files changed, 169 insertions, 81 deletions
diff --git a/mysql-test/include/install_plugin_if_exists.inc b/mysql-test/include/install_plugin_if_exists.inc
new file mode 100644
index 00000000000..93f968e8a39
--- /dev/null
+++ b/mysql-test/include/install_plugin_if_exists.inc
@@ -0,0 +1,41 @@
+--echo #
+--echo # MDEV-16294: INSTALL PLUGIN IF NOT EXISTS / UNINSTALL PLUGIN IF EXISTS
+--echo #
+--echo # INSTALL IF NOT EXISTS PLUGIN name SONAME library /
+--echo # UNINSTALL IF EXISTS PLUGIN|SONAME name
+--echo #
+
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+
+--replace_regex /\.dll/.so/
+--error ER_PLUGIN_INSTALLED
+INSTALL PLUGIN example SONAME 'ha_example';
+
+INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
+SHOW WARNINGS;
+
+UNINSTALL PLUGIN IF EXISTS example;
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+
+UNINSTALL PLUGIN IF EXISTS example;
+SHOW WARNINGS;
+
+--error ER_SP_DOES_NOT_EXIST
+UNINSTALL PLUGIN example;
+
+INSTALL SONAME 'ha_example';
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+
+UNINSTALL SONAME IF EXISTS 'ha_example';
+
+--replace_regex /\.dll/.so/
+UNINSTALL SONAME IF EXISTS 'ha_example';
+--replace_regex /\.dll/.so/
+SHOW WARNINGS;
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+
+--replace_regex /\.dll/.so/
+--error ER_SP_DOES_NOT_EXIST
+UNINSTALL SONAME 'ha_example';
diff --git a/mysql-test/main/plugin.result b/mysql-test/main/plugin.result
index fde2550ad81..947a2b6bd7a 100644
--- a/mysql-test/main/plugin.result
+++ b/mysql-test/main/plugin.result
@@ -332,6 +332,8 @@ RENAME TABLE t1 TO t2;
ERROR 42S02: Table 'test.t1' doesn't exist
DROP TABLE t1;
#
+# MDEV-16294: INSTALL PLUGIN IF NOT EXISTS / UNINSTALL PLUGIN IF EXISTS
+#
# INSTALL IF NOT EXISTS PLUGIN name SONAME library /
# UNINSTALL IF EXISTS PLUGIN|SONAME name
#
diff --git a/mysql-test/main/plugin.test b/mysql-test/main/plugin.test
index 273e1e064a5..68aab865036 100644
--- a/mysql-test/main/plugin.test
+++ b/mysql-test/main/plugin.test
@@ -266,42 +266,4 @@ UNINSTALL PLUGIN example;
RENAME TABLE t1 TO t2;
DROP TABLE t1;
---echo #
---echo # INSTALL IF NOT EXISTS PLUGIN name SONAME library /
---echo # UNINSTALL IF EXISTS PLUGIN|SONAME name
---echo #
-
-select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
-INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
-select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
-
---replace_regex /\.dll/.so/
---error ER_PLUGIN_INSTALLED
-INSTALL PLUGIN example SONAME 'ha_example';
-
-INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
-SHOW WARNINGS;
-
-UNINSTALL PLUGIN IF EXISTS example;
-select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
-
-UNINSTALL PLUGIN IF EXISTS example;
-SHOW WARNINGS;
-
---error 1305
-UNINSTALL PLUGIN example;
-
-INSTALL SONAME 'ha_example';
-select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
-
-UNINSTALL SONAME IF EXISTS 'ha_example';
-
---replace_regex /\.dll/.so/
-UNINSTALL SONAME IF EXISTS 'ha_example';
---replace_regex /\.dll/.so/
-SHOW WARNINGS;
-select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
-
---replace_regex /\.dll/.so/
---error 1305
-UNINSTALL SONAME 'ha_example';
+--source include/install_plugin_if_exists.inc
diff --git a/mysql-test/suite/compat/oracle/r/plugin.result b/mysql-test/suite/compat/oracle/r/plugin.result
new file mode 100644
index 00000000000..c885c03e656
--- /dev/null
+++ b/mysql-test/suite/compat/oracle/r/plugin.result
@@ -0,0 +1,48 @@
+SET sql_mode=ORACLE;
+#
+# MDEV-16294: INSTALL PLUGIN IF NOT EXISTS / UNINSTALL PLUGIN IF EXISTS
+#
+# INSTALL IF NOT EXISTS PLUGIN name SONAME library /
+# UNINSTALL IF EXISTS PLUGIN|SONAME name
+#
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+EXAMPLE ACTIVE STORAGE ENGINE
+INSTALL PLUGIN example SONAME 'ha_example';
+ERROR HY000: Plugin 'example' already installed
+INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
+Warnings:
+Note 1968 Plugin 'example' already installed
+SHOW WARNINGS;
+Level Code Message
+Note 1968 Plugin 'example' already installed
+UNINSTALL PLUGIN IF EXISTS example;
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+UNINSTALL PLUGIN IF EXISTS example;
+Warnings:
+Note 1305 PLUGIN example does not exist
+SHOW WARNINGS;
+Level Code Message
+Note 1305 PLUGIN example does not exist
+UNINSTALL PLUGIN example;
+ERROR 42000: PLUGIN example does not exist
+INSTALL SONAME 'ha_example';
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+EXAMPLE ACTIVE STORAGE ENGINE
+UNUSABLE ACTIVE DAEMON
+UNINSTALL SONAME IF EXISTS 'ha_example';
+UNINSTALL SONAME IF EXISTS 'ha_example';
+Warnings:
+Note 1305 SONAME ha_example.so does not exist
+SHOW WARNINGS;
+Level Code Message
+Note 1305 SONAME ha_example.so does not exist
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+UNINSTALL SONAME 'ha_example';
+ERROR 42000: SONAME ha_example.so does not exist
diff --git a/mysql-test/suite/compat/oracle/t/plugin.test b/mysql-test/suite/compat/oracle/t/plugin.test
new file mode 100644
index 00000000000..a84c4ae7828
--- /dev/null
+++ b/mysql-test/suite/compat/oracle/t/plugin.test
@@ -0,0 +1,3 @@
+SET sql_mode=ORACLE;
+
+--source include/install_plugin_if_exists.inc
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 5b055c2899a..e0a38c7521e 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -10160,3 +10160,50 @@ exit:
return having;
}
+
+bool LEX::stmt_install_plugin(const DDL_options_st &opt,
+ const Lex_ident_sys_st &name,
+ const LEX_CSTRING &soname)
+{
+ create_info.init();
+ if (add_create_options_with_check(opt))
+ return true;
+ sql_command= SQLCOM_INSTALL_PLUGIN;
+ comment= name;
+ ident= soname;
+ return false;
+}
+
+
+void LEX::stmt_install_plugin(const LEX_CSTRING &soname)
+{
+ sql_command= SQLCOM_INSTALL_PLUGIN;
+ comment= null_clex_str;
+ ident= soname;
+}
+
+
+bool LEX::stmt_uninstall_plugin_by_name(const DDL_options_st &opt,
+ const Lex_ident_sys_st &name)
+{
+ check_opt.init();
+ if (add_create_options_with_check(opt))
+ return true;
+ sql_command= SQLCOM_UNINSTALL_PLUGIN;
+ comment= name;
+ ident= null_clex_str;
+ return false;
+}
+
+
+bool LEX::stmt_uninstall_plugin_by_soname(const DDL_options_st &opt,
+ const LEX_CSTRING &soname)
+{
+ check_opt.init();
+ if (add_create_options_with_check(opt))
+ return true;
+ sql_command= SQLCOM_UNINSTALL_PLUGIN;
+ comment= null_clex_str;
+ ident= soname;
+ return false;
+}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 36b8a604a1a..50cf015db62 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -4391,6 +4391,16 @@ public:
bool parsed_create_view(SELECT_LEX_UNIT *unit, int check);
bool select_finalize(st_select_lex_unit *expr);
void relink_hack(st_select_lex *select_lex);
+
+ bool stmt_install_plugin(const DDL_options_st &opt,
+ const Lex_ident_sys_st &name,
+ const LEX_CSTRING &soname);
+ void stmt_install_plugin(const LEX_CSTRING &soname);
+
+ bool stmt_uninstall_plugin_by_name(const DDL_options_st &opt,
+ const Lex_ident_sys_st &name);
+ bool stmt_uninstall_plugin_by_soname(const DDL_options_st &opt,
+ const LEX_CSTRING &soname);
};
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index e235a465b1a..4bf52a47355 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -17994,42 +17994,25 @@ opt_migrate:
install:
INSTALL_SYM PLUGIN_SYM opt_if_not_exists ident SONAME_SYM TEXT_STRING_sys
{
- LEX *lex= Lex;
- lex->create_info.init();
- if (lex->add_create_options_with_check($3))
+ if (Lex->stmt_install_plugin($3, $4, $6))
MYSQL_YYABORT;
- lex->sql_command= SQLCOM_INSTALL_PLUGIN;
- lex->comment= $4;
- lex->ident= $6;
}
| INSTALL_SYM SONAME_SYM TEXT_STRING_sys
{
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_INSTALL_PLUGIN;
- lex->comment= null_clex_str;
- lex->ident= $3;
+ Lex->stmt_install_plugin($3);
}
;
uninstall:
UNINSTALL_SYM PLUGIN_SYM opt_if_exists ident
{
- LEX *lex= Lex;
- lex->check_opt.init();
- if (lex->add_create_options_with_check($3))
+ if (Lex->stmt_uninstall_plugin_by_name($3, $4))
MYSQL_YYABORT;
- lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
- lex->comment= $4;
}
| UNINSTALL_SYM SONAME_SYM opt_if_exists TEXT_STRING_sys
{
- LEX *lex= Lex;
- lex->check_opt.init();
- if (lex->add_create_options_with_check($3))
+ if (Lex->stmt_uninstall_plugin_by_soname($3, $4))
MYSQL_YYABORT;
- lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
- lex->comment= null_clex_str;
- lex->ident= $4;
}
;
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index 8b072632bf5..2ebabf67720 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -18170,44 +18170,36 @@ opt_migrate:
;
install:
- INSTALL_SYM PLUGIN_SYM ident SONAME_SYM TEXT_STRING_sys
+ INSTALL_SYM PLUGIN_SYM opt_if_not_exists ident SONAME_SYM TEXT_STRING_sys
{
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_INSTALL_PLUGIN;
- lex->comment= $3;
- lex->ident= $5;
+ if (Lex->stmt_install_plugin($3, $4, $6))
+ MYSQL_YYABORT;
}
| INSTALL_SYM SONAME_SYM TEXT_STRING_sys
{
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_INSTALL_PLUGIN;
- lex->comment= null_clex_str;
- lex->ident= $3;
+ Lex->stmt_install_plugin($3);
}
;
uninstall:
- UNINSTALL_SYM PLUGIN_SYM ident
+ UNINSTALL_SYM PLUGIN_SYM opt_if_exists ident
{
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
- lex->comment= $3;
+ if (Lex->stmt_uninstall_plugin_by_name($3, $4))
+ MYSQL_YYABORT;
}
- | UNINSTALL_SYM SONAME_SYM TEXT_STRING_sys
+ | UNINSTALL_SYM SONAME_SYM opt_if_exists TEXT_STRING_sys
{
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
- lex->comment= null_clex_str;
- lex->ident= $3;
+ if (Lex->stmt_uninstall_plugin_by_soname($3, $4))
+ MYSQL_YYABORT;
}
;
/* Avoid compiler warning from sql_yacc.cc where yyerrlab1 is not used */
keep_gcc_happy:
IMPOSSIBLE_ACTION
- {
- YYERROR;
- }
+ {
+ YYERROR;
+ }
;
/**