-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathconst.go
227 lines (207 loc) · 5.28 KB
/
const.go
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
package mysql
const (
ClassicProtocolVersion byte = 10
XProtocolVersion byte = 11
MaxPayloadLen int = 1<<24 - 1
TimeFormat string = "2006-01-02 15:04:05"
)
const (
OK_HEADER byte = 0x00
MORE_DATE_HEADER byte = 0x01
ERR_HEADER byte = 0xff
EOF_HEADER byte = 0xfe
LocalInFile_HEADER byte = 0xfb
CACHE_SHA2_FAST_AUTH byte = 0x03
CACHE_SHA2_FULL_AUTH byte = 0x04
)
const (
AUTH_MYSQL_OLD_PASSWORD = "mysql_old_password"
AUTH_NATIVE_PASSWORD = "mysql_native_password"
AUTH_CLEAR_PASSWORD = "mysql_clear_password"
AUTH_CACHING_SHA2_PASSWORD = "caching_sha2_password"
AUTH_SHA256_PASSWORD = "sha256_password"
AUTH_MARIADB_ED25519 = "client_ed25519"
)
// SERVER_STATUS_flags_enum
// https://dev.mysql.com/doc/dev/mysql-server/latest/mysql__com_8h.html#a1d854e841086925be1883e4d7b4e8cad
// https://github.com/mysql/mysql-server/blob/500c3117e6f638043c4fea8aacf17d63a8d07de6/include/mysql_com.h#L809-L864
const (
SERVER_STATUS_IN_TRANS uint16 = 0x0001
SERVER_STATUS_AUTOCOMMIT uint16 = 0x0002
SERVER_MORE_RESULTS_EXISTS uint16 = 0x0008
SERVER_STATUS_NO_GOOD_INDEX_USED uint16 = 0x0010
SERVER_STATUS_NO_INDEX_USED uint16 = 0x0020
SERVER_STATUS_CURSOR_EXISTS uint16 = 0x0040
SERVER_STATUS_LAST_ROW_SEND uint16 = 0x0080
SERVER_STATUS_DB_DROPPED uint16 = 0x0100
SERVER_STATUS_NO_BACKSLASH_ESCAPED uint16 = 0x0200
SERVER_STATUS_METADATA_CHANGED uint16 = 0x0400
SERVER_QUERY_WAS_SLOW uint16 = 0x0800
SERVER_PS_OUT_PARAMS uint16 = 0x1000
SERVER_STATUS_IN_TRANS_READONLY uint16 = 0x2000
SERVER_SESSION_STATE_CHANGED uint16 = 0x4000
)
// https://github.com/mysql/mysql-server/blob/6b6d3ed3d5c6591b446276184642d7d0504ecc86/include/my_command.h#L48-L103
const (
COM_SLEEP byte = iota
COM_QUIT
COM_INIT_DB
COM_QUERY
COM_FIELD_LIST
COM_CREATE_DB
COM_DROP_DB
COM_REFRESH
COM_SHUTDOWN
COM_STATISTICS
COM_PROCESS_INFO
COM_CONNECT
COM_PROCESS_KILL
COM_DEBUG
COM_PING
COM_TIME
COM_DELAYED_INSERT
COM_CHANGE_USER
COM_BINLOG_DUMP
COM_TABLE_DUMP
COM_CONNECT_OUT
COM_REGISTER_SLAVE
COM_STMT_PREPARE
COM_STMT_EXECUTE
COM_STMT_SEND_LONG_DATA
COM_STMT_CLOSE
COM_STMT_RESET
COM_SET_OPTION
COM_STMT_FETCH
COM_DAEMON
COM_BINLOG_DUMP_GTID
COM_RESET_CONNECTION
COM_CLONE
COM_SUBSCRIBE_GROUP_REPLICATION_STREAM
)
const (
// https://dev.mysql.com/doc/dev/mysql-server/latest/group__group__cs__capabilities__flags.html
CLIENT_LONG_PASSWORD uint32 = 1 << iota
CLIENT_FOUND_ROWS
CLIENT_LONG_FLAG
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_SECURE_CONNECTION
CLIENT_MULTI_STATEMENTS
CLIENT_MULTI_RESULTS
CLIENT_PS_MULTI_RESULTS
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
CLIENT_CAPABILITY_EXTENSION
CLIENT_SSL_VERIFY_SERVER_CERT
CLIENT_REMEMBER_OPTIONS
)
const (
MYSQL_TYPE_DECIMAL byte = iota
MYSQL_TYPE_TINY
MYSQL_TYPE_SHORT
MYSQL_TYPE_LONG
MYSQL_TYPE_FLOAT
MYSQL_TYPE_DOUBLE
MYSQL_TYPE_NULL
MYSQL_TYPE_TIMESTAMP
MYSQL_TYPE_LONGLONG
MYSQL_TYPE_INT24
MYSQL_TYPE_DATE
MYSQL_TYPE_TIME
MYSQL_TYPE_DATETIME
MYSQL_TYPE_YEAR
MYSQL_TYPE_NEWDATE
MYSQL_TYPE_VARCHAR
MYSQL_TYPE_BIT
// mysql 5.6
MYSQL_TYPE_TIMESTAMP2
MYSQL_TYPE_DATETIME2
MYSQL_TYPE_TIME2
)
const MYSQL_TYPE_VECTOR = 0xf2
const (
MYSQL_TYPE_JSON byte = iota + 0xf5
MYSQL_TYPE_NEWDECIMAL
MYSQL_TYPE_ENUM
MYSQL_TYPE_SET
MYSQL_TYPE_TINY_BLOB
MYSQL_TYPE_MEDIUM_BLOB
MYSQL_TYPE_LONG_BLOB
MYSQL_TYPE_BLOB
MYSQL_TYPE_VAR_STRING
MYSQL_TYPE_STRING
MYSQL_TYPE_GEOMETRY
)
const (
NOT_NULL_FLAG = 1
PRI_KEY_FLAG = 2
UNIQUE_KEY_FLAG = 4
BLOB_FLAG = 16
UNSIGNED_FLAG = 32
ZEROFILL_FLAG = 64
BINARY_FLAG = 128
ENUM_FLAG = 256
AUTO_INCREMENT_FLAG = 512
TIMESTAMP_FLAG = 1024
SET_FLAG = 2048
NUM_FLAG = 32768
PART_KEY_FLAG = 16384
GROUP_FLAG = 32768
UNIQUE_FLAG = 65536
)
const (
PARAM_UNSIGNED = 128
)
const (
DEFAULT_ADDR = "127.0.0.1:3306"
DEFAULT_IPV6_ADDR = "[::1]:3306"
DEFAULT_USER = "root"
DEFAULT_PASSWORD = ""
DEFAULT_FLAVOR = MySQLFlavor
DEFAULT_CHARSET = "utf8mb4"
DEFAULT_COLLATION_ID uint8 = 255
DEFAULT_COLLATION_NAME string = "utf8mb4_0900_ai_ci"
)
const (
DEFAULT_DUMP_EXECUTION_PATH = "mysqldump"
)
// Like vitess, use flavor for different MySQL versions,
const (
MySQLFlavor = "mysql"
MariaDBFlavor = "mariadb"
)
const (
MYSQL_OPTION_MULTI_STATEMENTS_ON = iota
MYSQL_OPTION_MULTI_STATEMENTS_OFF
)
const (
MYSQL_COMPRESS_NONE = iota
MYSQL_COMPRESS_ZLIB
MYSQL_COMPRESS_ZSTD
)
// See enum_cursor_type in mysql.h
const (
CURSOR_TYPE_NO_CURSOR byte = 0x0
CURSOR_TYPE_READ_ONLY byte = 0x1
CURSOR_TYPE_FOR_UPDATE byte = 0x2
CURSOR_TYPE_SCROLLABLE byte = 0x4
PARAMETER_COUNT_AVAILABLE byte = 0x8
)