summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/shutdown.result5
-rw-r--r--mysql-test/t/shutdown.test28
-rw-r--r--sql/mysqld.cc1
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_parse.cc11
-rw-r--r--sql/sql_prepare.cc1
-rw-r--r--sql/sql_yacc.yy10
7 files changed, 55 insertions, 3 deletions
diff --git a/mysql-test/r/shutdown.result b/mysql-test/r/shutdown.result
new file mode 100644
index 00000000000..fae3af1cd08
--- /dev/null
+++ b/mysql-test/r/shutdown.result
@@ -0,0 +1,5 @@
+create user user1@localhost;
+shutdown;
+ERROR 42000: Access denied; you need (at least one of) the SHUTDOWN privilege(s) for this operation
+shutdown;
+drop user user1@localhost;
diff --git a/mysql-test/t/shutdown.test b/mysql-test/t/shutdown.test
new file mode 100644
index 00000000000..b12772cfb6b
--- /dev/null
+++ b/mysql-test/t/shutdown.test
@@ -0,0 +1,28 @@
+--source include/not_embedded.inc
+#
+# SHUTDOWN statement
+#
+create user user1@localhost;
+
+connect (c1,localhost,user1,,);
+
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
+shutdown;
+
+connection default;
+disconnect c1;
+
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--exec echo "wait" > $_expect_file_name
+
+shutdown;
+
+--source include/wait_until_disconnected.inc
+
+--exec echo "restart" > $_expect_file_name
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+drop user user1@localhost;
+
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 7378193b817..02a00e3b573 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3505,6 +3505,7 @@ SHOW_VAR com_status_vars[]= {
{"show_user_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_USER_STATS]), SHOW_LONG_STATUS},
{"show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS},
{"show_warnings", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
+ {"shutdown", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHUTDOWN]), SHOW_LONG_STATUS},
{"start_all_slaves", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_ALL_START]), SHOW_LONG_STATUS},
{"start_slave", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_START]), SHOW_LONG_STATUS},
{"stmt_close", (char*) offsetof(STATUS_VAR, com_stmt_close), SHOW_LONG_STATUS},
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 14904607122..5daad91ae1c 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -194,7 +194,7 @@ enum enum_sql_command {
SQLCOM_SHOW_RELAYLOG_EVENTS,
SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
SQLCOM_SHOW_CLIENT_STATS,
- SQLCOM_SHOW_EXPLAIN,
+ SQLCOM_SHOW_EXPLAIN, SQLCOM_SHUTDOWN,
/*
When a command is added here, be sure it's also added in mysqld.cc
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3a499145a63..4691ecefd89 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3916,6 +3916,17 @@ end_with_restore_list:
lex->kill_signal);
break;
}
+ case SQLCOM_SHUTDOWN:
+#ifndef EMBEDDED_LIBRARY
+ if (check_global_access(thd,SHUTDOWN_ACL))
+ goto error;
+ kill_mysql();
+ my_ok(thd);
+#else
+ my_error(ER_NOT_SUPPORTED_YET, MYF(0), "embedded server");
+#endif
+ break;
+
#ifndef NO_EMBEDDED_ACCESS_CHECKS
case SQLCOM_SHOW_GRANTS:
{
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 4a728d30f25..331a84c5955 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2177,6 +2177,7 @@ static bool check_prepared_statement(Prepared_statement *stmt)
case SQLCOM_GRANT:
case SQLCOM_REVOKE:
case SQLCOM_KILL:
+ case SQLCOM_SHUTDOWN:
break;
case SQLCOM_PREPARE:
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 8e22950aa72..1a12a11eae7 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -789,10 +789,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%pure_parser /* We have threads */
/*
- Currently there are 174 shift/reduce conflicts.
+ Currently there are 196 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
-%expect 174
+%expect 196
/*
Comments for TOKENS.
@@ -1816,6 +1816,7 @@ statement:
| set
| signal_stmt
| show
+ | shutdown
| slave
| start
| truncate
@@ -12217,6 +12218,11 @@ kill_expr:
}
;
+
+shutdown:
+ SHUTDOWN { Lex->sql_command= SQLCOM_SHUTDOWN; }
+ ;
+
/* change database */
use: