Skip to content

Commit d2dfc1d

Browse files
committed
Bug#36835161: mysql_command_services does not work with x-protocol
The command_services suite uses the sql server sessions as an underlying mechanism. This was never supposed to work recursively: i.e. a command using sessions executed in a session should fail. Added a check to the command service to ensure it's not usable in such a context. Fixed some error handling in the test UDF. Change-Id: Idb8e4793a3363a1aed6c6b8789445dec8ac462fd
1 parent 708c308 commit d2dfc1d

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

components/test/test_mysql_command_services.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ static char *test_mysql_command_services_udf(UDF_INIT *, UDF_ARGS *args,
9090
unsigned int err_no;
9191
char *sqlstate_errmsg[50];
9292

93+
/* reset to empty as a start */
94+
*result = 0;
95+
9396
// Execute the SQL specified in the argument.
9497
if (cmd_factory_srv->init(&mysql_h)) {
9598
return nullptr;

share/messages_to_clients.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9966,6 +9966,9 @@ ER_VALIDATE_PASSWORD_INSUFFICIENT_CHANGED_CHARACTERS
99669966
ER_WARN_DEPRECATED_WITH_NOTE
99679967
eng "'%s' is deprecated and will be removed in a future release. %s"
99689968

9969+
ER_CANT_RUN_COMMAND_SERVICES_RECURSIVELY
9970+
eng "Running recursive calls to SQL execution service is not supported"
9971+
99699972
#
99709973
# End of 8.0 error messages (server-to-client).
99719974
# Do NOT add messages intended for the error log above!

sql/server_component/mysql_command_services_imp.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ struct Error_handler {
6161
DEFINE_BOOL_METHOD(mysql_command_services_imp::init, (MYSQL_H * mysql_h)) {
6262
bool ret = false;
6363
try {
64+
/* Not supposed to work recursively */
65+
if (current_thd->is_a_srv_session()) {
66+
my_error(ER_CANT_RUN_COMMAND_SERVICES_RECURSIVELY, MYF(0));
67+
return true;
68+
}
6469
Mysql_handle *mysql_handle = (Mysql_handle *)my_malloc(
6570
key_memory_query_service, sizeof(Mysql_handle),
6671
MYF(MY_WME | MY_ZEROFILL));

0 commit comments

Comments
 (0)