MySQL 5.6.14 Source Code Document
|
#include <my_global.h>
#include <mysql.h>
#include <mysql_com.h>
#include <mysqld_error.h>
#include <my_sys.h>
#include <m_string.h>
#include <my_net.h>
#include <violite.h>
#include <signal.h>
#include <errno.h>
#include "probes_mysql.h"
#include <algorithm>
Go to the source code of this file.
Macros | |
#define | update_statistics(A) |
#define | thd_increment_bytes_sent(N) |
#define | VIO_SOCKET_ERROR ((size_t) -1) |
#define | MAX_PACKET_LENGTH (256L*256L*256L-1) |
Functions | |
my_bool | my_net_init (NET *net, Vio *vio) |
void | net_end (NET *net) |
my_bool | net_realloc (NET *net, size_t length) |
void | net_clear (NET *net, my_bool check_buffer __attribute__((unused))) |
my_bool | net_flush (NET *net) |
my_bool | my_net_write (NET *net, const uchar *packet, size_t len) |
my_bool | net_write_command (NET *net, uchar command, const uchar *header, size_t head_len, const uchar *packet, size_t len) |
my_bool | net_write_packet (NET *net, const uchar *packet, size_t length) |
ulong | my_net_read (NET *net) |
void | my_net_set_read_timeout (NET *net, uint timeout) |
void | my_net_set_write_timeout (NET *net, uint timeout) |
This file is the net layer API for the MySQL client/server protocol.
Write and read of logical packets to/from socket.
Writes are cached into net_buffer_length big packets. Read packets are reallocated dynamicly when reading big packets. Each logical packet has the following pre-info: 3 byte length & 1 byte package-number.
This file needs to be written in C as it's used by the libmysql client as a C file.
Definition in file net_serv.cc.
Init with packet info.
Definition at line 98 of file net_serv.cc.
ulong 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.
Definition at line 878 of file net_serv.cc.
my_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.
Definition at line 279 of file net_serv.cc.
void net_clear | ( | NET * | net, |
my_bool check_buffer | __attribute__(unused) | ||
) |
Clear (reinitialize) the NET structure for a new command.
net | NET handler |
check_buffer | Whether to check the socket buffer. |
Definition at line 193 of file net_serv.cc.
my_bool net_flush | ( | NET * | net | ) |
Flush write_buffer if not empty.
Definition at line 213 of file net_serv.cc.
my_bool net_realloc | ( | NET * | net, |
size_t | length | ||
) |
Realloc the packet buffer.
Definition at line 141 of file net_serv.cc.
my_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)
net | NET handler |
command | Command in MySQL server (enum enum_server_command) |
header | Header to write after command |
head_len | Length of header |
packet | Query or parameter to query |
len | Length of packet |
0 | ok |
1 | error |
Definition at line 353 of file net_serv.cc.
my_bool net_write_packet | ( | NET * | net, |
const uchar * | packet, | ||
size_t | length | ||
) |
Write a MySQL protocol packet to the network handler.
net | NET handler. |
packet | The packet to write. |
length | Length of the packet. |
Definition at line 596 of file net_serv.cc.