![]() |
MySQL 9.2.0
Source Code Documentation
|
Header file for the Command service. More...
#include "mysql/com_data.h"
#include "mysql/service_srv_session.h"
#include "decimal.h"
#include "mysql_time.h"
#include <stdint.h>
#include "field_types.h"
#include "mysql/strings/m_ctype.h"
Go to the source code of this file.
Classes | |
struct | st_send_field |
struct | st_command_service_cbs |
struct | command_service_st |
Typedefs | |
typedef int(* | start_result_metadata_t) (void *ctx, uint num_cols, uint flags, const CHARSET_INFO *resultcs) |
Indicates beginning of metadata for the result set. More... | |
typedef int(* | field_metadata_t) (void *ctx, struct st_send_field *field, const CHARSET_INFO *charset) |
Field metadata is provided via this callback. More... | |
typedef int(* | end_result_metadata_t) (void *ctx, uint server_status, uint warn_count) |
Indicates end of metadata for the result set. More... | |
typedef int(* | start_row_t) (void *ctx) |
Indicates the beginning of a new row in the result set/metadata. More... | |
typedef int(* | end_row_t) (void *ctx) |
Indicates the end of the current row in the result set/metadata. More... | |
typedef void(* | abort_row_t) (void *ctx) |
An error occurred during execution. More... | |
typedef ulong(* | get_client_capabilities_t) (void *ctx) |
Return client's capabilities (see mysql_com.h, CLIENT_*) More... | |
typedef int(* | get_null_t) (void *ctx) |
Receive NULL value from server. More... | |
typedef int(* | get_integer_t) (void *ctx, longlong value) |
Receive TINY/SHORT/LONG value from server. More... | |
typedef int(* | get_longlong_t) (void *ctx, longlong value, uint is_unsigned) |
Get LONGLONG value from server. More... | |
typedef int(* | get_decimal_t) (void *ctx, const decimal_t *value) |
Receive DECIMAL value from server. More... | |
typedef int(* | get_double_t) (void *ctx, double value, uint32_t decimals) |
Receive FLOAT/DOUBLE from server. More... | |
typedef int(* | get_date_t) (void *ctx, const MYSQL_TIME *value) |
Get DATE value from server. More... | |
typedef int(* | get_time_t) (void *ctx, const MYSQL_TIME *value, uint decimals) |
Receive TIME value from server. More... | |
typedef int(* | get_datetime_t) (void *ctx, const MYSQL_TIME *value, uint decimals) |
Receive DATETIME value from server. More... | |
typedef int(* | get_string_t) (void *ctx, const char *value, size_t length, const CHARSET_INFO *valuecs) |
Get STRING value from server. More... | |
typedef void(* | handle_ok_t) (void *ctx, uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *message) |
Command ended with success. More... | |
typedef void(* | handle_error_t) (void *ctx, uint sql_errno, const char *err_msg, const char *sqlstate) |
Command ended with ERROR. More... | |
typedef void(* | shutdown_t) (void *ctx, int server_shutdown) |
Callback for shutdown notification from the server. More... | |
typedef bool(* | connection_alive_t) (void *ctx) |
If the user of the srv_service is bound to a connection, this callback makes it possible to check if the connection is still alive. More... | |
Enumerations | |
enum | cs_text_or_binary { CS_TEXT_REPRESENTATION = 1 , CS_BINARY_REPRESENTATION = 2 } |
Functions | |
int | command_service_run_command (MYSQL_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... | |
Variables | |
struct command_service_st * | command_service |
Header file for the Command service.
This service is to provide means of executing different commands, like COM_QUERY, COM_STMT_PREPARE, in the server.
typedef void(* abort_row_t) (void *ctx) |
An error occurred during execution.
This callback indicates that an error occurred during command execution and the partial row should be dropped. Server will raise error and return.
ctx | Plugin's context |
typedef bool(* connection_alive_t) (void *ctx) |
If the user of the srv_service is bound to a connection, this callback makes it possible to check if the connection is still alive.
It should always return true unless the client closed the connection.
typedef int(* end_result_metadata_t) (void *ctx, uint server_status, uint warn_count) |
Indicates end of metadata for the result set.
ctx | Plugin's context |
server_status | Status of server (see mysql_com.h, SERVER_STATUS_*) |
warn_count | Number of warnings generated during execution to the moment when the metadata is sent. |
typedef int(* end_row_t) (void *ctx) |
Indicates the end of the current row in the result set/metadata.
ctx | Plugin's context |
typedef int(* field_metadata_t) (void *ctx, struct st_send_field *field, const CHARSET_INFO *charset) |
Field metadata is provided via this callback.
ctx | Plugin's context |
field | Field's metadata (see field.h) |
charset | Field's charset |
typedef ulong(* get_client_capabilities_t) (void *ctx) |
Return client's capabilities (see mysql_com.h, CLIENT_*)
ctx | Plugin's context |
typedef int(* get_date_t) (void *ctx, const MYSQL_TIME *value) |
Get DATE value from server.
ctx | Plugin's context |
value | Value received |
typedef int(* get_datetime_t) (void *ctx, const MYSQL_TIME *value, uint decimals) |
Receive DATETIME value from server.
ctx | Plugin's context |
value | Value received |
decimals | Number of decimals |
typedef int(* get_decimal_t) (void *ctx, const decimal_t *value) |
Receive DECIMAL value from server.
ctx | Plugin's context |
value | Value received |
typedef int(* get_double_t) (void *ctx, double value, uint32_t decimals) |
Receive FLOAT/DOUBLE from server.
ctx | Plugin's context |
value | Value received |
decimals | Number of decimals |
typedef int(* get_integer_t) (void *ctx, longlong value) |
Receive TINY/SHORT/LONG value from server.
ctx | Plugin's context |
value | Value received |
typedef int(* get_longlong_t) (void *ctx, longlong value, uint is_unsigned) |
Get LONGLONG value from server.
ctx | Plugin's context |
value | Value received |
is_unsigned | TRUE <=> value is unsigned |
typedef int(* get_null_t) (void *ctx) |
Receive NULL value from server.
ctx | Plugin's context |
typedef int(* get_string_t) (void *ctx, const char *value, size_t length, const CHARSET_INFO *valuecs) |
Get STRING value from server.
ctx | Plugin's context |
value | Data |
length | Data length |
valuecs | Data charset |
In case of CS_TEXT_REPRESENTATION, the string value might be already a stringified value or non-string data, which is in character_set_results.
typedef int(* get_time_t) (void *ctx, const MYSQL_TIME *value, uint decimals) |
Receive TIME value from server.
ctx | Plugin's context |
value | Value received |
decimals | Number of decimals |
typedef void(* handle_error_t) (void *ctx, uint sql_errno, const char *err_msg, const char *sqlstate) |
Command ended with ERROR.
ctx | Plugin's context |
sql_errno | Error code |
err_msg | Error message |
sqlstate | SQL state corresponding to the error code |
typedef void(* handle_ok_t) (void *ctx, uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *message) |
Command ended with success.
ctx | Plugin's context |
server_status | Status of server (see mysql_com.h, SERVER_STATUS_*) |
statement_warn_count | Number of warnings thrown during execution |
affected_rows | Number of rows affected by the command |
last_insert_id | Last insert id being assigned during execution |
message | A message from server |
typedef void(* shutdown_t) (void *ctx, int server_shutdown) |
Callback for shutdown notification from the server.
ctx | Plugin's context |
server_shutdown | Whether this is a normal connection shutdown (0) or server shutdown (1). |
typedef int(* start_result_metadata_t) (void *ctx, uint num_cols, uint flags, const CHARSET_INFO *resultcs) |
Indicates beginning of metadata for the result set.
ctx | Plugin's context |
num_cols | Number of fields being sent |
flags | Flags to alter the metadata sending |
resultcs | Charset of the result set |
In case of CS_BINARY_REPRESENTATION, get_string() receives as a parameter the charset of the string, as it is stored on disk.
In case of CS_TEXT_REPRESENTATION, the string value might be already a stringified value or non-string data, which is in character_set_results.
typedef int(* start_row_t) (void *ctx) |
Indicates the beginning of a new row in the result set/metadata.
ctx | Plugin's context |
enum cs_text_or_binary |
int command_service_run_command | ( | MYSQL_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 :
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.
session | The session |
command | The command to be executed. |
data | The data needed for the command to be executed |
client_cs | The charset for the string data input(COM_QUERY for example) |
callbacks | Callbacks to be used by the server to encode data and to communicate with the client (plugin) side. |
text_or_binary | Select which representation the server will use for the data passed to the callbacks. For more information |
service_callbacks_ctx | Context passed to the command service callbacks |
struct command_service_st * command_service |