MySQL 8.3.0
Source Code Documentation
mysql_async.h File Reference

Declarations for asynchronous client communication. More...

#include <mysql.h>

Go to the source code of this file.

Classes

struct  io_vec
 Represents the packet to be sent on wire asynchronously. More...
 
struct  NET_ASYNC
 
struct  NET_EXTENSION
 
struct  MYSQL_ASYNC
 

Macros

#define NET_EXTENSION_PTR(N)    ((NET_EXTENSION *)((N)->extension ? (N)->extension : NULL))
 
#define NET_ASYNC_DATA(M)    ((NET_EXTENSION_PTR(M)) ? (NET_EXTENSION_PTR(M)->net_async_context) : NULL)
 

Typedefs

typedef struct NET_ASYNC NET_ASYNC
 
typedef struct MYSQL_ASYNC MYSQL_ASYNC
 

Enumerations

enum  net_async_operation { NET_ASYNC_OP_IDLE = 0 , NET_ASYNC_OP_READING , NET_ASYNC_OP_WRITING , NET_ASYNC_OP_COMPLETE }
 This enum is to represent different asynchronous operations like reading the network, writing to network, idle state, or complete state. More...
 
enum  net_async_read_packet_state { NET_ASYNC_PACKET_READ_IDLE = 0 , NET_ASYNC_PACKET_READ_HEADER , NET_ASYNC_PACKET_READ_BODY , NET_ASYNC_PACKET_READ_COMPLETE }
 Reading a packet is a multi-step process, so we have a state machine. More...
 
enum  net_read_query_result_status { NET_ASYNC_READ_QUERY_RESULT_IDLE = 0 , NET_ASYNC_READ_QUERY_RESULT_FIELD_COUNT , NET_ASYNC_READ_QUERY_RESULT_FIELD_INFO }
 Different states when reading a query result. More...
 
enum  net_send_command_status { NET_ASYNC_SEND_COMMAND_IDLE = 0 , NET_ASYNC_SEND_COMMAND_WRITE_COMMAND , NET_ASYNC_SEND_COMMAND_READ_STATUS }
 Sending a command involves the write as well as reading the status. More...
 
enum  net_async_block_state { NET_NONBLOCKING_CONNECT = 0 , NET_NONBLOCKING_READ , NET_NONBLOCKING_WRITE }
 Async operations are broadly classified into 3 phases: Connection phase, phase of sending data to server (which is writing phase) and reading data from server (which is reading phase). More...
 
enum  mysql_async_operation_status { ASYNC_OP_UNSET = 0 , ASYNC_OP_CONNECT , ASYNC_OP_QUERY }
 Asynchronous operations are broadly classified into 2 categories. More...
 
enum  mysql_async_query_state_enum { QUERY_IDLE = 0 , QUERY_SENDING , QUERY_READING_RESULT }
 Query execution in an asynchronous fashion is broadly divided into 3 states which is described in below enum. More...
 

Functions

NET_EXTENSIONnet_extension_init ()
 
void net_extension_free (NET *)
 
enum net_async_status my_net_write_nonblocking (NET *net, const unsigned char *packet, size_t len, bool *res)
 
enum net_async_status net_write_command_nonblocking (NET *net, unsigned char command, const unsigned char *prefix, size_t prefix_len, const unsigned char *packet, size_t packet_len, bool *res)
 Send a command to the server in asynchronous way. More...
 
enum net_async_status my_net_read_nonblocking (NET *net, unsigned long *len_ptr)
 
int mysql_get_socket_descriptor (MYSQL *mysql)
 

Detailed Description

Declarations for asynchronous client communication.

Note
this file should not be included as part of packaging.

Macro Definition Documentation

◆ NET_ASYNC_DATA

#define NET_ASYNC_DATA (   M)     ((NET_EXTENSION_PTR(M)) ? (NET_EXTENSION_PTR(M)->net_async_context) : NULL)

◆ NET_EXTENSION_PTR

#define NET_EXTENSION_PTR (   N)     ((NET_EXTENSION *)((N)->extension ? (N)->extension : NULL))

Typedef Documentation

◆ MYSQL_ASYNC

typedef struct MYSQL_ASYNC MYSQL_ASYNC

◆ NET_ASYNC

typedef struct NET_ASYNC NET_ASYNC

Enumeration Type Documentation

◆ mysql_async_operation_status

Asynchronous operations are broadly classified into 2 categories.

  1. Connection
  2. Query execution This classification is defined in below enum
Enumerator
ASYNC_OP_UNSET 
ASYNC_OP_CONNECT 
ASYNC_OP_QUERY 

◆ mysql_async_query_state_enum

Query execution in an asynchronous fashion is broadly divided into 3 states which is described in below enum.

Enumerator
QUERY_IDLE 
QUERY_SENDING 
QUERY_READING_RESULT 

◆ net_async_block_state

Async operations are broadly classified into 3 phases: Connection phase, phase of sending data to server (which is writing phase) and reading data from server (which is reading phase).

Below enum describes the same

Enumerator
NET_NONBLOCKING_CONNECT 
NET_NONBLOCKING_READ 
NET_NONBLOCKING_WRITE 

◆ net_async_operation

This enum is to represent different asynchronous operations like reading the network, writing to network, idle state, or complete state.

Enumerator
NET_ASYNC_OP_IDLE 

default state

NET_ASYNC_OP_READING 

used by my_net_read calls

NET_ASYNC_OP_WRITING 

used by my_net_write calls

NET_ASYNC_OP_COMPLETE 

network read or write is complete

◆ net_async_read_packet_state

Reading a packet is a multi-step process, so we have a state machine.

Enumerator
NET_ASYNC_PACKET_READ_IDLE 

default packet read state

NET_ASYNC_PACKET_READ_HEADER 

read packet header

NET_ASYNC_PACKET_READ_BODY 

read packet contents

NET_ASYNC_PACKET_READ_COMPLETE 

state to define if packet is completely read

◆ net_read_query_result_status

Different states when reading a query result.

Enumerator
NET_ASYNC_READ_QUERY_RESULT_IDLE 

default state

NET_ASYNC_READ_QUERY_RESULT_FIELD_COUNT 

read Ok or read field count sent as part of COM_QUERY

NET_ASYNC_READ_QUERY_RESULT_FIELD_INFO 

read result of above COM_* command

◆ net_send_command_status

Sending a command involves the write as well as reading the status.

Enumerator
NET_ASYNC_SEND_COMMAND_IDLE 

default send command state

NET_ASYNC_SEND_COMMAND_WRITE_COMMAND 

send COM_* command

NET_ASYNC_SEND_COMMAND_READ_STATUS 

read result of above COM_* command

Function Documentation

◆ my_net_read_nonblocking()

enum net_async_status my_net_read_nonblocking ( NET net,
unsigned long *  len_ptr 
)

◆ my_net_write_nonblocking()

enum net_async_status my_net_write_nonblocking ( NET net,
const unsigned char *  packet,
size_t  len,
bool *  res 
)

◆ mysql_get_socket_descriptor()

int mysql_get_socket_descriptor ( MYSQL mysql)

◆ net_extension_free()

void net_extension_free ( NET net)

◆ net_extension_init()

NET_EXTENSION * net_extension_init ( )

◆ net_write_command_nonblocking()

enum net_async_status net_write_command_nonblocking ( NET net,
uchar  command,
const uchar prefix,
size_t  prefix_len,
const uchar packet,
size_t  packet_len,
bool *  res 
)

Send a command to the server in asynchronous way.

This function will first populate all headers in NET::async_write_headers, followed by payload in NET::async_write_vector. Once header and payload is populated in NET, were call net_write_vector_nonblocking to send the packets to server in an asynchronous way.