diff --git a/sql/server_component/mysql_command_backend.cc b/sql/server_component/mysql_command_backend.cc index b962b1c3421..9ff9c21488f 100644 --- a/sql/server_component/mysql_command_backend.cc +++ b/sql/server_component/mysql_command_backend.cc @@ -277,10 +277,13 @@ bool csi_advanced_command(MYSQL *mysql, enum enum_server_command command, } mysql_handle.mysql = mysql; - if (mcs_extn->consumer_srv_data != nullptr) - srv_ctx_h = reinterpret_cast(mcs_extn->consumer_srv_data); - else if (((class mysql_command_consumer_refs *)(command_consumer_srv)) - ->factory_srv->start(&srv_ctx_h, (MYSQL_H *)&mysql_handle)) { + if (mcs_extn->consumer_srv_data != nullptr) { + ((class mysql_command_consumer_refs *)(command_consumer_srv)) + ->factory_srv->end( + reinterpret_cast(mcs_extn->consumer_srv_data)); + } + if (((class mysql_command_consumer_refs *)(command_consumer_srv)) + ->factory_srv->start(&srv_ctx_h, (MYSQL_H *)&mysql_handle)) { sprintf(*err_msg, "Could not create %s service", "mysql_text_consumer_factory_v1"); goto error;