/
mysql_protocol_common.h
111 lines (93 loc) · 2.85 KB
/
mysql_protocol_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLD_MOCK_MYSQL_PROTOCOL_COMMON_INCLUDED
#define MYSQLD_MOCK_MYSQL_PROTOCOL_COMMON_INCLUDED
#include <string>
#ifdef _WIN32
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
// TODO after migration to Server repo: delete mysqlrouter/ after moving stuff 1
// level up
#include "mysqlrouter/mysql_protocol.h"
#include "socket_operations.h"
namespace server_mock {
using byte = uint8_t;
using mysql_harness::socket_t;
/** @enum MySQLColumnType
*
* Supported MySQL Coumn types.
*
**/
enum class MySQLColumnType {
DECIMAL = 0x00,
TINY = 0x01,
SHORT = 0x02,
LONG = 0x03,
FLOAT = 0x04,
DOUBLE = 0x05,
NULL_ = 0x06,
TIMESTAMP = 0x07,
LONGLONG = 0x08,
INT24 = 0x09,
DATE = 0x0a,
TIME = 0x0b,
DATETIME = 0x0c,
YEAR = 0x0d,
NEWDATE = 0x0e,
VARCHAR = 0x0f,
BIT = 0x10,
NEWDECIMAL = 0xf7,
ENUM = 0xf7,
SET = 0xf8,
TINY_BLOB = 0xf9,
MEDIUM_BLOB = 0xfa,
LONG_BLOB = 0xfb,
BLOB = 0xfc,
VAR_STRING = 0xfd,
STRING = 0xfe,
GEOMETRY = 0xff
};
/** @brief Struct for keeping column specific data
*
**/
struct column_info_type {
std::string name;
MySQLColumnType type;
std::string orig_name;
std::string table;
std::string orig_table;
std::string schema;
std::string catalog;
uint16_t flags;
uint8_t decimals;
uint32_t length;
uint16_t character_set;
unsigned repeat;
};
/** @brief Vector for keeping has_value|string representation of the values
* of the single row (ordered by column)
**/
using RowValueType = std::vector<std::pair<bool, std::string>>;
MySQLColumnType column_type_from_string(const std::string &type);
void non_blocking(socket_t handle_, bool mode) noexcept;
} // namespace server_mock
#endif // MYSQLD_MOCK_MYSQL_PROTOCOL_COMMON_INCLUDED