MySQL 8.4.3
Source Code Documentation
command_service.cc File Reference

Command service implementation. More...

Functions

int command_service_run_command (Srv_session *session, enum enum_server_command command, const union COM_DATA *data, const CHARSET_INFO *client_cs, const struct st_command_service_cbs *callbacks, enum cs_text_or_binary text_or_binary, void *service_callbacks_ctx)
 Executes a server command in a session. More...
 

Detailed Description

Command service implementation.

For more information please check the function comments.

Function Documentation

◆ command_service_run_command()

int command_service_run_command ( Srv_session session,
enum enum_server_command  command,
const union COM_DATA data,
const CHARSET_INFO client_cs,
const struct st_command_service_cbs callbacks,
enum cs_text_or_binary  text_or_binary,
void *  service_callbacks_ctx 
)

Executes a server command in a session.

There are two cases. Execution in a physical thread :

  1. initialized by the srv_session service
  2. NOT initialized by the srv_session service

In case of 1, if there is currently attached session, and it is different from the passed one, the former will be automatically detached. The session to be used for the execution will then be attached. After the command is executed, the attached session will not be detached. It will be detached by a next call to run_command() with another session as parameter. In other words, for all sessions used in a physical thread, there will be at most one in attached state.

In case of 2, the current state (current_thd) will be preserved. Then the given session will move to attached state and the command will be executed. After the execution the state of the session will be changed to detached and the preserved state (current_thd) will be restored.

The client charset is used for commands like COM_QUERY and COM_STMT_PREPARE to know how to threat the char* fields. This charset will be used until the next call of run_command when it may be changed again.

Parameters
sessionThe session
commandThe command to be executed.
dataThe data needed for the command to be executed
client_csThe charset for the string data input(COM_QUERY for example)
callbacksCallbacks to be used by the server to encode data and to communicate with the client (plugin) side.
text_or_binarySee enum cs_text_or_binary
service_callbacks_ctxContext passed to the command service callbacks
Returns
0 success 1 failure