mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-4660 SHUTDOWN command
Based on James Briggs contribution.
This commit is contained in:
5
mysql-test/r/shutdown.result
Normal file
5
mysql-test/r/shutdown.result
Normal file
@ -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;
|
28
mysql-test/t/shutdown.test
Normal file
28
mysql-test/t/shutdown.test
Normal file
@ -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;
|
||||||
|
|
@ -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_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_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},
|
{"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_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},
|
{"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},
|
{"stmt_close", (char*) offsetof(STATUS_VAR, com_stmt_close), SHOW_LONG_STATUS},
|
||||||
|
@ -194,7 +194,7 @@ enum enum_sql_command {
|
|||||||
SQLCOM_SHOW_RELAYLOG_EVENTS,
|
SQLCOM_SHOW_RELAYLOG_EVENTS,
|
||||||
SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
|
SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
|
||||||
SQLCOM_SHOW_CLIENT_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
|
When a command is added here, be sure it's also added in mysqld.cc
|
||||||
|
@ -3916,6 +3916,17 @@ end_with_restore_list:
|
|||||||
lex->kill_signal);
|
lex->kill_signal);
|
||||||
break;
|
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
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
case SQLCOM_SHOW_GRANTS:
|
case SQLCOM_SHOW_GRANTS:
|
||||||
{
|
{
|
||||||
|
@ -2177,6 +2177,7 @@ static bool check_prepared_statement(Prepared_statement *stmt)
|
|||||||
case SQLCOM_GRANT:
|
case SQLCOM_GRANT:
|
||||||
case SQLCOM_REVOKE:
|
case SQLCOM_REVOKE:
|
||||||
case SQLCOM_KILL:
|
case SQLCOM_KILL:
|
||||||
|
case SQLCOM_SHUTDOWN:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SQLCOM_PREPARE:
|
case SQLCOM_PREPARE:
|
||||||
|
@ -789,10 +789,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
|||||||
|
|
||||||
%pure_parser /* We have threads */
|
%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.
|
We should not introduce new conflicts any more.
|
||||||
*/
|
*/
|
||||||
%expect 174
|
%expect 196
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Comments for TOKENS.
|
Comments for TOKENS.
|
||||||
@ -1816,6 +1816,7 @@ statement:
|
|||||||
| set
|
| set
|
||||||
| signal_stmt
|
| signal_stmt
|
||||||
| show
|
| show
|
||||||
|
| shutdown
|
||||||
| slave
|
| slave
|
||||||
| start
|
| start
|
||||||
| truncate
|
| truncate
|
||||||
@ -12217,6 +12218,11 @@ kill_expr:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
shutdown:
|
||||||
|
SHUTDOWN { Lex->sql_command= SQLCOM_SHUTDOWN; }
|
||||||
|
;
|
||||||
|
|
||||||
/* change database */
|
/* change database */
|
||||||
|
|
||||||
use:
|
use:
|
||||||
|
Reference in New Issue
Block a user