Uncrustify maxscale
See script directory for method. The script to run in the top level MaxScale directory is called maxscale-uncrustify.sh, which uses another script, list-src, from the same directory (so you need to set your PATH). The uncrustify version was 0.66.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include <maxscale/protocol/mysql.h>
|
||||
|
||||
/** A DCB-like client abstraction which ignores responses */
|
||||
class LocalClient: public MXB_POLL_DATA
|
||||
class LocalClient : public MXB_POLL_DATA
|
||||
{
|
||||
LocalClient(const LocalClient&);
|
||||
LocalClient& operator=(const LocalClient&);
|
||||
@ -61,19 +61,19 @@ private:
|
||||
static LocalClient* create(MYSQL_session* session, MySQLProtocol* proto, const char* ip, uint64_t port);
|
||||
LocalClient(MYSQL_session* session, MySQLProtocol* proto, int fd);
|
||||
static uint32_t poll_handler(MXB_POLL_DATA* data, MXB_WORKER* worker, uint32_t events);
|
||||
void process(uint32_t events);
|
||||
GWBUF* read_complete_packet();
|
||||
void drain_queue();
|
||||
void error();
|
||||
void close();
|
||||
void process(uint32_t events);
|
||||
GWBUF* read_complete_packet();
|
||||
void drain_queue();
|
||||
void error();
|
||||
void close();
|
||||
|
||||
/** Client states */
|
||||
enum vc_state
|
||||
{
|
||||
VC_WAITING_HANDSHAKE, // Initial state
|
||||
VC_RESPONSE_SENT, // Handshake received and response sent
|
||||
VC_OK, // Authentication is complete, ready for queries
|
||||
VC_ERROR // Something went wrong
|
||||
VC_WAITING_HANDSHAKE, // Initial state
|
||||
VC_RESPONSE_SENT, // Handshake received and response sent
|
||||
VC_OK, // Authentication is complete, ready for queries
|
||||
VC_ERROR // Something went wrong
|
||||
};
|
||||
|
||||
vc_state m_state;
|
||||
|
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
|
||||
@ -43,10 +43,10 @@
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
#define MYSQL_HEADER_LEN 4
|
||||
#define MYSQL_CHECKSUM_LEN 4
|
||||
#define MYSQL_EOF_PACKET_LEN 9
|
||||
#define MYSQL_OK_PACKET_MIN_LEN 11
|
||||
#define MYSQL_HEADER_LEN 4
|
||||
#define MYSQL_CHECKSUM_LEN 4
|
||||
#define MYSQL_EOF_PACKET_LEN 9
|
||||
#define MYSQL_OK_PACKET_MIN_LEN 11
|
||||
#define MYSQL_ERR_PACKET_MIN_LEN 9
|
||||
|
||||
/**
|
||||
@ -58,14 +58,14 @@ MXS_BEGIN_DECLS
|
||||
#define MYSQL_CHARSET_OFFSET 12
|
||||
#define MYSQL_CLIENT_CAP_OFFSET 4
|
||||
#define MYSQL_CLIENT_CAP_SIZE 4
|
||||
#define MARIADB_CAP_OFFSET MYSQL_CHARSET_OFFSET + 19
|
||||
#define MARIADB_CAP_OFFSET MYSQL_CHARSET_OFFSET + 19
|
||||
|
||||
#define GW_MYSQL_PROTOCOL_VERSION 10 // version is 10
|
||||
#define GW_MYSQL_PROTOCOL_VERSION 10 // version is 10
|
||||
#define GW_MYSQL_HANDSHAKE_FILLER 0x00
|
||||
#define GW_MYSQL_SERVER_LANGUAGE 0x08
|
||||
#define GW_MYSQL_MAX_PACKET_LEN 0xffffffL
|
||||
#define GW_MYSQL_SCRAMBLE_SIZE 20
|
||||
#define GW_SCRAMBLE_LENGTH_323 8
|
||||
#define GW_MYSQL_SERVER_LANGUAGE 0x08
|
||||
#define GW_MYSQL_MAX_PACKET_LEN 0xffffffL
|
||||
#define GW_MYSQL_SCRAMBLE_SIZE 20
|
||||
#define GW_SCRAMBLE_LENGTH_323 8
|
||||
|
||||
/**
|
||||
* Prepared statement payload response offsets for a COM_STMT_PREPARE response:
|
||||
@ -106,23 +106,23 @@ MXS_BEGIN_DECLS
|
||||
#define MYSQL_DATABASE_MAXLEN 128
|
||||
#define MYSQL_TABLE_MAXLEN 64
|
||||
|
||||
#define GW_NOINTR_CALL(A) do { errno = 0; A; } while (errno == EINTR)
|
||||
#define COM_QUIT_PACKET_SIZE (4+1)
|
||||
#define GW_NOINTR_CALL(A) do {errno = 0; A;} while (errno == EINTR)
|
||||
#define COM_QUIT_PACKET_SIZE (4 + 1)
|
||||
struct dcb;
|
||||
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
TX_EMPTY = 0, ///< "none of the below"
|
||||
TX_EXPLICIT = 1, ///< an explicit transaction is active
|
||||
TX_IMPLICIT = 2, ///< an implicit transaction is active
|
||||
TX_READ_TRX = 4, ///< transactional reads were done
|
||||
TX_READ_UNSAFE = 8, ///< non-transaction reads were done
|
||||
TX_WRITE_TRX = 16, ///< transactional writes were done
|
||||
TX_WRITE_UNSAFE = 32, ///< non-transactional writes were done
|
||||
TX_STMT_UNSAFE = 64, ///< "unsafe" (non-deterministic like UUID()) stmts
|
||||
TX_RESULT_SET = 128, ///< result-set was sent
|
||||
TX_WITH_SNAPSHOT= 256, ///< WITH CONSISTENT SNAPSHOT was used
|
||||
TX_LOCKED_TABLES= 512 ///< LOCK TABLES is active
|
||||
TX_EMPTY = 0, ///< "none of the below"
|
||||
TX_EXPLICIT = 1, ///< an explicit transaction is active
|
||||
TX_IMPLICIT = 2, ///< an implicit transaction is active
|
||||
TX_READ_TRX = 4, ///< transactional reads were done
|
||||
TX_READ_UNSAFE = 8, ///< non-transaction reads were done
|
||||
TX_WRITE_TRX = 16, ///< transactional writes were done
|
||||
TX_WRITE_UNSAFE = 32, ///< non-transactional writes were done
|
||||
TX_STMT_UNSAFE = 64, ///< "unsafe" (non-deterministic like UUID()) stmts
|
||||
TX_RESULT_SET = 128, ///< result-set was sent
|
||||
TX_WITH_SNAPSHOT = 256, ///< WITH CONSISTENT SNAPSHOT was used
|
||||
TX_LOCKED_TABLES = 512 ///< LOCK TABLES is active
|
||||
} mysql_tx_state_t;
|
||||
|
||||
typedef enum
|
||||
@ -139,114 +139,117 @@ typedef enum
|
||||
*/
|
||||
typedef struct mysql_session
|
||||
{
|
||||
uint8_t client_sha1[MYSQL_SCRAMBLE_LEN]; /*< SHA1(password) */
|
||||
char user[MYSQL_USER_MAXLEN + 1]; /*< username */
|
||||
char db[MYSQL_DATABASE_MAXLEN + 1]; /*< database */
|
||||
int auth_token_len; /*< token length */
|
||||
uint8_t *auth_token; /*< token */
|
||||
uint8_t client_sha1[MYSQL_SCRAMBLE_LEN]; /*< SHA1(password) */
|
||||
char user[MYSQL_USER_MAXLEN + 1]; /*< username */
|
||||
char db[MYSQL_DATABASE_MAXLEN + 1]; /*< database */
|
||||
int auth_token_len; /*< token length */
|
||||
uint8_t* auth_token; /*< token */
|
||||
} MYSQL_session;
|
||||
|
||||
/** Protocol packing macros. */
|
||||
#define gw_mysql_set_byte2(__buffer, __int) do { \
|
||||
(__buffer)[0]= (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); } while (0)
|
||||
#define gw_mysql_set_byte3(__buffer, __int) do { \
|
||||
(__buffer)[0]= (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
|
||||
(__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); } while (0)
|
||||
#define gw_mysql_set_byte4(__buffer, __int) do { \
|
||||
(__buffer)[0]= (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
|
||||
(__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
|
||||
(__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); } while (0)
|
||||
#define gw_mysql_set_byte2(__buffer, __int) \
|
||||
do { \
|
||||
(__buffer)[0] = (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1] = (uint8_t)(((__int) >> 8) & 0xFF);} while (0)
|
||||
#define gw_mysql_set_byte3(__buffer, __int) \
|
||||
do { \
|
||||
(__buffer)[0] = (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1] = (uint8_t)(((__int) >> 8) & 0xFF); \
|
||||
(__buffer)[2] = (uint8_t)(((__int) >> 16) & 0xFF);} while (0)
|
||||
#define gw_mysql_set_byte4(__buffer, __int) \
|
||||
do { \
|
||||
(__buffer)[0] = (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1] = (uint8_t)(((__int) >> 8) & 0xFF); \
|
||||
(__buffer)[2] = (uint8_t)(((__int) >> 16) & 0xFF); \
|
||||
(__buffer)[3] = (uint8_t)(((__int) >> 24) & 0xFF);} while (0)
|
||||
|
||||
/** Protocol unpacking macros. */
|
||||
#define gw_mysql_get_byte2(__buffer) \
|
||||
(uint16_t)((__buffer)[0] | \
|
||||
((__buffer)[1] << 8))
|
||||
(uint16_t)((__buffer)[0] \
|
||||
| ((__buffer)[1] << 8))
|
||||
#define gw_mysql_get_byte3(__buffer) \
|
||||
(uint32_t)((__buffer)[0] | \
|
||||
((__buffer)[1] << 8) | \
|
||||
((__buffer)[2] << 16))
|
||||
(uint32_t)((__buffer)[0] \
|
||||
| ((__buffer)[1] << 8) \
|
||||
| ((__buffer)[2] << 16))
|
||||
#define gw_mysql_get_byte4(__buffer) \
|
||||
(uint32_t)((__buffer)[0] | \
|
||||
((__buffer)[1] << 8) | \
|
||||
((__buffer)[2] << 16) | \
|
||||
((__buffer)[3] << 24))
|
||||
(uint32_t)((__buffer)[0] \
|
||||
| ((__buffer)[1] << 8) \
|
||||
| ((__buffer)[2] << 16) \
|
||||
| ((__buffer)[3] << 24))
|
||||
#define gw_mysql_get_byte8(__buffer) \
|
||||
((uint64_t)(__buffer)[0] | \
|
||||
((uint64_t)(__buffer)[1] << 8) | \
|
||||
((uint64_t)(__buffer)[2] << 16) | \
|
||||
((uint64_t)(__buffer)[3] << 24) | \
|
||||
((uint64_t)(__buffer)[4] << 32) | \
|
||||
((uint64_t)(__buffer)[5] << 40) | \
|
||||
((uint64_t)(__buffer)[6] << 48) | \
|
||||
((uint64_t)(__buffer)[7] << 56))
|
||||
((uint64_t)(__buffer)[0] \
|
||||
| ((uint64_t)(__buffer)[1] << 8) \
|
||||
| ((uint64_t)(__buffer)[2] << 16) \
|
||||
| ((uint64_t)(__buffer)[3] << 24) \
|
||||
| ((uint64_t)(__buffer)[4] << 32) \
|
||||
| ((uint64_t)(__buffer)[5] << 40) \
|
||||
| ((uint64_t)(__buffer)[6] << 48) \
|
||||
| ((uint64_t)(__buffer)[7] << 56))
|
||||
|
||||
/** MySQL protocol constants */
|
||||
typedef enum
|
||||
{
|
||||
GW_MYSQL_CAPABILITIES_NONE = 0,
|
||||
GW_MYSQL_CAPABILITIES_NONE = 0,
|
||||
/** This is sent by pre-10.2 clients */
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL = (1 << 0),
|
||||
GW_MYSQL_CAPABILITIES_FOUND_ROWS = (1 << 1),
|
||||
GW_MYSQL_CAPABILITIES_LONG_FLAG = (1 << 2),
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB = (1 << 3),
|
||||
GW_MYSQL_CAPABILITIES_NO_SCHEMA = (1 << 4),
|
||||
GW_MYSQL_CAPABILITIES_COMPRESS = (1 << 5),
|
||||
GW_MYSQL_CAPABILITIES_ODBC = (1 << 6),
|
||||
GW_MYSQL_CAPABILITIES_LOCAL_FILES = (1 << 7),
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SPACE = (1 << 8),
|
||||
GW_MYSQL_CAPABILITIES_PROTOCOL_41 = (1 << 9),
|
||||
GW_MYSQL_CAPABILITIES_INTERACTIVE = (1 << 10),
|
||||
GW_MYSQL_CAPABILITIES_SSL = (1 << 11),
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SIGPIPE = (1 << 12),
|
||||
GW_MYSQL_CAPABILITIES_TRANSACTIONS = (1 << 13),
|
||||
GW_MYSQL_CAPABILITIES_RESERVED = (1 << 14),
|
||||
GW_MYSQL_CAPABILITIES_SECURE_CONNECTION = (1 << 15),
|
||||
GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS = (1 << 16),
|
||||
GW_MYSQL_CAPABILITIES_MULTI_RESULTS = (1 << 17),
|
||||
GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS = (1 << 18),
|
||||
GW_MYSQL_CAPABILITIES_PLUGIN_AUTH = (1 << 19),
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_ATTRS = (1 << 20),
|
||||
GW_MYSQL_CAPABILITIES_AUTH_LENENC_DATA = (1 << 21),
|
||||
GW_MYSQL_CAPABILITIES_EXPIRE_PASSWORD = (1 << 22),
|
||||
GW_MYSQL_CAPABILITIES_SESSION_TRACK = (1 << 23),
|
||||
GW_MYSQL_CAPABILITIES_DEPRECATE_EOF = (1 << 24),
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL = (1 << 0),
|
||||
GW_MYSQL_CAPABILITIES_FOUND_ROWS = (1 << 1),
|
||||
GW_MYSQL_CAPABILITIES_LONG_FLAG = (1 << 2),
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB = (1 << 3),
|
||||
GW_MYSQL_CAPABILITIES_NO_SCHEMA = (1 << 4),
|
||||
GW_MYSQL_CAPABILITIES_COMPRESS = (1 << 5),
|
||||
GW_MYSQL_CAPABILITIES_ODBC = (1 << 6),
|
||||
GW_MYSQL_CAPABILITIES_LOCAL_FILES = (1 << 7),
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SPACE = (1 << 8),
|
||||
GW_MYSQL_CAPABILITIES_PROTOCOL_41 = (1 << 9),
|
||||
GW_MYSQL_CAPABILITIES_INTERACTIVE = (1 << 10),
|
||||
GW_MYSQL_CAPABILITIES_SSL = (1 << 11),
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SIGPIPE = (1 << 12),
|
||||
GW_MYSQL_CAPABILITIES_TRANSACTIONS = (1 << 13),
|
||||
GW_MYSQL_CAPABILITIES_RESERVED = (1 << 14),
|
||||
GW_MYSQL_CAPABILITIES_SECURE_CONNECTION = (1 << 15),
|
||||
GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS = (1 << 16),
|
||||
GW_MYSQL_CAPABILITIES_MULTI_RESULTS = (1 << 17),
|
||||
GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS = (1 << 18),
|
||||
GW_MYSQL_CAPABILITIES_PLUGIN_AUTH = (1 << 19),
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_ATTRS = (1 << 20),
|
||||
GW_MYSQL_CAPABILITIES_AUTH_LENENC_DATA = (1 << 21),
|
||||
GW_MYSQL_CAPABILITIES_EXPIRE_PASSWORD = (1 << 22),
|
||||
GW_MYSQL_CAPABILITIES_SESSION_TRACK = (1 << 23),
|
||||
GW_MYSQL_CAPABILITIES_DEPRECATE_EOF = (1 << 24),
|
||||
GW_MYSQL_CAPABILITIES_SSL_VERIFY_SERVER_CERT = (1 << 30),
|
||||
GW_MYSQL_CAPABILITIES_REMEMBER_OPTIONS = (1 << 31),
|
||||
GW_MYSQL_CAPABILITIES_CLIENT = (
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL |
|
||||
GW_MYSQL_CAPABILITIES_FOUND_ROWS |
|
||||
GW_MYSQL_CAPABILITIES_LONG_FLAG |
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB |
|
||||
GW_MYSQL_CAPABILITIES_LOCAL_FILES |
|
||||
GW_MYSQL_CAPABILITIES_PLUGIN_AUTH |
|
||||
GW_MYSQL_CAPABILITIES_TRANSACTIONS |
|
||||
GW_MYSQL_CAPABILITIES_PROTOCOL_41 |
|
||||
GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS |
|
||||
GW_MYSQL_CAPABILITIES_MULTI_RESULTS |
|
||||
GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS |
|
||||
GW_MYSQL_CAPABILITIES_SECURE_CONNECTION),
|
||||
GW_MYSQL_CAPABILITIES_REMEMBER_OPTIONS = (1 << 31),
|
||||
GW_MYSQL_CAPABILITIES_CLIENT = (
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL
|
||||
| GW_MYSQL_CAPABILITIES_FOUND_ROWS
|
||||
| GW_MYSQL_CAPABILITIES_LONG_FLAG
|
||||
| GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB
|
||||
| GW_MYSQL_CAPABILITIES_LOCAL_FILES
|
||||
| GW_MYSQL_CAPABILITIES_PLUGIN_AUTH
|
||||
| GW_MYSQL_CAPABILITIES_TRANSACTIONS
|
||||
| GW_MYSQL_CAPABILITIES_PROTOCOL_41
|
||||
| GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS
|
||||
| GW_MYSQL_CAPABILITIES_MULTI_RESULTS
|
||||
| GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS
|
||||
| GW_MYSQL_CAPABILITIES_SECURE_CONNECTION),
|
||||
GW_MYSQL_CAPABILITIES_SERVER = (
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL |
|
||||
GW_MYSQL_CAPABILITIES_FOUND_ROWS |
|
||||
GW_MYSQL_CAPABILITIES_LONG_FLAG |
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB |
|
||||
GW_MYSQL_CAPABILITIES_NO_SCHEMA |
|
||||
GW_MYSQL_CAPABILITIES_ODBC |
|
||||
GW_MYSQL_CAPABILITIES_LOCAL_FILES |
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SPACE |
|
||||
GW_MYSQL_CAPABILITIES_PROTOCOL_41 |
|
||||
GW_MYSQL_CAPABILITIES_INTERACTIVE |
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SIGPIPE |
|
||||
GW_MYSQL_CAPABILITIES_TRANSACTIONS |
|
||||
GW_MYSQL_CAPABILITIES_RESERVED |
|
||||
GW_MYSQL_CAPABILITIES_SECURE_CONNECTION |
|
||||
GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS |
|
||||
GW_MYSQL_CAPABILITIES_MULTI_RESULTS |
|
||||
GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS |
|
||||
GW_MYSQL_CAPABILITIES_PLUGIN_AUTH),
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL
|
||||
| GW_MYSQL_CAPABILITIES_FOUND_ROWS
|
||||
| GW_MYSQL_CAPABILITIES_LONG_FLAG
|
||||
| GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB
|
||||
| GW_MYSQL_CAPABILITIES_NO_SCHEMA
|
||||
| GW_MYSQL_CAPABILITIES_ODBC
|
||||
| GW_MYSQL_CAPABILITIES_LOCAL_FILES
|
||||
| GW_MYSQL_CAPABILITIES_IGNORE_SPACE
|
||||
| GW_MYSQL_CAPABILITIES_PROTOCOL_41
|
||||
| GW_MYSQL_CAPABILITIES_INTERACTIVE
|
||||
| GW_MYSQL_CAPABILITIES_IGNORE_SIGPIPE
|
||||
| GW_MYSQL_CAPABILITIES_TRANSACTIONS
|
||||
| GW_MYSQL_CAPABILITIES_RESERVED
|
||||
| GW_MYSQL_CAPABILITIES_SECURE_CONNECTION
|
||||
| GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS
|
||||
| GW_MYSQL_CAPABILITIES_MULTI_RESULTS
|
||||
| GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS
|
||||
| GW_MYSQL_CAPABILITIES_PLUGIN_AUTH),
|
||||
} gw_mysql_capabilities_t;
|
||||
|
||||
/**
|
||||
@ -286,19 +289,19 @@ typedef enum
|
||||
MXS_COM_TABLE_DUMP,
|
||||
MXS_COM_CONNECT_OUT = 20,
|
||||
MXS_COM_REGISTER_SLAVE,
|
||||
MXS_COM_STMT_PREPARE = 22,
|
||||
MXS_COM_STMT_EXECUTE = 23,
|
||||
MXS_COM_STMT_PREPARE = 22,
|
||||
MXS_COM_STMT_EXECUTE = 23,
|
||||
MXS_COM_STMT_SEND_LONG_DATA = 24,
|
||||
MXS_COM_STMT_CLOSE = 25,
|
||||
MXS_COM_STMT_RESET = 26,
|
||||
MXS_COM_SET_OPTION = 27,
|
||||
MXS_COM_STMT_FETCH = 28,
|
||||
MXS_COM_STMT_BULK_EXECUTE = 0xfa,
|
||||
MXS_COM_STMT_CLOSE = 25,
|
||||
MXS_COM_STMT_RESET = 26,
|
||||
MXS_COM_SET_OPTION = 27,
|
||||
MXS_COM_STMT_FETCH = 28,
|
||||
MXS_COM_STMT_BULK_EXECUTE = 0xfa,
|
||||
MXS_COM_DAEMON,
|
||||
MXS_COM_END
|
||||
} mxs_mysql_cmd_t;
|
||||
|
||||
static const mxs_mysql_cmd_t MXS_COM_UNDEFINED = (mxs_mysql_cmd_t) - 1;
|
||||
static const mxs_mysql_cmd_t MXS_COM_UNDEFINED = (mxs_mysql_cmd_t) -1;
|
||||
|
||||
/**
|
||||
* A GWBUF property with this name will contain the latest GTID in string form.
|
||||
@ -314,23 +317,25 @@ static const char* const MXS_LAST_GTID = "last_gtid";
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int fd; /*< The socket descriptor */
|
||||
struct dcb* owner_dcb; /*< The DCB of the socket we are running on */
|
||||
mxs_mysql_cmd_t current_command; /*< Current command being executed */
|
||||
mxs_auth_state_t protocol_auth_state; /*< Authentication status */
|
||||
mysql_protocol_state_t protocol_state; /*< Protocol struct status */
|
||||
uint8_t scramble[MYSQL_SCRAMBLE_LEN]; /*< server scramble, created or received */
|
||||
uint32_t server_capabilities; /*< server capabilities, created or received */
|
||||
uint32_t client_capabilities; /*< client capabilities, created or received */
|
||||
uint32_t extra_capabilities; /*< MariaDB 10.2 capabilities */
|
||||
uint64_t thread_id; /*< MySQL Thread ID. Send only 32bits in handshake. */
|
||||
unsigned int charset; /*< MySQL character set at connect time */
|
||||
int ignore_replies; /*< How many replies should be discarded */
|
||||
GWBUF* stored_query; /*< Temporarily stored queries */
|
||||
bool collect_result; /*< Collect the next result set as one buffer */
|
||||
int fd; /*< The socket descriptor */
|
||||
struct dcb* owner_dcb; /*< The DCB of the socket we are running on */
|
||||
mxs_mysql_cmd_t current_command; /*< Current command being executed */
|
||||
mxs_auth_state_t protocol_auth_state; /*< Authentication status */
|
||||
mysql_protocol_state_t protocol_state; /*< Protocol struct status */
|
||||
uint8_t scramble[MYSQL_SCRAMBLE_LEN];/*< server scramble, created or received */
|
||||
uint32_t server_capabilities; /*< server capabilities, created or received */
|
||||
uint32_t client_capabilities; /*< client capabilities, created or received */
|
||||
uint32_t extra_capabilities; /*< MariaDB 10.2 capabilities */
|
||||
uint64_t thread_id; /*< MySQL Thread ID. Send only 32bits in handshake. */
|
||||
unsigned int charset; /*< MySQL character set at connect time */
|
||||
int ignore_replies; /*< How many replies should be discarded */
|
||||
GWBUF* stored_query; /*< Temporarily stored queries */
|
||||
bool collect_result; /*< Collect the next result set as one buffer */
|
||||
bool changing_user;
|
||||
uint32_t num_eof_packets; /*< Encountered eof packet number, used for check packet type */
|
||||
bool large_query; /*< Whether to ignore the command byte of the next packet*/
|
||||
uint32_t num_eof_packets; /*< Encountered eof packet number, used for check
|
||||
* packet type */
|
||||
bool large_query; /*< Whether to ignore the command byte of the next
|
||||
* packet*/
|
||||
} MySQLProtocol;
|
||||
|
||||
typedef struct
|
||||
@ -346,7 +351,7 @@ typedef struct
|
||||
#define MYSQL_REPLY_OK 0x00
|
||||
#define MYSQL_REPLY_EOF 0xfe
|
||||
#define MYSQL_REPLY_LOCAL_INFILE 0xfb
|
||||
#define MYSQL_REPLY_AUTHSWITCHREQUEST 0xfe /**< Only sent during authentication */
|
||||
#define MYSQL_REPLY_AUTHSWITCHREQUEST 0xfe /**< Only sent during authentication */
|
||||
|
||||
static inline mxs_mysql_cmd_t MYSQL_GET_COMMAND(const uint8_t* header)
|
||||
{
|
||||
@ -368,10 +373,10 @@ static inline uint32_t MYSQL_GET_PACKET_LEN(const GWBUF* buffer)
|
||||
return MYSQL_GET_PAYLOAD_LEN(GWBUF_DATA(buffer)) + MYSQL_HEADER_LEN;
|
||||
}
|
||||
|
||||
#define MYSQL_GET_ERRCODE(payload) (gw_mysql_get_byte2(&payload[5]))
|
||||
#define MYSQL_GET_STMTOK_NPARAM(payload) (gw_mysql_get_byte2(&payload[9]))
|
||||
#define MYSQL_GET_STMTOK_NATTR(payload) (gw_mysql_get_byte2(&payload[11]))
|
||||
#define MYSQL_GET_NATTR(payload) ((int)payload[4])
|
||||
#define MYSQL_GET_ERRCODE(payload) (gw_mysql_get_byte2(&payload[5]))
|
||||
#define MYSQL_GET_STMTOK_NPARAM(payload) (gw_mysql_get_byte2(&payload[9]))
|
||||
#define MYSQL_GET_STMTOK_NATTR(payload) (gw_mysql_get_byte2(&payload[11]))
|
||||
#define MYSQL_GET_NATTR(payload) ((int)payload[4])
|
||||
|
||||
static inline bool MYSQL_IS_ERROR_PACKET(const uint8_t* header)
|
||||
{
|
||||
@ -380,8 +385,8 @@ static inline bool MYSQL_IS_ERROR_PACKET(const uint8_t* header)
|
||||
|
||||
static inline bool MYSQL_IS_COM_QUIT(const uint8_t* header)
|
||||
{
|
||||
return MYSQL_GET_COMMAND(header) == MXS_COM_QUIT &&
|
||||
MYSQL_GET_PAYLOAD_LEN(header) == 1;
|
||||
return MYSQL_GET_COMMAND(header) == MXS_COM_QUIT
|
||||
&& MYSQL_GET_PAYLOAD_LEN(header) == 1;
|
||||
}
|
||||
|
||||
static inline bool MYSQL_IS_COM_INIT_DB(const uint8_t* header)
|
||||
@ -430,7 +435,7 @@ bool mysql_protocol_done(DCB* dcb);
|
||||
*
|
||||
* @return String representation of the state
|
||||
*/
|
||||
const char *gw_mysql_protocol_state2string(int state);
|
||||
const char* gw_mysql_protocol_state2string(int state);
|
||||
|
||||
/**
|
||||
* Set current command being executed
|
||||
@ -444,20 +449,20 @@ void mysql_protocol_set_current_command(DCB* dcb, mxs_mysql_cmd_t cmd);
|
||||
|
||||
GWBUF* mysql_create_com_quit(GWBUF* bufparam, int sequence);
|
||||
GWBUF* mysql_create_custom_error(int sequence, int affected_rows, const char* msg);
|
||||
GWBUF *mysql_create_standard_error(int sequence, int error_number, const char *msg);
|
||||
GWBUF* mysql_create_standard_error(int sequence, int error_number, const char* msg);
|
||||
|
||||
int mysql_send_com_quit(DCB* dcb, int sequence, GWBUF* buf);
|
||||
int mysql_send_custom_error(DCB *dcb, int sequence, int affected_rows, const char* msg);
|
||||
int mysql_send_standard_error(DCB *dcb, int sequence, int errnum, const char *msg);
|
||||
int mysql_send_auth_error(DCB *dcb, int sequence, int affected_rows, const char* msg);
|
||||
int mysql_send_custom_error(DCB* dcb, int sequence, int affected_rows, const char* msg);
|
||||
int mysql_send_standard_error(DCB* dcb, int sequence, int errnum, const char* msg);
|
||||
int mysql_send_auth_error(DCB* dcb, int sequence, int affected_rows, const char* msg);
|
||||
|
||||
char* create_auth_fail_str(char *username, char *hostaddr, bool password, char *db, int);
|
||||
char* create_auth_fail_str(char* username, char* hostaddr, bool password, char* db, int);
|
||||
|
||||
void init_response_status(GWBUF* buf, uint8_t cmd, int* npackets, size_t* nbytes);
|
||||
bool read_complete_packet(DCB *dcb, GWBUF **readbuf);
|
||||
bool gw_get_shared_session_auth_info(DCB* dcb, MYSQL_session* session);
|
||||
void mxs_mysql_get_session_track_info(GWBUF *buff, MySQLProtocol *proto);
|
||||
mysql_tx_state_t parse_trx_state(const char *str);
|
||||
void init_response_status(GWBUF* buf, uint8_t cmd, int* npackets, size_t* nbytes);
|
||||
bool read_complete_packet(DCB* dcb, GWBUF** readbuf);
|
||||
bool gw_get_shared_session_auth_info(DCB* dcb, MYSQL_session* session);
|
||||
void mxs_mysql_get_session_track_info(GWBUF* buff, MySQLProtocol* proto);
|
||||
mysql_tx_state_t parse_trx_state(const char* str);
|
||||
|
||||
/**
|
||||
* Decode server handshake
|
||||
@ -468,7 +473,7 @@ mysql_tx_state_t parse_trx_state(const char *str);
|
||||
* @return 0 on success, -1 on failure
|
||||
*
|
||||
*/
|
||||
int gw_decode_mysql_server_handshake(MySQLProtocol *conn, uint8_t *payload);
|
||||
int gw_decode_mysql_server_handshake(MySQLProtocol* conn, uint8_t* payload);
|
||||
|
||||
/**
|
||||
* Create a response to the server handshake
|
||||
@ -481,14 +486,17 @@ int gw_decode_mysql_server_handshake(MySQLProtocol *conn, uint8_t *payload);
|
||||
*
|
||||
* @return Generated response packet
|
||||
*/
|
||||
GWBUF* gw_generate_auth_response(MYSQL_session* client, MySQLProtocol *conn,
|
||||
bool with_ssl, bool ssl_established, uint64_t service_capabilities);
|
||||
GWBUF* gw_generate_auth_response(MYSQL_session* client,
|
||||
MySQLProtocol* conn,
|
||||
bool with_ssl,
|
||||
bool ssl_established,
|
||||
uint64_t service_capabilities);
|
||||
|
||||
/** Read the backend server's handshake */
|
||||
bool gw_read_backend_handshake(DCB *dcb, GWBUF *buffer);
|
||||
bool gw_read_backend_handshake(DCB* dcb, GWBUF* buffer);
|
||||
|
||||
/** Send the server handshake response packet to the backend server */
|
||||
mxs_auth_state_t gw_send_backend_auth(DCB *dcb);
|
||||
mxs_auth_state_t gw_send_backend_auth(DCB* dcb);
|
||||
|
||||
/** Sends a response for an AuthSwitchRequest to the default auth plugin */
|
||||
int send_mysql_native_password_response(DCB* dcb);
|
||||
@ -497,7 +505,7 @@ int send_mysql_native_password_response(DCB* dcb);
|
||||
bool send_auth_switch_request_packet(DCB* dcb);
|
||||
|
||||
/** Write an OK packet to a DCB */
|
||||
int mxs_mysql_send_ok(DCB *dcb, int sequence, uint8_t affected_rows, const char* message);
|
||||
int mxs_mysql_send_ok(DCB* dcb, int sequence, uint8_t affected_rows, const char* message);
|
||||
|
||||
/**
|
||||
* @brief Check if the buffer contains an OK packet
|
||||
@ -505,7 +513,7 @@ int mxs_mysql_send_ok(DCB *dcb, int sequence, uint8_t affected_rows, const char*
|
||||
* @param buffer Buffer containing a complete MySQL packet
|
||||
* @return True if the buffer contains an OK packet
|
||||
*/
|
||||
bool mxs_mysql_is_ok_packet(GWBUF *buffer);
|
||||
bool mxs_mysql_is_ok_packet(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* @brief Check if the buffer contains an ERR packet
|
||||
@ -513,7 +521,7 @@ bool mxs_mysql_is_ok_packet(GWBUF *buffer);
|
||||
* @param buffer Buffer containing a complete MySQL packet
|
||||
* @return True if the buffer contains an ERR packet
|
||||
*/
|
||||
bool mxs_mysql_is_err_packet(GWBUF *buffer);
|
||||
bool mxs_mysql_is_err_packet(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* @brief Check if a buffer contains a result set
|
||||
@ -522,7 +530,7 @@ bool mxs_mysql_is_err_packet(GWBUF *buffer);
|
||||
*
|
||||
* @return True if the @c buffer contains the start of a result set
|
||||
*/
|
||||
bool mxs_mysql_is_result_set(GWBUF *buffer);
|
||||
bool mxs_mysql_is_result_set(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* @brief Check if the buffer contains a LOCAL INFILE request
|
||||
@ -531,7 +539,7 @@ bool mxs_mysql_is_result_set(GWBUF *buffer);
|
||||
*
|
||||
* @return True if the buffer contains a LOCAL INFILE request
|
||||
*/
|
||||
bool mxs_mysql_is_local_infile(GWBUF *buffer);
|
||||
bool mxs_mysql_is_local_infile(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* @brief Check if the buffer contains a prepared statement OK packet
|
||||
@ -540,7 +548,7 @@ bool mxs_mysql_is_local_infile(GWBUF *buffer);
|
||||
*
|
||||
* @return True if the @c buffer contains a prepared statement OK packet
|
||||
*/
|
||||
bool mxs_mysql_is_prep_stmt_ok(GWBUF *buffer);
|
||||
bool mxs_mysql_is_prep_stmt_ok(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* Is this a binary protocol command
|
||||
@ -558,7 +566,7 @@ bool mxs_mysql_is_ps_command(uint8_t cmd);
|
||||
*
|
||||
* @return True if more results are expected
|
||||
*/
|
||||
bool mxs_mysql_more_results_after_ok(GWBUF *buffer);
|
||||
bool mxs_mysql_more_results_after_ok(GWBUF* buffer);
|
||||
|
||||
/** Get current command for a session */
|
||||
mxs_mysql_cmd_t mxs_mysql_current_command(MXS_SESSION* session);
|
||||
@ -570,8 +578,10 @@ mxs_mysql_cmd_t mxs_mysql_current_command(MXS_SESSION* session);
|
||||
* @param npackets Pointer where the number of packets is stored
|
||||
* @param nbytes Pointer where number of bytes is stored
|
||||
*/
|
||||
void mysql_num_response_packets(GWBUF *buf, uint8_t cmd,
|
||||
int* npackets, size_t *nbytes);
|
||||
void mysql_num_response_packets(GWBUF* buf,
|
||||
uint8_t cmd,
|
||||
int* npackets,
|
||||
size_t* nbytes);
|
||||
|
||||
/**
|
||||
* @brief Return current database of the session
|
||||
|
Reference in New Issue
Block a user