![]() |
MySQL 9.4.0
Source Code Documentation
|
#include <mysql.h>#include <stddef.h>#include <sys/types.h>#include "errmsg.h"#include "my_command.h"#include "my_compiler.h"#include "my_inttypes.h"#include "my_list.h"#include "mysql_com.h"#include "mysql_com_server.h"Go to the source code of this file.
Classes | |
| struct | STATE_INFO_NODE |
| The structure is used to hold the state change information received from the server. More... | |
| struct | STATE_INFO |
| Store the change info received from the server in an array of linked lists with STATE_INFO_NODE elements (one per state type). More... | |
| struct | MYSQL_EXTENSION |
| struct | client_authentication_info |
| struct | st_mysql_options_extention |
| struct | MYSQL_METHODS |
Macros | |
| #define | MYSQL_EXTENSION_PTR(H) |
| #define | ASYNC_DATA(M) (NULL != (M) ? (MYSQL_EXTENSION_PTR(M)->mysql_async_context) : NULL) |
| #define | MAX_AUTHENTICATION_FACTOR 3 |
| #define | MYSQL_OPTIONS_EXTENSION_PTR(H, what) ((H)->options.extension ? (H)->options.extension->what : nullptr) |
| #define | simple_command(mysql, command, arg, length, skip_check) |
| #define | simple_command_nonblocking(mysql, command, arg, length, skip_check, error) |
| #define | stmt_command(mysql, command, arg, length, stmt) |
| #define | protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41) |
| #define | AUTH_NEXT_FACTOR_PACKETTYPE 2 |
Functions | |
| void | mysql_close_free (MYSQL *mysql) |
| void | mysql_close_free_options (MYSQL *mysql) |
| MYSQL_EXTENSION * | mysql_extension_init (MYSQL *) |
| void | mysql_extension_free (MYSQL_EXTENSION *) |
| void | mysql_extension_bind_free (MYSQL_EXTENSION *ext) |
| void | mysql_extension_set_server_extn (MYSQL *mysql, NET_SERVER *extn) |
| Sets the MYSQL_EXTENSION::server_extn attribute by the use of NET_SERVER which contains information about compression context and compression attributes. More... | |
| MYSQL_FIELD * | unpack_fields (MYSQL *mysql, MYSQL_ROWS *data, MEM_ROOT *alloc, uint fields, bool default_value, uint server_capabilities) |
| MYSQL_FIELD * | cli_read_metadata_ex (MYSQL *mysql, MEM_ROOT *alloc, unsigned long field_count, unsigned int fields) |
| MYSQL_FIELD * | cli_read_metadata (MYSQL *mysql, unsigned long field_count, unsigned int fields) |
| MYSQL_RES * | use_result (MYSQL *mysql) |
| MYSQL * | connect_helper (mysql_async_connect *ctx) |
| void | free_rows (MYSQL_DATA *cur) |
| void | free_old_query (MYSQL *mysql) |
| void | end_server (MYSQL *mysql) |
| bool | mysql_reconnect (MYSQL *mysql) |
| void | mysql_read_default_options (struct st_mysql_options *options, const char *filename, const char *group) |
| bool | cli_advanced_command (MYSQL *mysql, enum enum_server_command command, const unsigned char *header, size_t header_length, const unsigned char *arg, size_t arg_length, bool skip_check, MYSQL_STMT *stmt) |
| unsigned long | cli_safe_read (MYSQL *mysql, bool *is_data_packet) |
| Read a packet from server. More... | |
| enum net_async_status | cli_safe_read_nonblocking (MYSQL *mysql, bool *is_data_packet, ulong *res) |
| Its a non blocking version of cli_safe_read. More... | |
| unsigned long | cli_safe_read_with_ok (MYSQL *mysql, bool parse_ok, bool *is_data_packet) |
| Read a packet from server. More... | |
| void | net_clear_error (NET *net) |
| Clear possible error state of struct NET. More... | |
| void | set_stmt_errmsg (MYSQL_STMT *stmt, NET *net) |
| Set statement error code, sqlstate, and error message from NET. More... | |
| void | set_stmt_error (MYSQL_STMT *stmt, int errcode, const char *sqlstate) |
| Set statement error code, sqlstate, and error message from given errcode and sqlstate. More... | |
| void | set_stmt_extended_error (MYSQL_STMT *stmt, int errcode, const char *sqlstate, const char *format,...) |
| Set statement error code, sqlstate, and error message from given errcode and sqlstate. More... | |
| void | set_mysql_error (MYSQL *mysql, int errcode, const char *sqlstate) |
| Set the internal error message to mysql handler. More... | |
| void | set_mysql_extended_error (MYSQL *mysql, int errcode, const char *sqlstate, const char *format,...) |
| Set an error message on the client. More... | |
| void | mpvio_info (MYSQL_VIO vio, MYSQL_PLUGIN_VIO_INFO *info) |
| int | run_plugin_auth (MYSQL *mysql, char *data, uint data_len, const char *data_plugin, const char *db) |
| Client side of the plugin driver authentication. More... | |
| int | mysql_client_plugin_init () |
| Initializes the client plugin layer. More... | |
| void | mysql_client_plugin_deinit () |
| Deinitializes the client plugin layer. More... | |
| uchar * | send_client_connect_attrs (MYSQL *mysql, uchar *buf) |
| int | is_file_or_dir_world_writable (const char *filepath) |
| Check if a file/dir is world-writable (only on non-Windows platforms) More... | |
| void | read_ok_ex (MYSQL *mysql, unsigned long len) |
| bool | fix_param_bind (MYSQL_BIND *param, uint idx) |
| bool | mysql_int_serialize_param_data (NET *net, unsigned int param_count, MYSQL_BIND *params, const char **names, unsigned long n_param_sets, uchar **ret_data, ulong *ret_length, uchar send_types_to_server, bool send_named_params, bool send_parameter_set_count, bool send_parameter_count_when_zero) |
| Serialize the query parameters. More... | |
Variables | |
| const char * | unknown_sqlstate |
| const char * | cant_connect_sqlstate |
| const char * | not_error_sqlstate |
| CHARSET_INFO * | default_client_charset_info |
| struct st_mysql_client_plugin * | mysql_client_builtins [] |
| bool | libmysql_cleartext_plugin_enabled |
| #define AUTH_NEXT_FACTOR_PACKETTYPE 2 |
| #define MAX_AUTHENTICATION_FACTOR 3 |
| #define MYSQL_EXTENSION_PTR | ( | H | ) |
| #define MYSQL_OPTIONS_EXTENSION_PTR | ( | H, | |
| what | |||
| ) | ((H)->options.extension ? (H)->options.extension->what : nullptr) |
| #define protocol_41 | ( | A | ) | ((A)->server_capabilities & CLIENT_PROTOCOL_41) |
| #define simple_command | ( | mysql, | |
| command, | |||
| arg, | |||
| length, | |||
| skip_check | |||
| ) |
| #define simple_command_nonblocking | ( | mysql, | |
| command, | |||
| arg, | |||
| length, | |||
| skip_check, | |||
| error | |||
| ) |
| #define stmt_command | ( | mysql, | |
| command, | |||
| arg, | |||
| length, | |||
| stmt | |||
| ) |
| bool cli_advanced_command | ( | MYSQL * | mysql, |
| enum enum_server_command | command, | ||
| const unsigned char * | header, | ||
| size_t | header_length, | ||
| const unsigned char * | arg, | ||
| size_t | arg_length, | ||
| bool | skip_check, | ||
| MYSQL_STMT * | stmt | ||
| ) |
| MYSQL_FIELD * cli_read_metadata | ( | MYSQL * | mysql, |
| unsigned long | field_count, | ||
| unsigned int | fields | ||
| ) |
| MYSQL_FIELD * cli_read_metadata_ex | ( | MYSQL * | mysql, |
| MEM_ROOT * | alloc, | ||
| unsigned long | field_count, | ||
| unsigned int | fields | ||
| ) |
| unsigned long cli_safe_read | ( | MYSQL * | mysql, |
| bool * | is_data_packet | ||
| ) |
Read a packet from server.
Give error message if connection was broken or ERR packet was received. Detect if the packet received was an OK, ERR or something else (a "data packet").
| [in] | mysql | connection handle |
| [out] | is_data_packet | if set to true then the packet received was a "data packet". |
| The | length of the packet that was read or packet_error in case of error. In case of error its description is stored in mysql handle. |
| enum net_async_status cli_safe_read_nonblocking | ( | MYSQL * | mysql, |
| bool * | is_data_packet, | ||
| ulong * | res | ||
| ) |
Its a non blocking version of cli_safe_read.
| unsigned long cli_safe_read_with_ok | ( | MYSQL * | mysql, |
| bool | parse_ok, | ||
| bool * | is_data_packet | ||
| ) |
Read a packet from server.
Give error message if socket was down or packet is an error message
| [in] | mysql | connection handle |
| [in] | parse_ok | if set to true then parse OK packet if it is received |
| [out] | is_data_packet | if set to true then packet received is a "data packet", that is not OK or ERR packet or EOF in case of old servers |
| MYSQL * connect_helper | ( | mysql_async_connect * | ctx | ) |
| void end_server | ( | MYSQL * | mysql | ) |
| bool fix_param_bind | ( | MYSQL_BIND * | param, |
| uint | idx | ||
| ) |
| void free_old_query | ( | MYSQL * | mysql | ) |
| void free_rows | ( | MYSQL_DATA * | cur | ) |
| int is_file_or_dir_world_writable | ( | const char * | path | ) |
Check if a file/dir is world-writable (only on non-Windows platforms)
| [in] | path | Path of the file/dir to be checked |
| -2 | Permission denied to check attributes of file/dir |
| -1 | Error in reading file/dir |
| 0 | File/dir is not world-writable |
| 1 | File/dir is world-writable |
| void mpvio_info | ( | MYSQL_VIO | vio, |
| MYSQL_PLUGIN_VIO_INFO * | info | ||
| ) |
| void mysql_client_plugin_deinit | ( | ) |
Deinitializes the client plugin layer.
Unloades all client plugins and frees any associated resources.
| int mysql_client_plugin_init | ( | ) |
Initializes the client plugin layer.
This function must be called before any other client plugin function.
| 0 | successful |
| != | 0 error occurred |
| void mysql_close_free | ( | MYSQL * | mysql | ) |
| void mysql_close_free_options | ( | MYSQL * | mysql | ) |
| void mysql_extension_bind_free | ( | MYSQL_EXTENSION * | ext | ) |
| void mysql_extension_free | ( | MYSQL_EXTENSION * | ext | ) |
| MYSQL_EXTENSION * mysql_extension_init | ( | MYSQL * | mysql | ) |
|
inline |
Sets the MYSQL_EXTENSION::server_extn attribute by the use of NET_SERVER which contains information about compression context and compression attributes.
This attribute needs to be set each time mysql_real_connect() is called to make a connection. When a connection attempt fails or when a connection is closed, as part of the MYSQL handle cleanup, mysql_close_free() is called and that will free MYSQL_EXTENSION::server_extn.
mysql_close_free() will free all the memory allocated in the MYSQL handle but preserves MYSQL::options. These options are later free'd by mysql_close_free_options() unless the client flag CLIENT_REMEMBER_OPTIONS is set.
| mysql | The MYSQL handle |
| extn | The NET_SERVER handle that contains compression context info. |
| bool mysql_int_serialize_param_data | ( | NET * | net, |
| unsigned int | param_count, | ||
| MYSQL_BIND * | params, | ||
| const char ** | names, | ||
| unsigned long | n_param_sets, | ||
| uchar ** | ret_data, | ||
| ulong * | ret_length, | ||
| uchar | send_types_to_server, | ||
| bool | send_named_params, | ||
| bool | send_parameter_set_count, | ||
| bool | send_parameter_count_when_zero | ||
| ) |
Serialize the query parameters.
Used by mysql_real_query, mysql_real_query_nonblocking and mysql_stmt_execute()
Must be called on connected sessions only.
| net | the NET to use as a string buffer serializing the params. It's cleared at start. | |
| param_count | the number of parameters to send | |
| params | the filled in MYSQL_BIND structure to retrieve the values from | |
| names | the names of the parameters in the params argument | |
| n_param_sets | the number of sets of values to set | |
| [out] | ret_data | the buffer to the serialized parameter representation |
| [out] | ret_length | the number of bytes stored into the buffer |
| send_types_to_server | : whether to send the parameter types to the server or not | |
| send_named_params | : whether the names of the parameters should be sent | |
| send_parameter_set_count | : whether to send 1 as parameter count or not | |
| send_parameter_count_when_zero | ON to send the param count even when it's zero |
| true | execution failed. Error in NET |
| false | execution succeeded |
| void mysql_read_default_options | ( | struct st_mysql_options * | options, |
| const char * | filename, | ||
| const char * | group | ||
| ) |
| bool mysql_reconnect | ( | MYSQL * | mysql | ) |
| void net_clear_error | ( | NET * | net | ) |
Clear possible error state of struct NET.
| net | clear the state of the argument |
| void read_ok_ex | ( | MYSQL * | mysql, |
| unsigned long | len | ||
| ) |
| int run_plugin_auth | ( | MYSQL * | mysql, |
| char * | data, | ||
| uint | data_len, | ||
| const char * | data_plugin, | ||
| const char * | db | ||
| ) |
Client side of the plugin driver authentication.
| mysql | mysql |
| data | pointer to the plugin auth data (scramble) in the handshake packet |
| data_len | the length of the data |
| data_plugin | a plugin that data were prepared for or 0 if it's mysql_change_user() |
| db | initial db to use, can be 0 |
| 0 | ok |
| 1 | error |
| void set_mysql_error | ( | MYSQL * | mysql, |
| int | errcode, | ||
| const char * | sqlstate | ||
| ) |
Set the internal error message to mysql handler.
| mysql | connection handle (client side) |
| errcode | CR_ error code, passed to ER macro to get error text |
| sqlstate | SQL standard sqlstate |
| void set_mysql_extended_error | ( | MYSQL * | mysql, |
| int | errcode, | ||
| const char * | sqlstate, | ||
| const char * | format, | ||
| ... | |||
| ) |
Set an error message on the client.
| mysql | connection handle |
| errcode | CR_* errcode, for client errors |
| sqlstate | SQL standard sql state, unknown_sqlstate for the majority of client errors. |
| format | error message template, in sprintf format |
| ... | variable number of arguments |
| void set_stmt_errmsg | ( | MYSQL_STMT * | stmt, |
| NET * | net | ||
| ) |
Set statement error code, sqlstate, and error message from NET.
| stmt | a statement handle. Copy the error here. |
| net | mysql->net. Source of the error. |
| void set_stmt_error | ( | MYSQL_STMT * | stmt, |
| int | errcode, | ||
| const char * | sqlstate | ||
| ) |
Set statement error code, sqlstate, and error message from given errcode and sqlstate.
| void set_stmt_extended_error | ( | MYSQL_STMT * | stmt, |
| int | errcode, | ||
| const char * | sqlstate, | ||
| const char * | format, | ||
| ... | |||
| ) |
Set statement error code, sqlstate, and error message from given errcode and sqlstate.
| MYSQL_FIELD * unpack_fields | ( | MYSQL * | mysql, |
| MYSQL_ROWS * | data, | ||
| MEM_ROOT * | alloc, | ||
| uint | fields, | ||
| bool | default_value, | ||
| uint | server_capabilities | ||
| ) |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |