xref: /PHP-8.1/ext/mysqlnd/mysqlnd_enum_n_def.h (revision 277e169e)
1 /*
2   +----------------------------------------------------------------------+
3   | Copyright (c) The PHP Group                                          |
4   +----------------------------------------------------------------------+
5   | This source file is subject to version 3.01 of the PHP license,      |
6   | that is bundled with this package in the file LICENSE, and is        |
7   | available through the world-wide-web at the following url:           |
8   | https://www.php.net/license/3_01.txt                                 |
9   | If you did not receive a copy of the PHP license and are unable to   |
10   | obtain it through the world-wide-web, please send a note to          |
11   | license@php.net so we can mail you a copy immediately.               |
12   +----------------------------------------------------------------------+
13   | Authors: Andrey Hristov <andrey@php.net>                             |
14   |          Ulf Wendel <uw@php.net>                                     |
15   |          Georg Richter <georg@php.net>                               |
16   +----------------------------------------------------------------------+
17 */
18 
19 #ifndef MYSQLND_ENUM_N_DEF_H
20 #define MYSQLND_ENUM_N_DEF_H
21 
22 #ifndef TRUE
23 #define TRUE 1
24 #endif
25 
26 #ifndef FALSE
27 #define FALSE 0
28 #endif
29 
30 
31 #define MYSQLND_MIN_COMPRESS_LEN 0
32 
33 #define MYSQLND_MAX_PACKET_SIZE (256L*256L*256L-1)
34 
35 #define MYSQLND_ASSEMBLED_PACKET_MAX_SIZE 3UL*1024UL*1024UL*1024UL
36 
37 #define MYSQLND_DEFAULT_AUTH_PROTOCOL "mysql_native_password"
38 
39 #define MYSQLND_ERRMSG_SIZE			512
40 #define MYSQLND_SQLSTATE_LENGTH		5
41 #define MYSQLND_SQLSTATE_NULL		"00000"
42 
43 #define MYSQLND_MAX_ALLOWED_USER_LEN	252		/* 63 char * 4byte . MySQL supports now only 16 char, but let it be forward compatible */
44 #define MYSQLND_MAX_ALLOWED_DB_LEN		1024	/* 256 char * 4byte. MySQL supports now only 64 char in the tables, but on the FS could be different. Forward compatible. */
45 
46 #define MYSQLND_NET_CMD_BUFFER_MIN_SIZE			4096
47 #define MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR		"4096"
48 
49 #define MYSQLND_STMT_ID_LENGTH 4
50 
51 
52 #define SERVER_STATUS_IN_TRANS					1	/* Transaction has started */
53 #define SERVER_STATUS_AUTOCOMMIT				2	/* Server in auto_commit mode */
54 #define SERVER_MORE_RESULTS_EXISTS				8	/* Multi query - next query exists */
55 #define SERVER_QUERY_NO_GOOD_INDEX_USED	16
56 #define SERVER_QUERY_NO_INDEX_USED		32
57 /*
58   The server was able to fulfill the clients request and opened a
59   read-only non-scrollable cursor for a query. This flag comes
60   in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
61 */
62 #define SERVER_STATUS_CURSOR_EXISTS				64
63 /*
64   This flag is sent when a read-only cursor is exhausted, in reply to
65   COM_STMT_FETCH command.
66 */
67 #define SERVER_STATUS_LAST_ROW_SENT				128
68 #define SERVER_STATUS_DB_DROPPED				256 /* A database was dropped */
69 #define SERVER_STATUS_NO_BACKSLASH_ESCAPES		512
70 #define SERVER_QUERY_WAS_SLOW					2048
71 #define SERVER_PS_OUT_PARAMS            		4096
72 
73 #define MYSQLND_NO_DATA			100
74 #define MYSQLND_DATA_TRUNCATED	101
75 
76 #define SHA1_MAX_LENGTH 20
77 #define SCRAMBLE_LENGTH 20
78 #define SCRAMBLE_LENGTH_323 8
79 
80 #define CLIENT_LONG_PASSWORD		1		/* new more secure passwords */
81 #define CLIENT_FOUND_ROWS			2		/* Found instead of affected rows */
82 #define CLIENT_LONG_FLAG			4		/* Get all column flags */
83 #define CLIENT_CONNECT_WITH_DB		8		/* One can specify db on connect */
84 #define CLIENT_NO_SCHEMA			16		/* Don't allow database.table.column */
85 #define CLIENT_COMPRESS				32		/* Can use compression protocol */
86 #define CLIENT_ODBC					64		/* Odbc client */
87 #define CLIENT_LOCAL_FILES			128		/* Can use LOAD DATA LOCAL */
88 #define CLIENT_IGNORE_SPACE			256		/* Ignore spaces before '(' */
89 #define CLIENT_PROTOCOL_41			512		/* New 4.1 protocol */
90 #define CLIENT_INTERACTIVE			1024	/* This is an interactive client */
91 #define CLIENT_SSL					2048	/* Switch to SSL after handshake */
92 #define CLIENT_IGNORE_SIGPIPE		4096	/* IGNORE sigpipes */
93 #define CLIENT_TRANSACTIONS			8192	/* Client knows about transactions */
94 #define CLIENT_RESERVED				16384	/* Old flag for 4.1 protocol */
95 #define CLIENT_SECURE_CONNECTION	32768	/* New 4.1 authentication */
96 #define CLIENT_MULTI_STATEMENTS		(1UL << 16) /* Enable/disable multi-stmt support */
97 #define CLIENT_MULTI_RESULTS		(1UL << 17) /* Enable/disable multi-results */
98 #define CLIENT_PS_MULTI_RESULTS		(1UL << 18) /* Multi-results in PS-protocol */
99 #define CLIENT_PLUGIN_AUTH			(1UL << 19) /* Client supports plugin authentication */
100 #define CLIENT_CONNECT_ATTRS		(1UL << 20) /* Client supports connection attributes */
101 #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA	(1UL << 21) /* Enable authentication response packet to be larger than 255 bytes. */
102 #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS		(1UL << 22) /* Don't close the connection for a connection with expired password. */
103 #define CLIENT_SESSION_TRACK					(1UL << 23) /* Extended OK */
104 /*
105   This is a mysqlnd extension. CLIENT_ODBC is not used anyway. We will reuse it for our case and translate it to not using SSL peer verification
106 */
107 #define CLIENT_SSL_DONT_VERIFY_SERVER_CERT	CLIENT_ODBC
108 #define CLIENT_SSL_VERIFY_SERVER_CERT	(1UL << 30)
109 #define CLIENT_REMEMBER_OPTIONS			(1UL << 31)
110 
111 #define MYSQLND_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | \
112 				CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION | \
113 				CLIENT_MULTI_RESULTS  | CLIENT_LOCAL_FILES | CLIENT_PLUGIN_AUTH)
114 
115 #define MYSQLND_PROTOCOL_FLAG_USE_COMPRESSION 1
116 
117 
118 /* Client Error codes */
119 #define CR_UNKNOWN_ERROR		2000
120 #define CR_CONNECTION_ERROR		2002
121 #define CR_SERVER_GONE_ERROR	2006
122 #define CR_OUT_OF_MEMORY		2008
123 #define CR_SERVER_LOST			2013
124 #define CR_COMMANDS_OUT_OF_SYNC	2014
125 #define CR_CANT_FIND_CHARSET	2019
126 #define CR_MALFORMED_PACKET		2027
127 #define CR_NOT_IMPLEMENTED		2054
128 #define CR_NO_PREPARE_STMT		2030
129 #define CR_PARAMS_NOT_BOUND		2031
130 #define CR_INVALID_PARAMETER_NO	2034
131 #define CR_INVALID_BUFFER_USE	2035
132 #define CR_LOAD_DATA_LOCAL_INFILE_REJECTED 2068
133 
134 #define MYSQLND_EE_FILENOTFOUND	 7890
135 
136 #define UNKNOWN_SQLSTATE		"HY000"
137 
138 #define MAX_CHARSET_LEN			32
139 
140 
141 #define TRANS_START_NO_OPT						0
142 #define TRANS_START_WITH_CONSISTENT_SNAPSHOT	1
143 #define TRANS_START_READ_WRITE					2
144 #define TRANS_START_READ_ONLY					4
145 
146 #define TRANS_COR_NO_OPT		0
147 #define TRANS_COR_AND_CHAIN		1
148 #define TRANS_COR_AND_NO_CHAIN	2
149 #define TRANS_COR_RELEASE		4
150 #define TRANS_COR_NO_RELEASE	8
151 
152 enum
153 {
154 	MYSQLND_FETCH_ASSOC = 1,
155 	MYSQLND_FETCH_NUM = 2,
156 	MYSQLND_FETCH_BOTH = 1|2
157 };
158 
159 /* Follow libmysql convention */
160 typedef enum func_status
161 {
162 	PASS = 0,
163 	FAIL = 1
164 } enum_func_status;
165 
166 typedef enum mysqlnd_query_type
167 {
168 	QUERY_UPSERT,
169 	QUERY_SELECT,
170 	QUERY_LOAD_LOCAL
171 } enum_mysqlnd_query_type;
172 
173 typedef enum mysqlnd_res_type
174 {
175 	MYSQLND_RES_NORMAL = 1,
176 	MYSQLND_RES_PS_BUF,
177 	MYSQLND_RES_PS_UNBUF
178 } enum_mysqlnd_res_type;
179 
180 typedef enum mysqlnd_send_execute_type
181 {
182 	MYSQLND_SEND_EXECUTE_IMPLICIT = 0,
183 	MYSQLND_SEND_EXECUTE_EXPLICIT
184 } enum_mysqlnd_send_execute_type;
185 
186 typedef enum mysqlnd_parse_exec_response_type
187 {
188 	MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT = 0,
189 	MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT_NEXT_RESULT,
190 	MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT_OUT_VARIABLES,
191 	MYSQLND_PARSE_EXEC_RESPONSE_EXPLICIT,
192 } enum_mysqlnd_parse_exec_response_type;
193 
194 typedef enum mysqlnd_client_option
195 {
196 	MYSQL_OPT_CONNECT_TIMEOUT,
197 	MYSQL_OPT_COMPRESS,
198 	MYSQL_OPT_NAMED_PIPE,
199 	MYSQL_INIT_COMMAND,
200 	MYSQL_READ_DEFAULT_FILE,
201 	MYSQL_READ_DEFAULT_GROUP,
202 	MYSQL_SET_CHARSET_DIR,
203 	MYSQL_SET_CHARSET_NAME,
204 	MYSQL_OPT_LOCAL_INFILE,
205 	MYSQL_OPT_PROTOCOL,
206 	MYSQL_SHARED_MEMORY_BASE_NAME,
207 	MYSQL_OPT_READ_TIMEOUT,
208 	MYSQL_OPT_WRITE_TIMEOUT,
209 	MYSQL_OPT_USE_RESULT,
210 	MYSQL_OPT_USE_REMOTE_CONNECTION,
211 	MYSQL_OPT_USE_EMBEDDED_CONNECTION,
212 	MYSQL_OPT_GUESS_CONNECTION,
213 	MYSQL_SET_CLIENT_IP,
214 	MYSQL_SECURE_AUTH,
215 	MYSQL_REPORT_DATA_TRUNCATION,
216 	MYSQL_OPT_RECONNECT,
217 	MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
218 	MYSQL_PLUGIN_DIR,
219 	MYSQL_DEFAULT_AUTH,
220 	MYSQL_OPT_BIND,
221 	MYSQL_OPT_SSL_KEY,
222 	MYSQL_OPT_SSL_CERT,
223 	MYSQL_OPT_SSL_CA,
224 	MYSQL_OPT_SSL_CAPATH,
225 	MYSQL_OPT_SSL_CIPHER,
226 	MYSQL_OPT_SSL_CRL,
227 	MYSQL_OPT_SSL_CRLPATH,
228 	MYSQL_OPT_CONNECT_ATTR_RESET,
229 	MYSQL_OPT_CONNECT_ATTR_ADD,
230 	MYSQL_OPT_CONNECT_ATTR_DELETE,
231 	MYSQL_SERVER_PUBLIC_KEY,
232 	MYSQL_ENABLE_CLEARTEXT_PLUGIN,
233 	MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,
234 	MYSQL_OPT_SSL_ENFORCE,
235 	MYSQL_OPT_MAX_ALLOWED_PACKET,
236 	MYSQL_OPT_NET_BUFFER_LENGTH,
237 	MYSQL_OPT_TLS_VERSION,
238 	MYSQL_OPT_SSL_MODE,
239 	MYSQL_OPT_LOAD_DATA_LOCAL_DIR,
240 	MYSQLND_DEPRECATED_ENUM1 = 200,
241 	MYSQLND_OPT_INT_AND_FLOAT_NATIVE = 201,
242 	MYSQLND_OPT_NET_CMD_BUFFER_SIZE = 202,
243 	MYSQLND_OPT_NET_READ_BUFFER_SIZE = 203,
244 	MYSQLND_OPT_SSL_KEY = 204,
245 	MYSQLND_OPT_SSL_CERT = 205,
246 	MYSQLND_OPT_SSL_CA = 206,
247 	MYSQLND_OPT_SSL_CAPATH = 207,
248 	MYSQLND_OPT_SSL_CIPHER = 208,
249 	MYSQLND_OPT_SSL_PASSPHRASE = 209,
250 	MYSQLND_OPT_MAX_ALLOWED_PACKET = 210,
251 	MYSQLND_OPT_AUTH_PROTOCOL = 211
252 } enum_mysqlnd_client_option;
253 
254 typedef enum mysqlnd_session_protocol_type
255 {
256 	MYSQL_PROTOCOL_DEFAULT = 0,
257 	MYSQL_PROTOCOL_TCP,		/* all, supported */
258 	MYSQL_PROTOCOL_SOCKET,	/* unix, supported */
259 	MYSQL_PROTOCOL_PIPE,	/* win32, not-supported */
260 	MYSQL_PROTOCOL_MEMORY,	/* win32, not-supported */
261 	MYSQL_PROTOCOL_LAST
262 } enum_mysqlnd_session_protocol_type;
263 
264 typedef enum mysqlnd_field_types
265 {
266 	MYSQL_TYPE_DECIMAL	= 0,
267 	MYSQL_TYPE_TINY		= 1,
268 	MYSQL_TYPE_SHORT	= 2,
269 	MYSQL_TYPE_LONG		= 3,
270 	MYSQL_TYPE_FLOAT	= 4,
271 	MYSQL_TYPE_DOUBLE	= 5,
272 	MYSQL_TYPE_NULL		= 6,
273 	MYSQL_TYPE_TIMESTAMP= 7,
274 	MYSQL_TYPE_LONGLONG	= 8,
275 	MYSQL_TYPE_INT24	= 9,
276 	MYSQL_TYPE_DATE		= 10,
277 	MYSQL_TYPE_TIME		= 11,
278 	MYSQL_TYPE_DATETIME	= 12,
279 	MYSQL_TYPE_YEAR		= 13,
280 	MYSQL_TYPE_NEWDATE	= 14,
281 	MYSQL_TYPE_VARCHAR	= 15,
282 	MYSQL_TYPE_BIT		= 16,
283 	MYSQL_TYPE_JSON=245,
284 	MYSQL_TYPE_NEWDECIMAL=246,
285 	MYSQL_TYPE_ENUM=247,
286 	MYSQL_TYPE_SET=248,
287 	MYSQL_TYPE_TINY_BLOB=249,
288 	MYSQL_TYPE_MEDIUM_BLOB=250,
289 	MYSQL_TYPE_LONG_BLOB=251,
290 	MYSQL_TYPE_BLOB=252,
291 	MYSQL_TYPE_VAR_STRING=253,
292 	MYSQL_TYPE_STRING=254,
293 	MYSQL_TYPE_GEOMETRY=255
294 } enum_mysqlnd_field_types;
295 
296 /* Please update this if there is a new type after MYSQL_TYPE_GEOMETRY */
297 #define MYSQL_TYPE_LAST		MYSQL_TYPE_GEOMETRY
298 
299 
300 typedef enum mysqlnd_server_option
301 {
302 	MYSQL_OPTION_MULTI_STATEMENTS_ON,
303 	MYSQL_OPTION_MULTI_STATEMENTS_OFF
304 } enum_mysqlnd_server_option;
305 
306 
307 #define FIELD_TYPE_DECIMAL		MYSQL_TYPE_DECIMAL
308 #define FIELD_TYPE_NEWDECIMAL	MYSQL_TYPE_NEWDECIMAL
309 #define FIELD_TYPE_TINY			MYSQL_TYPE_TINY
310 #define FIELD_TYPE_SHORT		MYSQL_TYPE_SHORT
311 #define FIELD_TYPE_LONG			MYSQL_TYPE_LONG
312 #define FIELD_TYPE_FLOAT		MYSQL_TYPE_FLOAT
313 #define FIELD_TYPE_DOUBLE		MYSQL_TYPE_DOUBLE
314 #define FIELD_TYPE_NULL			MYSQL_TYPE_NULL
315 #define FIELD_TYPE_TIMESTAMP	MYSQL_TYPE_TIMESTAMP
316 #define FIELD_TYPE_LONGLONG		MYSQL_TYPE_LONGLONG
317 #define FIELD_TYPE_INT24		MYSQL_TYPE_INT24
318 #define FIELD_TYPE_DATE			MYSQL_TYPE_DATE
319 #define FIELD_TYPE_TIME			MYSQL_TYPE_TIME
320 #define FIELD_TYPE_DATETIME		MYSQL_TYPE_DATETIME
321 #define FIELD_TYPE_YEAR			MYSQL_TYPE_YEAR
322 #define FIELD_TYPE_NEWDATE		MYSQL_TYPE_NEWDATE
323 #define FIELD_TYPE_ENUM			MYSQL_TYPE_ENUM
324 #define FIELD_TYPE_SET			MYSQL_TYPE_SET
325 #define FIELD_TYPE_JSON 		MYSQL_TYPE_JSON
326 #define FIELD_TYPE_TINY_BLOB	MYSQL_TYPE_TINY_BLOB
327 #define FIELD_TYPE_MEDIUM_BLOB	MYSQL_TYPE_MEDIUM_BLOB
328 #define FIELD_TYPE_LONG_BLOB	MYSQL_TYPE_LONG_BLOB
329 #define FIELD_TYPE_BLOB			MYSQL_TYPE_BLOB
330 #define FIELD_TYPE_VAR_STRING	MYSQL_TYPE_VAR_STRING
331 #define FIELD_TYPE_STRING		MYSQL_TYPE_STRING
332 #define FIELD_TYPE_CHAR			MYSQL_TYPE_TINY
333 #define FIELD_TYPE_INTERVAL		MYSQL_TYPE_ENUM
334 #define FIELD_TYPE_GEOMETRY		MYSQL_TYPE_GEOMETRY
335 #define FIELD_TYPE_BIT			MYSQL_TYPE_BIT
336 
337 #define NOT_NULL_FLAG			    1
338 #define PRI_KEY_FLAG			    2
339 #define UNIQUE_KEY_FLAG			    4
340 #define MULTIPLE_KEY_FLAG		    8
341 #define BLOB_FLAG				   16
342 #define UNSIGNED_FLAG			   32
343 #define ZEROFILL_FLAG			   64
344 #define BINARY_FLAG				  128
345 #define ENUM_FLAG				  256
346 #define AUTO_INCREMENT_FLAG		  512
347 #define TIMESTAMP_FLAG			 1024
348 #define SET_FLAG				 2048
349 #define NO_DEFAULT_VALUE_FLAG	 4096
350 #define ON_UPDATE_NOW_FLAG		 8192
351 #define PART_KEY_FLAG			16384
352 #define GROUP_FLAG				32768
353 #define NUM_FLAG				32768
354 
355 #define IS_PRI_KEY(n)	((n) & PRI_KEY_FLAG)
356 #define IS_NOT_NULL(n)	((n) & NOT_NULL_FLAG)
357 #define IS_BLOB(n)		((n) & BLOB_FLAG)
358 #define IS_NUM(t)		((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR || (t) == FIELD_TYPE_NEWDECIMAL)
359 
360 
361 /*
362 		/-----> CONN_CLOSE  <---------------\
363 		|           ^                         \
364 		|           |                         \
365 	CONN_READY -> CONN_QUERY_SENT -> CONN_FETCHING_DATA
366 		^                                      |
367 		\-------------------------------------/
368 */
369 typedef enum mysqlnd_connection_state
370 {
371 	CONN_ALLOCED = 0,
372 	CONN_READY = 1,
373 	CONN_QUERY_SENT = 2,
374 	CONN_SENDING_LOAD_DATA = 3,
375 	CONN_FETCHING_DATA = 4,
376 	CONN_NEXT_RESULT_PENDING = 5,
377 	CONN_QUIT_SENT = 6 /* object is "destroyed" at this stage */
378 } enum_mysqlnd_connection_state;
379 
380 
381 typedef enum mysqlnd_stmt_state
382 {
383 	MYSQLND_STMT_INITTED = 0,
384 	MYSQLND_STMT_PREPARED = 1,
385 	MYSQLND_STMT_EXECUTED = 2,
386 	MYSQLND_STMT_WAITING_USE_OR_STORE = 3,
387 	MYSQLND_STMT_USE_OR_STORE_CALLED = 4,
388 	MYSQLND_STMT_USER_FETCHING = 5/* fetch_row_buff or fetch_row_unbuf */
389 } enum_mysqlnd_stmt_state;
390 
391 
392 typedef enum param_bind_flags
393 {
394 	MYSQLND_PARAM_BIND_BLOB_USED = 1
395 } enum_param_bind_flags;
396 
397 
398 /* PS */
399 enum mysqlnd_stmt_attr
400 {
401 	STMT_ATTR_UPDATE_MAX_LENGTH,
402 	STMT_ATTR_CURSOR_TYPE,
403 	STMT_ATTR_PREFETCH_ROWS
404 };
405 
406 enum myslqnd_cursor_type
407 {
408 	CURSOR_TYPE_NO_CURSOR= 0,
409 	CURSOR_TYPE_READ_ONLY= 1,
410 	CURSOR_TYPE_FOR_UPDATE= 2,
411 	CURSOR_TYPE_SCROLLABLE= 4
412 };
413 
414 typedef enum mysqlnd_connection_close_type
415 {
416 	MYSQLND_CLOSE_EXPLICIT = 0,
417 	MYSQLND_CLOSE_IMPLICIT,
418 	MYSQLND_CLOSE_DISCONNECTED,
419 	MYSQLND_CLOSE_LAST	/* for checking, should always be last */
420 } enum_connection_close_type;
421 
422 
423 typedef enum mysqlnd_collected_stats
424 {
425 	STAT_BYTES_SENT,
426 	STAT_BYTES_RECEIVED,
427 	STAT_PACKETS_SENT,
428 	STAT_PACKETS_RECEIVED,
429 	STAT_PROTOCOL_OVERHEAD_IN,
430 	STAT_PROTOCOL_OVERHEAD_OUT,
431 	STAT_BYTES_RECEIVED_OK,
432 	STAT_BYTES_RECEIVED_EOF,
433 	STAT_BYTES_RECEIVED_RSET_HEADER,
434 	STAT_BYTES_RECEIVED_RSET_FIELD_META,
435 	STAT_BYTES_RECEIVED_RSET_ROW,
436 	STAT_BYTES_RECEIVED_PREPARE_RESPONSE,
437 	STAT_BYTES_RECEIVED_CHANGE_USER,
438 	STAT_PACKETS_SENT_CMD,
439 	STAT_PACKETS_RECEIVED_OK,
440 	STAT_PACKETS_RECEIVED_EOF,
441 	STAT_PACKETS_RECEIVED_RSET_HEADER,
442 	STAT_PACKETS_RECEIVED_RSET_FIELD_META,
443 	STAT_PACKETS_RECEIVED_RSET_ROW,
444 	STAT_PACKETS_RECEIVED_PREPARE_RESPONSE,
445 	STAT_PACKETS_RECEIVED_CHANGE_USER,
446 	STAT_RSET_QUERY,
447 	STAT_NON_RSET_QUERY,
448 	STAT_NO_INDEX_USED,
449 	STAT_BAD_INDEX_USED,
450 	STAT_QUERY_WAS_SLOW,
451 	STAT_BUFFERED_SETS,
452 	STAT_UNBUFFERED_SETS,
453 	STAT_PS_BUFFERED_SETS,
454 	STAT_PS_UNBUFFERED_SETS,
455 	STAT_FLUSHED_NORMAL_SETS,
456 	STAT_FLUSHED_PS_SETS,
457 	STAT_PS_PREPARED_NEVER_EXECUTED,
458 	STAT_PS_PREPARED_ONCE_USED,
459 	STAT_ROWS_FETCHED_FROM_SERVER_NORMAL,
460 	STAT_ROWS_FETCHED_FROM_SERVER_PS,
461 	STAT_ROWS_BUFFERED_FROM_CLIENT_NORMAL,
462 	STAT_ROWS_BUFFERED_FROM_CLIENT_PS,
463 	STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_BUF,
464 	STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_UNBUF,
465 	STAT_ROWS_FETCHED_FROM_CLIENT_PS_BUF,
466 	STAT_ROWS_FETCHED_FROM_CLIENT_PS_UNBUF,
467 	STAT_ROWS_FETCHED_FROM_CLIENT_PS_CURSOR,
468 	STAT_ROWS_AFFECTED_NORMAL,
469 	STAT_ROWS_AFFECTED_PS,
470 	STAT_ROWS_SKIPPED_NORMAL,
471 	STAT_ROWS_SKIPPED_PS,
472 	STAT_COPY_ON_WRITE_SAVED,
473 	STAT_COPY_ON_WRITE_PERFORMED,
474 	STAT_CMD_BUFFER_TOO_SMALL,
475 	STAT_CONNECT_SUCCESS,
476 	STAT_CONNECT_FAILURE,
477 	STAT_CONNECT_REUSED,
478 	STAT_RECONNECT,
479 	STAT_PCONNECT_SUCCESS,
480 	STAT_OPENED_CONNECTIONS,
481 	STAT_OPENED_PERSISTENT_CONNECTIONS,
482 	STAT_CLOSE_EXPLICIT,
483 	STAT_CLOSE_IMPLICIT,
484 	STAT_CLOSE_DISCONNECT,
485 	STAT_CLOSE_IN_MIDDLE,
486 	STAT_FREE_RESULT_EXPLICIT,
487 	STAT_FREE_RESULT_IMPLICIT,
488 	STAT_STMT_CLOSE_EXPLICIT,
489 	STAT_STMT_CLOSE_IMPLICIT,
490 	STAT_MEM_EMALLOC_COUNT,
491 	STAT_MEM_EMALLOC_AMOUNT,
492 	STAT_MEM_ECALLOC_COUNT,
493 	STAT_MEM_ECALLOC_AMOUNT,
494 	STAT_MEM_EREALLOC_COUNT,
495 	STAT_MEM_EREALLOC_AMOUNT,
496 	STAT_MEM_EFREE_COUNT,
497 	STAT_MEM_EFREE_AMOUNT,
498 	STAT_MEM_MALLOC_COUNT,
499 	STAT_MEM_MALLOC_AMOUNT,
500 	STAT_MEM_CALLOC_COUNT,
501 	STAT_MEM_CALLOC_AMOUNT,
502 	STAT_MEM_REALLOC_COUNT,
503 	STAT_MEM_REALLOC_AMOUNT,
504 	STAT_MEM_FREE_COUNT,
505 	STAT_MEM_FREE_AMOUNT,
506 	STAT_MEM_ESTRNDUP_COUNT,
507 	STAT_MEM_STRNDUP_COUNT,
508 	STAT_MEM_ESTRDUP_COUNT,
509 	STAT_MEM_STRDUP_COUNT,
510 	STAT_MEM_EDUP_COUNT,
511 	STAT_MEM_DUP_COUNT,
512 	STAT_TEXT_TYPE_FETCHED_NULL,
513 	STAT_TEXT_TYPE_FETCHED_BIT,
514 	STAT_TEXT_TYPE_FETCHED_INT8,
515 	STAT_TEXT_TYPE_FETCHED_INT16,
516 	STAT_TEXT_TYPE_FETCHED_INT24,
517 	STAT_TEXT_TYPE_FETCHED_INT32,
518 	STAT_TEXT_TYPE_FETCHED_INT64,
519 	STAT_TEXT_TYPE_FETCHED_DECIMAL,
520 	STAT_TEXT_TYPE_FETCHED_FLOAT,
521 	STAT_TEXT_TYPE_FETCHED_DOUBLE,
522 	STAT_TEXT_TYPE_FETCHED_DATE,
523 	STAT_TEXT_TYPE_FETCHED_YEAR,
524 	STAT_TEXT_TYPE_FETCHED_TIME,
525 	STAT_TEXT_TYPE_FETCHED_DATETIME,
526 	STAT_TEXT_TYPE_FETCHED_TIMESTAMP,
527 	STAT_TEXT_TYPE_FETCHED_STRING,
528 	STAT_TEXT_TYPE_FETCHED_JSON,
529 	STAT_TEXT_TYPE_FETCHED_BLOB,
530 	STAT_TEXT_TYPE_FETCHED_ENUM,
531 	STAT_TEXT_TYPE_FETCHED_SET,
532 	STAT_TEXT_TYPE_FETCHED_GEOMETRY,
533 	STAT_TEXT_TYPE_FETCHED_OTHER,
534 	STAT_BINARY_TYPE_FETCHED_NULL,
535 	STAT_BINARY_TYPE_FETCHED_BIT,
536 	STAT_BINARY_TYPE_FETCHED_INT8,
537 	STAT_BINARY_TYPE_FETCHED_INT16,
538 	STAT_BINARY_TYPE_FETCHED_INT24,
539 	STAT_BINARY_TYPE_FETCHED_INT32,
540 	STAT_BINARY_TYPE_FETCHED_INT64,
541 	STAT_BINARY_TYPE_FETCHED_DECIMAL,
542 	STAT_BINARY_TYPE_FETCHED_FLOAT,
543 	STAT_BINARY_TYPE_FETCHED_DOUBLE,
544 	STAT_BINARY_TYPE_FETCHED_DATE,
545 	STAT_BINARY_TYPE_FETCHED_YEAR,
546 	STAT_BINARY_TYPE_FETCHED_TIME,
547 	STAT_BINARY_TYPE_FETCHED_DATETIME,
548 	STAT_BINARY_TYPE_FETCHED_TIMESTAMP,
549 	STAT_BINARY_TYPE_FETCHED_STRING,
550 	STAT_BINARY_TYPE_FETCHED_BLOB,
551 	STAT_BINARY_TYPE_FETCHED_ENUM,
552 	STAT_BINARY_TYPE_FETCHED_SET,
553 	STAT_BINARY_TYPE_FETCHED_GEOMETRY,
554 	STAT_BINARY_TYPE_FETCHED_OTHER,
555 	STAT_INIT_COMMAND_EXECUTED_COUNT,
556 	STAT_INIT_COMMAND_FAILED_COUNT,
557 	STAT_COM_QUIT,
558 	STAT_COM_INIT_DB,
559 	STAT_COM_QUERY,
560 	STAT_COM_FIELD_LIST,
561 	STAT_COM_CREATE_DB,
562 	STAT_COM_DROP_DB,
563 	STAT_COM_REFRESH,
564 	STAT_COM_SHUTDOWN,
565 	STAT_COM_STATISTICS,
566 	STAT_COM_PROCESS_INFO,
567 	STAT_COM_CONNECT,
568 	STAT_COM_PROCESS_KILL,
569 	STAT_COM_DEBUG,
570 	STAT_COM_PING,
571 	STAT_COM_TIME,
572 	STAT_COM_DELAYED_INSERT,
573 	STAT_COM_CHANGE_USER,
574 	STAT_COM_BINLOG_DUMP,
575 	STAT_COM_TABLE_DUMP,
576 	STAT_COM_CONNECT_OUT,
577 	STAT_COM_REGISTER_SLAVE,
578 	STAT_COM_STMT_PREPARE,
579 	STAT_COM_STMT_EXECUTE,
580 	STAT_COM_STMT_SEND_LONG_DATA,
581 	STAT_COM_STMT_CLOSE,
582 	STAT_COM_STMT_RESET,
583 	STAT_COM_SET_OPTION,
584 	STAT_COM_STMT_FETCH,
585 	STAT_COM_DAEMON,
586 	STAT_BYTES_RECEIVED_PURE_DATA_TEXT,
587 	STAT_BYTES_RECEIVED_PURE_DATA_PS,
588 	STAT_LAST /* Should be always the last */
589 } enum_mysqlnd_collected_stats;
590 
591 
592 /* Enums */
593 enum mysqlnd_packet_type
594 {
595 	PROT_GREET_PACKET= 0,
596 	PROT_AUTH_PACKET,
597 	PROT_AUTH_RESP_PACKET,
598 	PROT_CHANGE_AUTH_RESP_PACKET,
599 	PROT_OK_PACKET,
600 	PROT_EOF_PACKET,
601 	PROT_CMD_PACKET,
602 	PROT_RSET_HEADER_PACKET,
603 	PROT_RSET_FLD_PACKET,
604 	PROT_ROW_PACKET,
605 	PROT_STATS_PACKET,
606 	PROT_PREPARE_RESP_PACKET,
607 	PROT_CHG_USER_RESP_PACKET,
608 	PROT_SHA256_PK_REQUEST_PACKET,
609 	PROT_SHA256_PK_REQUEST_RESPONSE_PACKET,
610 	PROT_CACHED_SHA2_RESULT_PACKET,
611 	PROT_LAST /* should always be last */
612 };
613 
614 
615 /*
616   After adding new elements please update
617   `mysqlnd_command_to_text` in mysqlnd_wireprotocol.c
618 */
619 enum php_mysqlnd_server_command
620 {
621 	COM_SLEEP = 0,
622 	COM_QUIT,
623 	COM_INIT_DB,
624 	COM_QUERY,
625 	COM_FIELD_LIST,
626 	COM_CREATE_DB,
627 	COM_DROP_DB,
628 	COM_REFRESH,
629 	COM_SHUTDOWN,
630 	COM_STATISTICS,
631 	COM_PROCESS_INFO,
632 	COM_CONNECT,
633 	COM_PROCESS_KILL,
634 	COM_DEBUG,
635 	COM_PING,
636 	COM_TIME = 15,
637 	COM_DELAYED_INSERT,
638 	COM_CHANGE_USER,
639 	COM_BINLOG_DUMP,
640 	COM_TABLE_DUMP,
641 	COM_CONNECT_OUT = 20,
642 	COM_REGISTER_SLAVE,
643 	COM_STMT_PREPARE = 22,
644 	COM_STMT_EXECUTE = 23,
645 	COM_STMT_SEND_LONG_DATA = 24,
646 	COM_STMT_CLOSE = 25,
647 	COM_STMT_RESET = 26,
648 	COM_SET_OPTION = 27,
649 	COM_STMT_FETCH = 28,
650 	COM_DAEMON = 29,
651 	COM_BINLOG_DUMP_GTID = 30,
652 	COM_RESET_CONNECTION = 31,
653 	COM_STMT_EXECUTE_BATCH = 32,
654 	COM_END,
655 	/* Here follow own, non-protocol, commands */
656 	COM_REAP_RESULT=240,	/* own command */
657 	COM_ENABLE_SSL,			/* own command */
658 	COM_HANDSHAKE,			/* own command */
659 };
660 
661 
662 #define MYSQLND_DEFAULT_PREFETCH_ROWS (zend_ulong) 1
663 
664 #define MYSQLND_REFRESH_GRANT		1	/* Refresh grant tables */
665 #define MYSQLND_REFRESH_LOG			2	/* Start on new log file */
666 #define MYSQLND_REFRESH_TABLES		4	/* close all tables */
667 #define MYSQLND_REFRESH_HOSTS		8	/* Flush host cache */
668 #define MYSQLND_REFRESH_STATUS		16	/* Flush status variables */
669 #define MYSQLND_REFRESH_THREADS		32	/* Flush thread cache */
670 #define MYSQLND_REFRESH_REPLICA		64	/* Reset master info and restart replica */
671 #define MYSQLND_REFRESH_SLAVE		MYSQLND_REFRESH_REPLICA	/* temporarily for backward compatibility */
672 #define MYSQLND_REFRESH_MASTER		128	/* Remove all bin logs in the index */
673 #define MYSQLND_REFRESH_BACKUP_LOG	0x200000L
674 
675 
676 #define MYSQLND_CLIENT_NO_FLAG				0
677 
678 #endif	/* MYSQLND_ENUM_N_DEF_H */
679