MySQL 8.0.39
Source Code Documentation
mysql_com.h File Reference

Common definition between mysql server & client. More...

#include <stdbool.h>
#include <stdint.h>
#include "my_command.h"
#include "my_compress.h"
#include "my_io.h"
#include "mysql/components/services/bits/my_io_bits.h"
#include "mysql/udf_registration_types.h"

Go to the source code of this file.

Classes

struct  NET
 
struct  rand_struct
 

Macros

#define SYSTEM_CHARSET_MBMAXLEN   3
 
#define FILENAME_CHARSET_MBMAXLEN   5
 
#define NAME_CHAR_LEN   64
 Field/table name length. More...
 
#define PARTITION_EXPR_CHAR_LEN    2048
 Maximum expression length in chars . More...
 
#define USERNAME_CHAR_LENGTH   32
 
#define USERNAME_CHAR_LENGTH_STR   "32"
 
#define NAME_LEN   (NAME_CHAR_LEN * SYSTEM_CHARSET_MBMAXLEN)
 
#define USERNAME_LENGTH   (USERNAME_CHAR_LENGTH * SYSTEM_CHARSET_MBMAXLEN)
 
#define CONNECT_STRING_MAXLEN   1024
 
#define MYSQL_AUTODETECT_CHARSET_NAME   "auto"
 
#define SERVER_VERSION_LENGTH   60
 
#define SQLSTATE_LENGTH   5
 
#define RELYING_PARTY_ID_LENGTH   255
 
#define CHALLENGE_LENGTH   32
 
#define MAX_AUTH_FACTORS   3
 
#define TABLE_COMMENT_INLINE_MAXLEN   180
 Maximum length of comments. More...
 
#define TABLE_COMMENT_MAXLEN   2048
 
#define COLUMN_COMMENT_MAXLEN   1024
 
#define INDEX_COMMENT_MAXLEN   1024
 
#define TABLE_PARTITION_COMMENT_MAXLEN   1024
 
#define TABLESPACE_COMMENT_MAXLEN   2048
 
#define MAX_PACKET_LENGTH   (256L * 256L * 256L - 1)
 Maximum length of protocol packet. More...
 
#define LOCAL_HOST   "localhost"
 
#define LOCAL_HOST_NAMEDPIPE   "."
 
#define FRM_GCOL_HEADER_SIZE   4
 The length of the header part for each generated column in the .frm file. More...
 
#define GENERATED_COLUMN_EXPRESSION_MAXLEN   65535 - FRM_GCOL_HEADER_SIZE
 Maximum length of the expression statement defined for generated columns. More...
 
#define SCRAMBLE_LENGTH   20
 Length of random string sent by server on handshake; this is also length of obfuscated password, received from client. More...
 
#define AUTH_PLUGIN_DATA_PART_1_LENGTH   8
 
#define SCRAMBLED_PASSWORD_CHAR_LENGTH   (SCRAMBLE_LENGTH * 2 + 1)
 length of password stored in the db: new passwords are preceded with '*' More...
 
#define NOT_NULL_FLAG   1
 Field can't be NULL. More...
 
#define PRI_KEY_FLAG   2
 Field is part of a primary key. More...
 
#define UNIQUE_KEY_FLAG   4
 Field is part of a unique key. More...
 
#define MULTIPLE_KEY_FLAG   8
 Field is part of a key. More...
 
#define BLOB_FLAG   16
 Field is a blob. More...
 
#define UNSIGNED_FLAG   32
 Field is unsigned. More...
 
#define ZEROFILL_FLAG   64
 Field is zerofill. More...
 
#define BINARY_FLAG   128
 Field is binary
More...
 
#define ENUM_FLAG   256
 field is an enum More...
 
#define AUTO_INCREMENT_FLAG   512
 field is a autoincrement field More...
 
#define TIMESTAMP_FLAG   1024
 Field is a timestamp. More...
 
#define SET_FLAG   2048
 field is a set More...
 
#define NO_DEFAULT_VALUE_FLAG   4096
 Field doesn't have default value. More...
 
#define ON_UPDATE_NOW_FLAG   8192
 Field is set to NOW on UPDATE. More...
 
#define NUM_FLAG   32768
 Field is num (for clients) More...
 
#define PART_KEY_FLAG   16384
 Intern; Part of some key. More...
 
#define GROUP_FLAG   32768
 Intern: Group field. More...
 
#define UNIQUE_FLAG   65536
 Intern: Used by sql_yacc. More...
 
#define BINCMP_FLAG   131072
 Intern: Used by sql_yacc. More...
 
#define GET_FIXED_FIELDS_FLAG    (1 << 18)
 Used to get fields in item tree . More...
 
#define FIELD_IN_PART_FUNC_FLAG   (1 << 19)
 Field part of partition func. More...
 
#define FIELD_IN_ADD_INDEX   (1 << 20)
 Intern: Field in TABLE object for new version of altered table, which participates in a newly added index. More...
 
#define FIELD_IS_RENAMED   (1 << 21)
 Intern: Field is being renamed. More...
 
#define FIELD_FLAGS_STORAGE_MEDIA   22
 Field storage media, bit 22-23. More...
 
#define FIELD_FLAGS_STORAGE_MEDIA_MASK   (3 << FIELD_FLAGS_STORAGE_MEDIA)
 
#define FIELD_FLAGS_COLUMN_FORMAT   24
 Field column format, bit 24-25. More...
 
#define FIELD_FLAGS_COLUMN_FORMAT_MASK   (3 << FIELD_FLAGS_COLUMN_FORMAT)
 
#define FIELD_IS_DROPPED   (1 << 26)
 Intern: Field is being dropped. More...
 
#define EXPLICIT_NULL_FLAG    (1 << 27)
 Field is explicitly specified as \ NULL by the user. More...
 
#define NOT_SECONDARY_FLAG   (1 << 29)
 Field will not be loaded in secondary engine. More...
 
#define FIELD_IS_INVISIBLE   (1 << 30)
 Field is explicitly marked as invisible by the user. More...
 
#define REFRESH_GRANT   1
 Refresh grant tables, FLUSH PRIVILEGES. More...
 
#define REFRESH_LOG   2
 Start on new log file, FLUSH LOGS. More...
 
#define REFRESH_TABLES   4
 close all tables, FLUSH TABLES More...
 
#define REFRESH_HOSTS   8
 Flush host cache, FLUSH HOSTS. More...
 
#define REFRESH_STATUS   16
 Flush status variables, FLUSH STATUS. More...
 
#define REFRESH_THREADS   32
 Flush thread cache. More...
 
#define REFRESH_REPLICA    64
 Reset master info and restart replica \ thread, RESET REPLICA. More...
 
#define REFRESH_SLAVE    REFRESH_REPLICA
 Reset master info and restart replica \ thread, RESET REPLICA. More...
 
#define REFRESH_MASTER    128
 Remove all bin logs in the index \ and truncate the index, RESET MASTER. More...
 
#define REFRESH_ERROR_LOG   256
 Rotate only the error log. More...
 
#define REFRESH_ENGINE_LOG   512
 Flush all storage engine logs. More...
 
#define REFRESH_BINARY_LOG   1024
 Flush the binary log. More...
 
#define REFRESH_RELAY_LOG   2048
 Flush the relay log. More...
 
#define REFRESH_GENERAL_LOG   4096
 Flush the general log. More...
 
#define REFRESH_SLOW_LOG   8192
 Flush the slow query log. More...
 
#define REFRESH_READ_LOCK   16384
 Lock tables for read. More...
 
#define REFRESH_FAST   32768
 Wait for an impending flush before closing the tables. More...
 
#define REFRESH_USER_RESOURCES
 
#define REFRESH_FOR_EXPORT   0x100000L /** FLUSH TABLES ... FOR EXPORT */
 
#define REFRESH_OPTIMIZER_COSTS   0x200000L /** FLUSH OPTIMIZER_COSTS */
 
#define REFRESH_PERSIST   0x400000L /** RESET PERSIST */
 
#define CLIENT_LONG_PASSWORD   1
 Use the improved version of Old Password Authentication. More...
 
#define CLIENT_FOUND_ROWS   2
 Send found rows instead of affected rows in EOF_Packet. More...
 
#define CLIENT_LONG_FLAG   4
 Get all column flags. More...
 
#define CLIENT_CONNECT_WITH_DB   8
 Database (schema) name can be specified on connect in Handshake Response Packet. More...
 
#define CLIENT_NO_SCHEMA    16
 DEPRECATED: Don't allow database.table.column. More...
 
#define CLIENT_COMPRESS   32
 Compression protocol supported. More...
 
#define CLIENT_ODBC   64
 Special handling of ODBC behavior. More...
 
#define CLIENT_LOCAL_FILES   128
 Can use LOAD DATA LOCAL. More...
 
#define CLIENT_IGNORE_SPACE   256
 Ignore spaces before '('. More...
 
#define CLIENT_PROTOCOL_41   512
 New 4.1 protocol. More...
 
#define CLIENT_INTERACTIVE   1024
 This is an interactive client. More...
 
#define CLIENT_SSL   2048
 Use SSL encryption for the session. More...
 
#define CLIENT_IGNORE_SIGPIPE   4096
 Client only flag. More...
 
#define CLIENT_TRANSACTIONS   8192
 Client knows about transactions. More...
 
#define CLIENT_RESERVED   16384
 DEPRECATED: Old flag for 4.1 protocol
More...
 
#define CLIENT_RESERVED2    32768
 DEPRECATED: Old flag for 4.1 authentication \ CLIENT_SECURE_CONNECTION. More...
 
#define CLIENT_MULTI_STATEMENTS   (1UL << 16)
 Enable/disable multi-stmt support. More...
 
#define CLIENT_MULTI_RESULTS   (1UL << 17)
 Enable/disable multi-results. More...
 
#define CLIENT_PS_MULTI_RESULTS   (1UL << 18)
 Multi-results and OUT parameters in PS-protocol. More...
 
#define CLIENT_PLUGIN_AUTH   (1UL << 19)
 Client supports plugin authentication. More...
 
#define CLIENT_CONNECT_ATTRS   (1UL << 20)
 Client supports connection attributes. More...
 
#define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA   (1UL << 21)
 Enable authentication response packet to be larger than 255 bytes. More...
 
#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS   (1UL << 22)
 Don't close the connection for a user account with expired password. More...
 
#define CLIENT_SESSION_TRACK   (1UL << 23)
 Capable of handling server state change information. More...
 
#define CLIENT_DEPRECATE_EOF   (1UL << 24)
 Client no longer needs EOF_Packet and will use OK_Packet instead. More...
 
#define CLIENT_OPTIONAL_RESULTSET_METADATA   (1UL << 25)
 The client can handle optional metadata information in the resultset. More...
 
#define CLIENT_ZSTD_COMPRESSION_ALGORITHM   (1UL << 26)
 Compression protocol extended to support zstd compression method. More...
 
#define CLIENT_QUERY_ATTRIBUTES   (1UL << 27)
 Support optional extension for query parameters into the COM_QUERY and COM_STMT_EXECUTE packets. More...
 
#define MULTI_FACTOR_AUTHENTICATION   (1UL << 28)
 Support Multi factor authentication. More...
 
#define CLIENT_CAPABILITY_EXTENSION   (1UL << 29)
 This flag will be reserved to extend the 32bit capabilities structure to 64bits. More...
 
#define CLIENT_SSL_VERIFY_SERVER_CERT   (1UL << 30)
 Verify server certificate. More...
 
#define CLIENT_REMEMBER_OPTIONS   (1UL << 31)
 Don't reset the options after an unsuccessful connect. More...
 
#define CAN_CLIENT_COMPRESS   CLIENT_COMPRESS
 a compatibility alias for CLIENT_COMPRESS More...
 
#define CLIENT_ALL_FLAGS
 Gather all possible capabilities (flags) supported by the server. More...
 
#define CLIENT_BASIC_FLAGS
 Switch off from CLIENT_ALL_FLAGS the flags that are optional and depending on build flags. More...
 
#define SERVER_STATUS_CLEAR_SET
 Server status flags that must be cleared when starting execution of a new SQL statement. More...
 
#define MYSQL_ERRMSG_SIZE   512
 Max length of a error message. More...
 
#define NET_READ_TIMEOUT   30
 Timeout on read. More...
 
#define NET_WRITE_TIMEOUT   60
 Timeout on write. More...
 
#define NET_WAIT_TIMEOUT   8 * 60 * 60
 Wait for new query. More...
 
#define ONLY_KILL_QUERY   1
 Flag used by the parser. More...
 
#define MYSQL_VIO   struct Vio *
 
#define MAX_TINYINT_WIDTH   3
 Max width for a TINY w.o. More...
 
#define MAX_SMALLINT_WIDTH   5
 Max width for a SHORT w.o. More...
 
#define MAX_MEDIUMINT_WIDTH   8
 Max width for a INT24 w.o. More...
 
#define MAX_INT_WIDTH   10
 Max width for a LONG w.o. More...
 
#define MAX_BIGINT_WIDTH   20
 Max width for a LONGLONG. More...
 
#define MAX_CHAR_WIDTH   255
 Max width for a CHAR column, in number of characters. More...
 
#define MAX_BLOB_WIDTH   16777216
 Default width for blob in bytes. More...
 
#define NET_ERROR_UNSET   0
 No error has occurred yet. More...
 
#define NET_ERROR_SOCKET_RECOVERABLE   1
 Socket still usable. More...
 
#define NET_ERROR_SOCKET_UNUSABLE   2
 Do not use the socket. More...
 
#define NET_ERROR_SOCKET_NOT_READABLE   3
 Try write and close socket. More...
 
#define NET_ERROR_SOCKET_NOT_WRITABLE   4
 Try read and close socket. More...
 
#define packet_error   (~(unsigned long)0)
 
#define CLIENT_MULTI_QUERIES   CLIENT_MULTI_STATEMENTS
 
#define FIELD_TYPE_DECIMAL   MYSQL_TYPE_DECIMAL
 
#define FIELD_TYPE_NEWDECIMAL   MYSQL_TYPE_NEWDECIMAL
 
#define FIELD_TYPE_TINY   MYSQL_TYPE_TINY
 
#define FIELD_TYPE_SHORT   MYSQL_TYPE_SHORT
 
#define FIELD_TYPE_LONG   MYSQL_TYPE_LONG
 
#define FIELD_TYPE_FLOAT   MYSQL_TYPE_FLOAT
 
#define FIELD_TYPE_DOUBLE   MYSQL_TYPE_DOUBLE
 
#define FIELD_TYPE_NULL   MYSQL_TYPE_NULL
 
#define FIELD_TYPE_TIMESTAMP   MYSQL_TYPE_TIMESTAMP
 
#define FIELD_TYPE_LONGLONG   MYSQL_TYPE_LONGLONG
 
#define FIELD_TYPE_INT24   MYSQL_TYPE_INT24
 
#define FIELD_TYPE_DATE   MYSQL_TYPE_DATE
 
#define FIELD_TYPE_TIME   MYSQL_TYPE_TIME
 
#define FIELD_TYPE_DATETIME   MYSQL_TYPE_DATETIME
 
#define FIELD_TYPE_YEAR   MYSQL_TYPE_YEAR
 
#define FIELD_TYPE_NEWDATE   MYSQL_TYPE_NEWDATE
 
#define FIELD_TYPE_ENUM   MYSQL_TYPE_ENUM
 
#define FIELD_TYPE_SET   MYSQL_TYPE_SET
 
#define FIELD_TYPE_TINY_BLOB   MYSQL_TYPE_TINY_BLOB
 
#define FIELD_TYPE_MEDIUM_BLOB   MYSQL_TYPE_MEDIUM_BLOB
 
#define FIELD_TYPE_LONG_BLOB   MYSQL_TYPE_LONG_BLOB
 
#define FIELD_TYPE_BLOB   MYSQL_TYPE_BLOB
 
#define FIELD_TYPE_VAR_STRING   MYSQL_TYPE_VAR_STRING
 
#define FIELD_TYPE_STRING   MYSQL_TYPE_STRING
 
#define FIELD_TYPE_CHAR   MYSQL_TYPE_TINY
 
#define FIELD_TYPE_INTERVAL   MYSQL_TYPE_ENUM
 
#define FIELD_TYPE_GEOMETRY   MYSQL_TYPE_GEOMETRY
 
#define FIELD_TYPE_BIT   MYSQL_TYPE_BIT
 
#define MYSQL_SHUTDOWN_KILLABLE_CONNECT   (unsigned char)(1 << 0)
 
#define MYSQL_SHUTDOWN_KILLABLE_TRANS   (unsigned char)(1 << 1)
 
#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE   (unsigned char)(1 << 2)
 
#define MYSQL_SHUTDOWN_KILLABLE_UPDATE   (unsigned char)(1 << 3)
 
#define SESSION_TRACK_BEGIN   SESSION_TRACK_SYSTEM_VARIABLES
 start of enum_session_state_type More...
 
#define SESSION_TRACK_END   SESSION_TRACK_TRANSACTION_STATE
 End of enum_session_state_type. More...
 
#define IS_SESSION_STATE_TYPE(T)    (((int)(T) >= SESSION_TRACK_BEGIN) && ((T) <= SESSION_TRACK_END))
 is T a valid session state type More...
 
#define net_new_transaction(net)   ((net)->pkt_nr = 0)
 
#define NET_HEADER_SIZE   4
 standard header size More...
 
#define COMP_HEADER_SIZE   3
 compression header extra size More...
 
#define NULL_LENGTH   ((unsigned long)~0)
 For net_store_length() More...
 
#define MYSQL_STMT_HEADER   4
 
#define MYSQL_LONG_DATA_HEADER   6
 

Typedefs

typedef struct NET NET
 

Enumerations

enum  SERVER_STATUS_flags_enum {
  SERVER_STATUS_IN_TRANS = 1 , SERVER_STATUS_AUTOCOMMIT = 2 , SERVER_MORE_RESULTS_EXISTS = 8 , SERVER_QUERY_NO_GOOD_INDEX_USED = 16 ,
  SERVER_QUERY_NO_INDEX_USED = 32 , SERVER_STATUS_CURSOR_EXISTS = 64 , SERVER_STATUS_LAST_ROW_SENT = 128 , SERVER_STATUS_DB_DROPPED = 256 ,
  SERVER_STATUS_NO_BACKSLASH_ESCAPES = 512 , SERVER_STATUS_METADATA_CHANGED = 1024 , SERVER_QUERY_WAS_SLOW = 2048 , SERVER_PS_OUT_PARAMS = 4096 ,
  SERVER_STATUS_IN_TRANS_READONLY = 8192 , SERVER_SESSION_STATE_CHANGED = (1UL << 14)
}
 The status flags are a bit-field. More...
 
enum  mysql_enum_shutdown_level {
  SHUTDOWN_DEFAULT = 0 , SHUTDOWN_WAIT_CONNECTIONS = MYSQL_SHUTDOWN_KILLABLE_CONNECT , SHUTDOWN_WAIT_TRANSACTIONS = MYSQL_SHUTDOWN_KILLABLE_TRANS , SHUTDOWN_WAIT_UPDATES = MYSQL_SHUTDOWN_KILLABLE_UPDATE ,
  SHUTDOWN_WAIT_ALL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) , SHUTDOWN_WAIT_CRITICAL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1 , KILL_QUERY = 254 , KILL_CONNECTION = 255
}
 We want levels to be in growing order of hardness (because we use number comparisons). More...
 
enum  enum_resultset_metadata { RESULTSET_METADATA_NONE = 0 , RESULTSET_METADATA_FULL = 1 }
 
enum  enum_cursor_type {
  CURSOR_TYPE_NO_CURSOR = 0 , CURSOR_TYPE_READ_ONLY = 1 , CURSOR_TYPE_FOR_UPDATE = 2 , CURSOR_TYPE_SCROLLABLE = 4 ,
  PARAMETER_COUNT_AVAILABLE = 8
}
 The flags used in COM_STMT_EXECUTE. More...
 
enum  enum_mysql_set_option { MYSQL_OPTION_MULTI_STATEMENTS_ON , MYSQL_OPTION_MULTI_STATEMENTS_OFF }
 options for mysql_options() More...
 
enum  enum_session_state_type {
  SESSION_TRACK_SYSTEM_VARIABLES , SESSION_TRACK_SCHEMA , SESSION_TRACK_STATE_CHANGE , SESSION_TRACK_GTIDS ,
  SESSION_TRACK_TRANSACTION_CHARACTERISTICS , SESSION_TRACK_TRANSACTION_STATE
}
 Type of state change information that the server can include in the Ok packet. More...
 

Functions

bool my_net_init (struct NET *net, MYSQL_VIO vio)
 
void my_net_local_init (struct NET *net)
 
void net_end (struct NET *net)
 
void net_clear (struct NET *net, bool check_buffer)
 Clear (reinitialize) the NET structure for a new command. More...
 
void net_claim_memory_ownership (struct NET *net, bool claim)
 
bool net_realloc (struct NET *net, size_t length)
 Realloc the packet buffer. More...
 
bool net_flush (struct NET *net)
 Flush write_buffer if not empty. More...
 
bool my_net_write (struct NET *net, const unsigned char *packet, size_t len)
 Write a logical packet with packet header. More...
 
bool net_write_command (struct NET *net, unsigned char command, const unsigned char *header, size_t head_len, const unsigned char *packet, size_t len)
 Send a command to the server. More...
 
bool net_write_packet (struct NET *net, const unsigned char *packet, size_t length)
 Write a MySQL protocol packet to the network handler. More...
 
unsigned long my_net_read (struct NET *net)
 Read a packet from the client/server and return it without the internal package header. More...
 
void my_net_set_write_timeout (struct NET *net, unsigned int timeout)
 
void my_net_set_read_timeout (struct NET *net, unsigned int timeout)
 
void my_net_set_retry_count (struct NET *net, unsigned int retry_count)
 
void randominit (struct rand_struct *, unsigned long seed1, unsigned long seed2)
 
double my_rnd (struct rand_struct *)
 Generate random number. More...
 
void create_random_string (char *to, unsigned int length, struct rand_struct *rand_st)
 
void hash_password (unsigned long *to, const char *password, unsigned int password_len)
 
void make_scrambled_password_323 (char *to, const char *password)
 
void scramble_323 (char *to, const char *message, const char *password)
 
bool check_scramble_323 (const unsigned char *reply, const char *message, unsigned long *salt)
 
void get_salt_from_password_323 (unsigned long *res, const char *password)
 
void make_password_from_salt_323 (char *to, const unsigned long *salt)
 
void make_scrambled_password (char *to, const char *password)
 
void scramble (char *to, const char *message, const char *password)
 Produce an obscure octet sequence from password and random string, received from the server. More...
 
bool check_scramble (const unsigned char *reply, const char *message, const unsigned char *hash_stage2)
 
void get_salt_from_password (unsigned char *res, const char *password)
 
void make_password_from_salt (char *to, const unsigned char *hash_stage2)
 
char * octet2hex (char *to, const char *str, unsigned int len)
 
bool generate_sha256_scramble (unsigned char *dst, size_t dst_size, const char *src, size_t src_size, const char *rnd, size_t rnd_size)
 
char * get_tty_password (const char *opt_message)
 
const char * mysql_errno_to_sqlstate (unsigned int mysql_errno)
 
bool my_thread_init (void)
 Allocate thread specific memory for the thread, used by mysys and dbug. More...
 
void my_thread_end (void)
 Deallocate memory used by the thread for book-keeping. More...
 
uint64_t net_field_length_ll (unsigned char **packet)
 
unsigned char * net_store_length (unsigned char *pkg, unsigned long long length)
 
unsigned int net_length_size (unsigned long long num)
 
unsigned int net_field_length_size (const unsigned char *pos)
 length of buffer required to represent a length-encoded string give the length part of length encoded string. More...
 

Detailed Description

Common definition between mysql server & client.

Macro Definition Documentation

◆ AUTH_PLUGIN_DATA_PART_1_LENGTH

#define AUTH_PLUGIN_DATA_PART_1_LENGTH   8

◆ CAN_CLIENT_COMPRESS

#define CAN_CLIENT_COMPRESS   CLIENT_COMPRESS

a compatibility alias for CLIENT_COMPRESS

◆ CHALLENGE_LENGTH

#define CHALLENGE_LENGTH   32

◆ CLIENT_ALL_FLAGS

#define CLIENT_ALL_FLAGS
Value:
CLIENT_CONNECT_WITH_DB | CLIENT_NO_SCHEMA | CLIENT_COMPRESS | CLIENT_ODBC | \
CLIENT_LOCAL_FILES | CLIENT_IGNORE_SPACE | CLIENT_PROTOCOL_41 | \
CLIENT_INTERACTIVE | CLIENT_SSL | CLIENT_IGNORE_SIGPIPE | \
CLIENT_TRANSACTIONS | CLIENT_RESERVED | CLIENT_RESERVED2 | \
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS | CLIENT_PS_MULTI_RESULTS | \
CLIENT_SSL_VERIFY_SERVER_CERT | CLIENT_REMEMBER_OPTIONS | \
CLIENT_PLUGIN_AUTH | CLIENT_CONNECT_ATTRS | \
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \
CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS | CLIENT_SESSION_TRACK | \
CLIENT_DEPRECATE_EOF | CLIENT_OPTIONAL_RESULTSET_METADATA | \
CLIENT_ZSTD_COMPRESSION_ALGORITHM | CLIENT_QUERY_ATTRIBUTES | \
MULTI_FACTOR_AUTHENTICATION)
#define CLIENT_REMEMBER_OPTIONS
Don't reset the options after an unsuccessful connect.
Definition: mysql_com.h:773
#define CLIENT_MULTI_RESULTS
Enable/disable multi-results.
Definition: mysql_com.h:514
#define CLIENT_QUERY_ATTRIBUTES
Support optional extension for query parameters into the COM_QUERY and COM_STMT_EXECUTE packets.
Definition: mysql_com.h:732
#define CLIENT_FOUND_ROWS
Send found rows instead of affected rows in EOF_Packet.
Definition: mysql_com.h:289
#define CLIENT_LONG_PASSWORD
Use the improved version of Old Password Authentication.
Definition: mysql_com.h:284
#define CLIENT_NO_SCHEMA
DEPRECATED: Don't allow database.table.column.
Definition: mysql_com.h:327
#define CLIENT_CONNECT_ATTRS
Client supports connection attributes.
Definition: mysql_com.h:582
#define CLIENT_IGNORE_SPACE
Ignore spaces before '('.
Definition: mysql_com.h:378
#define CLIENT_COMPRESS
Compression protocol supported.
Definition: mysql_com.h:344
#define CLIENT_PS_MULTI_RESULTS
Multi-results and OUT parameters in PS-protocol.
Definition: mysql_com.h:537
#define CLIENT_ODBC
Special handling of ODBC behavior.
Definition: mysql_com.h:350
#define CLIENT_IGNORE_SIGPIPE
Client only flag.
Definition: mysql_com.h:442
#define CLIENT_RESERVED2
DEPRECATED: Old flag for 4.1 authentication \ CLIENT_SECURE_CONNECTION.
Definition: mysql_com.h:464
#define CLIENT_SSL
Use SSL encryption for the session.
Definition: mysql_com.h:431
#define CLIENT_LONG_FLAG
Get all column flags.
Definition: mysql_com.h:307
#define CLIENT_PROTOCOL_41
New 4.1 protocol.
Definition: mysql_com.h:396
#define CLIENT_RESERVED
DEPRECATED: Old flag for 4.1 protocol
Definition: mysql_com.h:463
#define CLIENT_OPTIONAL_RESULTSET_METADATA
The client can handle optional metadata information in the resultset.
Definition: mysql_com.h:695
#define CLIENT_SESSION_TRACK
Capable of handling server state change information.
Definition: mysql_com.h:656

Gather all possible capabilities (flags) supported by the server.

◆ CLIENT_BASIC_FLAGS

#define CLIENT_BASIC_FLAGS
Value:
CLIENT_ZSTD_COMPRESSION_ALGORITHM))
#define CLIENT_SSL_VERIFY_SERVER_CERT
Verify server certificate.
Definition: mysql_com.h:762
#define CLIENT_ALL_FLAGS
Gather all possible capabilities (flags) supported by the server.
Definition: mysql_com.h:780

Switch off from CLIENT_ALL_FLAGS the flags that are optional and depending on build flags.

If any of the optional flags is supported by the build it will be switched on before sending to the client during the connection handshake.

◆ COLUMN_COMMENT_MAXLEN

#define COLUMN_COMMENT_MAXLEN   1024

◆ CONNECT_STRING_MAXLEN

#define CONNECT_STRING_MAXLEN   1024

◆ FILENAME_CHARSET_MBMAXLEN

#define FILENAME_CHARSET_MBMAXLEN   5

◆ FRM_GCOL_HEADER_SIZE

#define FRM_GCOL_HEADER_SIZE   4

The length of the header part for each generated column in the .frm file.

◆ GENERATED_COLUMN_EXPRESSION_MAXLEN

#define GENERATED_COLUMN_EXPRESSION_MAXLEN   65535 - FRM_GCOL_HEADER_SIZE

Maximum length of the expression statement defined for generated columns.

◆ INDEX_COMMENT_MAXLEN

#define INDEX_COMMENT_MAXLEN   1024

◆ IS_SESSION_STATE_TYPE

#define IS_SESSION_STATE_TYPE (   T)     (((int)(T) >= SESSION_TRACK_BEGIN) && ((T) <= SESSION_TRACK_END))

is T a valid session state type

◆ LOCAL_HOST

#define LOCAL_HOST   "localhost"

◆ LOCAL_HOST_NAMEDPIPE

#define LOCAL_HOST_NAMEDPIPE   "."

◆ MAX_AUTH_FACTORS

#define MAX_AUTH_FACTORS   3

◆ MAX_BIGINT_WIDTH

#define MAX_BIGINT_WIDTH   20

Max width for a LONGLONG.

◆ MAX_BLOB_WIDTH

#define MAX_BLOB_WIDTH   16777216

Default width for blob in bytes.

◆ MAX_CHAR_WIDTH

#define MAX_CHAR_WIDTH   255

Max width for a CHAR column, in number of characters.

◆ MAX_INT_WIDTH

#define MAX_INT_WIDTH   10

Max width for a LONG w.o.

sign

◆ MAX_MEDIUMINT_WIDTH

#define MAX_MEDIUMINT_WIDTH   8

Max width for a INT24 w.o.

sign

◆ MAX_PACKET_LENGTH

#define MAX_PACKET_LENGTH   (256L * 256L * 256L - 1)

Maximum length of protocol packet.

OK_Packet length limit also restricted to this value as any length greater than this value will have first byte of OK_Packet to be 254 thus does not provide a means to identify if this is OK_Packet or EOF_Packet.

◆ MAX_SMALLINT_WIDTH

#define MAX_SMALLINT_WIDTH   5

Max width for a SHORT w.o.

sign

◆ MAX_TINYINT_WIDTH

#define MAX_TINYINT_WIDTH   3

Max width for a TINY w.o.

sign

◆ MYSQL_AUTODETECT_CHARSET_NAME

#define MYSQL_AUTODETECT_CHARSET_NAME   "auto"

◆ MYSQL_ERRMSG_SIZE

#define MYSQL_ERRMSG_SIZE   512

Max length of a error message.

Should be kept in sync with ERRMSGSIZE.

◆ MYSQL_LONG_DATA_HEADER

#define MYSQL_LONG_DATA_HEADER   6

◆ MYSQL_STMT_HEADER

#define MYSQL_STMT_HEADER   4

◆ MYSQL_VIO

#define MYSQL_VIO   struct Vio *

◆ NAME_CHAR_LEN

#define NAME_CHAR_LEN   64

Field/table name length.

◆ NAME_LEN

#define NAME_LEN   (NAME_CHAR_LEN * SYSTEM_CHARSET_MBMAXLEN)

◆ NET_ERROR_SOCKET_NOT_READABLE

#define NET_ERROR_SOCKET_NOT_READABLE   3

Try write and close socket.

◆ NET_ERROR_SOCKET_NOT_WRITABLE

#define NET_ERROR_SOCKET_NOT_WRITABLE   4

Try read and close socket.

◆ NET_ERROR_SOCKET_RECOVERABLE

#define NET_ERROR_SOCKET_RECOVERABLE   1

Socket still usable.

◆ NET_ERROR_SOCKET_UNUSABLE

#define NET_ERROR_SOCKET_UNUSABLE   2

Do not use the socket.

◆ NET_ERROR_UNSET

#define NET_ERROR_UNSET   0

No error has occurred yet.

◆ net_new_transaction

#define net_new_transaction (   net)    ((net)->pkt_nr = 0)

◆ NET_READ_TIMEOUT

#define NET_READ_TIMEOUT   30

Timeout on read.

◆ NET_WAIT_TIMEOUT

#define NET_WAIT_TIMEOUT   8 * 60 * 60

Wait for new query.

◆ NET_WRITE_TIMEOUT

#define NET_WRITE_TIMEOUT   60

Timeout on write.

◆ NULL_LENGTH

#define NULL_LENGTH   ((unsigned long)~0)

For net_store_length()

◆ ONLY_KILL_QUERY

#define ONLY_KILL_QUERY   1

Flag used by the parser.

Kill only the query and not the connection.

See also
SQLCOM_KILL, sql_kill(), LEX::type

◆ packet_error

#define packet_error   (~(unsigned long)0)

◆ PARTITION_EXPR_CHAR_LEN

#define PARTITION_EXPR_CHAR_LEN    2048

Maximum expression length in chars .

◆ RELYING_PARTY_ID_LENGTH

#define RELYING_PARTY_ID_LENGTH   255

◆ SCRAMBLE_LENGTH

#define SCRAMBLE_LENGTH   20

Length of random string sent by server on handshake; this is also length of obfuscated password, received from client.

◆ SCRAMBLED_PASSWORD_CHAR_LENGTH

#define SCRAMBLED_PASSWORD_CHAR_LENGTH   (SCRAMBLE_LENGTH * 2 + 1)

length of password stored in the db: new passwords are preceded with '*'

◆ SERVER_STATUS_CLEAR_SET

#define SERVER_STATUS_CLEAR_SET
Value:
SERVER_MORE_RESULTS_EXISTS | SERVER_STATUS_METADATA_CHANGED | \
SERVER_QUERY_WAS_SLOW | SERVER_STATUS_DB_DROPPED | \
SERVER_STATUS_CURSOR_EXISTS | SERVER_STATUS_LAST_ROW_SENT | \
SERVER_SESSION_STATE_CHANGED)
@ SERVER_STATUS_LAST_ROW_SENT
This flag is sent when a read-only cursor is exhausted, in reply to COM_STMT_FETCH command.
Definition: mysql_com.h:833
@ SERVER_STATUS_DB_DROPPED
A database was dropped.
Definition: mysql_com.h:834
@ SERVER_QUERY_NO_GOOD_INDEX_USED
Definition: mysql_com.h:818
@ SERVER_QUERY_NO_INDEX_USED
Definition: mysql_com.h:819
@ SERVER_STATUS_METADATA_CHANGED
Sent to the client if after a prepared statement reprepare we discovered that the new statement retur...
Definition: mysql_com.h:841

Server status flags that must be cleared when starting execution of a new SQL statement.

Flags from this set are only added to the current server status by the execution engine, but never removed – the execution engine expects them to disappear automagically by the next command.

◆ SERVER_VERSION_LENGTH

#define SERVER_VERSION_LENGTH   60

◆ SESSION_TRACK_BEGIN

#define SESSION_TRACK_BEGIN   SESSION_TRACK_SYSTEM_VARIABLES

start of enum_session_state_type

◆ SESSION_TRACK_END

#define SESSION_TRACK_END   SESSION_TRACK_TRANSACTION_STATE

End of enum_session_state_type.

◆ SQLSTATE_LENGTH

#define SQLSTATE_LENGTH   5

◆ SYSTEM_CHARSET_MBMAXLEN

#define SYSTEM_CHARSET_MBMAXLEN   3

◆ TABLE_COMMENT_INLINE_MAXLEN

#define TABLE_COMMENT_INLINE_MAXLEN   180

Maximum length of comments.

pre 5.6: 60 characters

◆ TABLE_COMMENT_MAXLEN

#define TABLE_COMMENT_MAXLEN   2048

◆ TABLE_PARTITION_COMMENT_MAXLEN

#define TABLE_PARTITION_COMMENT_MAXLEN   1024

◆ TABLESPACE_COMMENT_MAXLEN

#define TABLESPACE_COMMENT_MAXLEN   2048

◆ USERNAME_CHAR_LENGTH

#define USERNAME_CHAR_LENGTH   32

◆ USERNAME_CHAR_LENGTH_STR

#define USERNAME_CHAR_LENGTH_STR   "32"

◆ USERNAME_LENGTH

#define USERNAME_LENGTH   (USERNAME_CHAR_LENGTH * SYSTEM_CHARSET_MBMAXLEN)

Typedef Documentation

◆ NET

typedef struct NET NET

Enumeration Type Documentation

◆ enum_cursor_type

The flags used in COM_STMT_EXECUTE.

See also
Protocol_classic::parse_packet, mysql_int_serialize_param_data
Enumerator
CURSOR_TYPE_NO_CURSOR 
CURSOR_TYPE_READ_ONLY 
CURSOR_TYPE_FOR_UPDATE 
CURSOR_TYPE_SCROLLABLE 
PARAMETER_COUNT_AVAILABLE 

On when the client will send the parameter count even for 0 parameters.

◆ enum_mysql_set_option

options for mysql_options()

Enumerator
MYSQL_OPTION_MULTI_STATEMENTS_ON 
MYSQL_OPTION_MULTI_STATEMENTS_OFF 

◆ enum_resultset_metadata

Enumerator
RESULTSET_METADATA_NONE 

No metadata will be sent.

RESULTSET_METADATA_FULL 

The server will send all metadata.

◆ enum_session_state_type

Type of state change information that the server can include in the Ok packet.

Note
  • session_state_type shouldn't go past 255 (i.e. 1-byte boundary).
  • Modify the definition of SESSION_TRACK_END when a new member is added.
Enumerator
SESSION_TRACK_SYSTEM_VARIABLES 

Session system variables.

SESSION_TRACK_SCHEMA 

Current schema.

SESSION_TRACK_STATE_CHANGE 

track session state changes

SESSION_TRACK_GTIDS 

See also: session_track_gtids.

SESSION_TRACK_TRANSACTION_CHARACTERISTICS 

Transaction chistics.

SESSION_TRACK_TRANSACTION_STATE 

Transaction state.

◆ SERVER_STATUS_flags_enum

The status flags are a bit-field.

Enumerator
SERVER_STATUS_IN_TRANS 

Is raised when a multi-statement transaction has been started, either explicitly, by means of BEGIN or COMMIT AND CHAIN, or implicitly, by the first transactional statement, when autocommit=off.

SERVER_STATUS_AUTOCOMMIT 

Server in auto_commit mode.

SERVER_MORE_RESULTS_EXISTS 

Multi query - next query exists.

SERVER_QUERY_NO_GOOD_INDEX_USED 
SERVER_QUERY_NO_INDEX_USED 
SERVER_STATUS_CURSOR_EXISTS 

The server was able to fulfill the clients request and opened a read-only non-scrollable cursor for a query.

This flag comes in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. Used by Binary Protocol Resultset to signal that COM_STMT_FETCH must be used to fetch the row-data.

SERVER_STATUS_LAST_ROW_SENT 

This flag is sent when a read-only cursor is exhausted, in reply to COM_STMT_FETCH command.

SERVER_STATUS_DB_DROPPED 

A database was dropped.

SERVER_STATUS_NO_BACKSLASH_ESCAPES 
SERVER_STATUS_METADATA_CHANGED 

Sent to the client if after a prepared statement reprepare we discovered that the new statement returns a different number of result set columns.

SERVER_QUERY_WAS_SLOW 
SERVER_PS_OUT_PARAMS 

To mark ResultSet containing output parameter values.

SERVER_STATUS_IN_TRANS_READONLY 

Set at the same time as SERVER_STATUS_IN_TRANS if the started multi-statement transaction is a read-only transaction.

Cleared when the transaction commits or aborts. Since this flag is sent to clients in OK and EOF packets, the flag indicates the transaction status at the end of command execution.

SERVER_SESSION_STATE_CHANGED 

This status flag, when on, implies that one of the state information has changed on the server because of the execution of the last statement.

Function Documentation

◆ check_scramble()

bool check_scramble ( const unsigned char *  reply,
const char *  message,
const unsigned char *  hash_stage2 
)

◆ check_scramble_323()

bool check_scramble_323 ( const unsigned char *  reply,
const char *  message,
unsigned long *  salt 
)

◆ create_random_string()

void create_random_string ( char *  to,
unsigned int  length,
struct rand_struct rand_st 
)

◆ generate_sha256_scramble()

bool generate_sha256_scramble ( unsigned char *  dst,
size_t  dst_size,
const char *  src,
size_t  src_size,
const char *  rnd,
size_t  rnd_size 
)

◆ get_salt_from_password()

void get_salt_from_password ( unsigned char *  res,
const char *  password 
)

◆ get_salt_from_password_323()

void get_salt_from_password_323 ( unsigned long *  res,
const char *  password 
)

◆ get_tty_password()

char * get_tty_password ( const char *  opt_message)

◆ hash_password()

void hash_password ( unsigned long *  to,
const char *  password,
unsigned int  password_len 
)

◆ make_password_from_salt()

void make_password_from_salt ( char *  to,
const unsigned char *  hash_stage2 
)

◆ make_password_from_salt_323()

void make_password_from_salt_323 ( char *  to,
const unsigned long *  salt 
)

◆ make_scrambled_password()

void make_scrambled_password ( char *  to,
const char *  password 
)

◆ make_scrambled_password_323()

void make_scrambled_password_323 ( char *  to,
const char *  password 
)

◆ my_net_init()

bool my_net_init ( struct NET net,
MYSQL_VIO  vio 
)

◆ my_net_local_init()

void my_net_local_init ( struct NET net)

◆ my_net_read()

unsigned long my_net_read ( NET net)

Read a packet from the client/server and return it without the internal package header.

If the packet is the first packet of a multi-packet packet (which is indicated by the length of the packet = 0xffffff) then all sub packets are read and concatenated.

If the packet was compressed, its uncompressed and the length of the uncompressed packet is returned.

Returns
The function returns the length of the found packet or packet_error. net->read_pos points to the read data.

◆ my_net_set_read_timeout()

void my_net_set_read_timeout ( struct NET net,
unsigned int  timeout 
)

◆ my_net_set_retry_count()

void my_net_set_retry_count ( struct NET net,
unsigned int  retry_count 
)

◆ my_net_set_write_timeout()

void my_net_set_write_timeout ( struct NET net,
unsigned int  timeout 
)

◆ my_net_write()

bool my_net_write ( NET net,
const uchar packet,
size_t  len 
)

Write a logical packet with packet header.

Format: Packet length (3 bytes), packet number (1 byte) When compression is used, a 3 byte compression length is added.

Note
If compression is used, the original packet is modified!

◆ my_rnd()

double my_rnd ( struct rand_struct rand_st)

Generate random number.

Parameters
[in,out]rand_stStructure used for number generation.
Return values
Generatedpseudo random number.

◆ my_thread_end()

void my_thread_end ( void  )

Deallocate memory used by the thread for book-keeping.

Note
This may be called multiple times for a thread. This happens for example when one calls 'mysql_server_init()' mysql_server_end() and then ends with a mysql_end().

◆ my_thread_init()

bool my_thread_init ( void  )

Allocate thread specific memory for the thread, used by mysys and dbug.

Note
This function may called multiple times for a thread, for example if one uses my_init() followed by mysql_server_init().
Return values
falseok
trueFatal error; mysys/dbug functions can't be used

◆ mysql_errno_to_sqlstate()

const char * mysql_errno_to_sqlstate ( unsigned int  mysql_errno)

◆ net_claim_memory_ownership()

void net_claim_memory_ownership ( struct NET net,
bool  claim 
)

◆ net_clear()

void net_clear ( NET net,
bool  check_buffer 
)

Clear (reinitialize) the NET structure for a new command.

Remarks
Performs debug checking of the socket buffer to ensure that the protocol sequence is correct.
Parameters
netNET handler
check_bufferWhether to check the socket buffer.

◆ net_end()

void net_end ( struct NET net)

◆ net_field_length_ll()

uint64_t net_field_length_ll ( unsigned char **  packet)
inline

◆ net_field_length_size()

unsigned int net_field_length_size ( const uchar pos)

length of buffer required to represent a length-encoded string give the length part of length encoded string.

This function can be used before calling net_field_lenth/net_field_length_ll.

Parameters
[in]posLength information of length-encoded string
Returns
length of buffer needed to store this number [1, 3, 4, 9].

◆ net_flush()

bool net_flush ( struct NET net)

Flush write_buffer if not empty.

◆ net_length_size()

unsigned int net_length_size ( unsigned long long  num)

◆ net_realloc()

bool net_realloc ( struct NET net,
size_t  length 
)

Realloc the packet buffer.

◆ net_store_length()

unsigned char * net_store_length ( unsigned char *  pkg,
unsigned long long  length 
)

◆ net_write_command()

bool net_write_command ( NET net,
uchar  command,
const uchar header,
size_t  head_len,
const uchar packet,
size_t  len 
)

Send a command to the server.

The reason for having both header and packet is so that libmysql can easy add a header to a special command (like prepared statements) without having to re-alloc the string.

As the command is part of the first data packet, we have to do some data juggling to put the command in there, without having to create a new packet.

This function will split big packets into sub-packets if needed. (Each sub packet can only be 2^24 bytes)

Parameters
netNET handler
commandCommand in MySQL server (enum enum_server_command)
headerHeader to write after command
head_lenLength of header
packetQuery or parameter to query
lenLength of packet
Return values
0ok
1error

◆ net_write_packet()

bool net_write_packet ( NET net,
const uchar packet,
size_t  length 
)

Write a MySQL protocol packet to the network handler.

Parameters
netNET handler.
packetThe packet to write.
lengthLength of the packet.
Remarks
The packet might be encapsulated into a compressed packet.
Returns
true on error, false on success.

◆ octet2hex()

char * octet2hex ( char *  to,
const char *  str,
unsigned int  len 
)

◆ randominit()

void randominit ( struct rand_struct ,
unsigned long  seed1,
unsigned long  seed2 
)

◆ scramble()

void scramble ( char *  to,
const char *  message,
const char *  password 
)

Produce an obscure octet sequence from password and random string, received from the server.

This sequence corresponds to the password, but password can not be easily restored from it. The sequence is then sent to the server for validation. Trailing zero is not stored in the buf as it is not needed. This function is used by client to create authenticated reply to the server's greeting.

Parameters
[out]tostore scrambled string here. The buf must be at least SHA1_HASH_SIZE bytes long.
messagerandom message, must be exactly SCRAMBLE_LENGTH long and NULL-terminated.
passwordusers' password, NULL-terminated

◆ scramble_323()

void scramble_323 ( char *  to,
const char *  message,
const char *  password 
)