MySQL 26.10.0
Source Code Documentation
mysql_com.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 Without limiting anything contained in the foregoing, this file,
16 which is part of C Driver for MySQL (Connector/C), is also subject to the
17 Universal FOSS Exception, version 1.0, a copy of which can be found at
18 http://oss.oracle.com/licenses/universal-foss-exception.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License, version 2.0, for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
28
29/**
30 @file include/mysql_com.h
31 Common definition between mysql server & client.
32*/
33
34#ifndef _mysql_com_h
35#define _mysql_com_h
36
37#ifndef MYSQL_ABI_CHECK
38#include <stdbool.h>
39#include <stdint.h>
40#endif
41
42#include "my_command.h"
43#include "my_compress.h"
44
45/*
46 We need a definition for my_socket. On the client, <mysql.h> already provides
47 it, but on the server side, we need to get it from a header.
48*/
49#ifndef my_socket_defined
50#include "my_io.h"
52#endif
53
54#ifndef MYSQL_ABI_CHECK
55#include <stdbool.h>
56#endif
57
58#define SYSTEM_CHARSET_MBMAXLEN 3
59#define FILENAME_CHARSET_MBMAXLEN 5
60#define NAME_CHAR_LEN 64 /**< Field/table name length */
61#define PARTITION_EXPR_CHAR_LEN \
62 2048 /**< Maximum expression length in chars \
63 */
64#define USERNAME_CHAR_LENGTH 32
65#define USERNAME_CHAR_LENGTH_STR "32"
66#ifndef NAME_LEN
67#define NAME_LEN (NAME_CHAR_LEN * SYSTEM_CHARSET_MBMAXLEN)
68#endif
69#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH * SYSTEM_CHARSET_MBMAXLEN)
70#define CONNECT_STRING_MAXLEN 1024
71
72#define MYSQL_AUTODETECT_CHARSET_NAME "auto"
73
74#define SERVER_VERSION_LENGTH 60
75#define SQLSTATE_LENGTH 5
76
77/*
78 In FIDO terminology, relying party is the server where required services are
79 running. Relying party ID is unique name given to server.
80*/
81#define RELYING_PARTY_ID_LENGTH 255
82
83/* Length of random salt sent during fido registration */
84#define CHALLENGE_LENGTH 32
85
86/* Maximum authentication factors server supports */
87#define MAX_AUTH_FACTORS 3
88/**
89 Maximum length of comments
90
91 pre 5.6: 60 characters
92*/
93#define TABLE_COMMENT_INLINE_MAXLEN 180
94#define TABLE_COMMENT_MAXLEN 2048
95#define COLUMN_COMMENT_MAXLEN 1024
96#define INDEX_COMMENT_MAXLEN 1024
97#define TABLE_PARTITION_COMMENT_MAXLEN 1024
98#define TABLESPACE_COMMENT_MAXLEN 2048
99
100/**
101 Maximum length of protocol packet.
102 @ref page_protocol_basic_ok_packet length limit also restricted to this value
103 as any length greater than this value will have first byte of
104 @ref page_protocol_basic_ok_packet to be 254 thus does not
105 provide a means to identify if this is @ref page_protocol_basic_ok_packet or
106 @ref page_protocol_basic_eof_packet.
107*/
108#define MAX_PACKET_LENGTH (256L * 256L * 256L - 1)
109
110#define LOCAL_HOST "localhost"
111#define LOCAL_HOST_NAMEDPIPE "."
112
113#if defined(_WIN32)
114#define MYSQL_NAMEDPIPE "MySQL"
115#define MYSQL_SERVICENAME "MySQL"
116#endif /* _WIN32 */
117
118/** The length of the header part for each generated column in the .frm file.*/
119#define FRM_GCOL_HEADER_SIZE 4
120/**
121 Maximum length of the expression statement defined for generated columns.
122*/
123#define GENERATED_COLUMN_EXPRESSION_MAXLEN 65535 - FRM_GCOL_HEADER_SIZE
124/**
125 Length of random string sent by server on handshake; this is also length of
126 obfuscated password, received from client
127*/
128#define SCRAMBLE_LENGTH 20
129#define AUTH_PLUGIN_DATA_PART_1_LENGTH 8
130/** length of password stored in the db: new passwords are preceded with '*'*/
131#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH * 2 + 1)
132
133/**
134 @defgroup group_cs_column_definition_flags Column Definition Flags
135 @ingroup group_cs
136
137 @brief Values for the flags bitmask used by ::Send_field:flags
138
139 Currently need to fit into 32 bits.
140
141 Each bit represents an optional feature of the protocol.
142
143 Both the client and the server are sending these.
144
145 The intersection of the two determines what optional parts of the
146 protocol will be used.
147*/
148
149/**
150 @addtogroup group_cs_column_definition_flags
151 @{
152*/
153
154#define NOT_NULL_FLAG 1 /**< Field can't be NULL */
155#define PRI_KEY_FLAG 2 /**< Field is part of a primary key */
156#define UNIQUE_KEY_FLAG 4 /**< Field is part of a unique key */
157#define MULTIPLE_KEY_FLAG 8 /**< Field is part of a key */
158#define BLOB_FLAG 16 /**< Field is a blob */
159#define UNSIGNED_FLAG 32 /**< Field is unsigned */
160#define ZEROFILL_FLAG 64 /**< Field is zerofill */
161#define BINARY_FLAG 128 /**< Field is binary */
162
163/* The following are only sent to new clients */
164#define ENUM_FLAG 256 /**< field is an enum */
165#define AUTO_INCREMENT_FLAG 512 /**< field is a autoincrement field */
166#define TIMESTAMP_FLAG 1024 /**< Field is a timestamp */
167#define SET_FLAG 2048 /**< field is a set */
168#define NO_DEFAULT_VALUE_FLAG 4096 /**< Field doesn't have default value */
169#define ON_UPDATE_NOW_FLAG 8192 /**< Field is set to NOW on UPDATE */
170#define PART_KEY_FLAG 16384 /**< Intern; Part of some key */
171#define NUM_FLAG 32768 /**< Field is num (for clients) */
172#define UNIQUE_FLAG 65536 /**< Intern: Used by sql_yacc */
173#define BINCMP_FLAG 131072 /**< Intern: Used by sql_yacc */
174#define GET_FIXED_FIELDS_FLAG \
175 (1 << 18) /**< Used to get fields in item tree \
176 */
177#define FIELD_IN_PART_FUNC_FLAG (1 << 19) /**< Field part of partition func */
178/**
179 Intern: Field in TABLE object for new version of altered table,
180 which participates in a newly added index.
181*/
182#define FIELD_IN_ADD_INDEX (1 << 20)
183#define FIELD_IS_RENAMED (1 << 21) /**< Intern: Field is being renamed */
184#define FIELD_FLAGS_STORAGE_MEDIA 22 /**< Field storage media, bit 22-23 */
185#define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA)
186#define FIELD_FLAGS_COLUMN_FORMAT 24 /**< Field column format, bit 24-25 */
187#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
188#define FIELD_IS_DROPPED (1 << 26) /**< Intern: Field is being dropped */
189#define EXPLICIT_NULL_FLAG \
190 (1 << 27) /**< Field is explicitly specified as \
191 NULL by the user */
192#define GROUP_FLAG \
193 (1 << 28) /**< Intern: Group field. Transient use in \
194 create_tmp_table */
195
196/** Field will not be loaded in secondary engine. */
197#define NOT_SECONDARY_FLAG (1 << 29)
198/** Field is explicitly marked as invisible by the user. */
199#define FIELD_IS_INVISIBLE (1 << 30)
200
201/** @}*/
202
203/**
204 @defgroup group_cs_com_refresh_flags COM_REFRESH Flags
205 @ingroup group_cs
206
207 @brief Values for the `sub_command` in ::COM_REFRESH
208
209 Currently the protocol carries only 8 bits of these flags.
210
211 The rest (8-end) are used only internally in the server.
212*/
213
214/**
215 @addtogroup group_cs_com_refresh_flags
216 @{
217*/
218
219#define REFRESH_GRANT 1 /**< Refresh grant tables, FLUSH PRIVILEGES */
220#define REFRESH_LOG 2 /**< Start on new log file, FLUSH LOGS */
221#define REFRESH_TABLES 4 /**< close all tables, FLUSH TABLES */
222#define UNUSED_8 \
223 8 /**< Previously REFRESH_HOSTS but not used anymore. Use TRUNCATE TABLE \
224 performance_schema.host_cache instead */
225#define REFRESH_STATUS 16 /**< Flush status variables, FLUSH STATUS */
226#define UNUSED_32 32 /**< Removed. Used to be flush thread cache */
227#define REFRESH_REPLICA \
228 64 /**< Reset source info and restart replica \
229 thread, RESET REPLICA */
230
231#define REFRESH_SOURCE \
232 128 /**< Remove all bin logs in the index \
233 and truncate the index. Also resets \
234 GTID information. Command: \
235 RESET BINARY LOGS AND GTIDS */
236
237#define REFRESH_ERROR_LOG 256 /**< Rotate only the error log */
238#define REFRESH_ENGINE_LOG 512 /**< Flush all storage engine logs */
239#define REFRESH_BINARY_LOG 1024 /**< Flush the binary log */
240#define REFRESH_RELAY_LOG 2048 /**< Flush the relay log */
241#define REFRESH_GENERAL_LOG 4096 /**< Flush the general log */
242#define REFRESH_SLOW_LOG 8192 /**< Flush the slow query log */
243#define REFRESH_READ_LOCK 16384 /**< Lock tables for read. */
244/**
245 Wait for an impending flush before closing the tables.
246
247 @sa REFRESH_READ_LOCK, handle_reload_request, close_cached_tables
248*/
249#define REFRESH_FAST 32768
250#define REFRESH_USER_RESOURCES \
251 0x80000L /** FLUSH RESOURCES. @sa ::reset_mqh \
252 */
253#define REFRESH_FOR_EXPORT 0x100000L /** FLUSH TABLES ... FOR EXPORT */
254#define REFRESH_OPTIMIZER_COSTS 0x200000L /** FLUSH OPTIMIZER_COSTS */
255#define REFRESH_PERSIST 0x400000L /** RESET PERSIST */
256
257/** @}*/
258
259/**
260 @defgroup group_cs_capabilities_flags Capabilities Flags
261 @ingroup group_cs
262
263 @brief Values for the capabilities flag bitmask used by the MySQL protocol
264
265 Currently need to fit into 32 bits.
266
267 Each bit represents an optional feature of the protocol.
268
269 Both the client and the server are sending these.
270
271 The intersection of the two determines whast optional parts of the
272 protocol will be used.
273*/
274
275/**
276 @addtogroup group_cs_capabilities_flags
277 @{
278*/
279
280/**
281 Use the improved version of Old Password Authentication.
282
283 Not used.
284
285 @note Assumed to be set since 4.1.1.
287#define CLIENT_LONG_PASSWORD 1
288/**
289 Send found rows instead of affected rows in @ref
290 page_protocol_basic_eof_packet
292#define CLIENT_FOUND_ROWS 2
293/**
294 @brief Get all column flags
295
296 Longer flags in Protocol::ColumnDefinition320.
297
298 @todo Reference Protocol::ColumnDefinition320
299
300 Server
301 ------
302
303 Supports longer flags.
304
305 Client
306 ------
307
308 Expects longer flags.
310#define CLIENT_LONG_FLAG 4
311/**
312 Database (schema) name can be specified on connect in Handshake Response
313 Packet.
314
315 @todo Reference Handshake Response Packet.
316
317 Server
318 ------
319
320 Supports schema-name in Handshake Response Packet.
321
322 Client
323 ------
324
325 Handshake Response Packet contains a schema-name.
326
327 @sa send_client_reply_packet()
329#define CLIENT_CONNECT_WITH_DB 8
330#define CLIENT_NO_SCHEMA \
331 16 /**< DEPRECATED: Don't allow database.table.column */
332/**
333 Compression protocol supported.
334
335 @todo Reference Compression
336
337 Server
338 ------
339
340 Supports compression.
341
342 Client
343 ------
344
345 Switches to Compression compressed protocol after successful authentication.
347#define CLIENT_COMPRESS 32
348/**
349 Special handling of ODBC behavior.
350
351 @note No special behavior since 3.22.
353#define CLIENT_ODBC 64
354/**
355 Can use LOAD DATA LOCAL.
356
357 Server
358 ------
359
360 Enables the LOCAL INFILE request of LOAD DATA|XML.
361
362 Client
363 ------
364
365 Will handle LOCAL INFILE request.
367#define CLIENT_LOCAL_FILES 128
368/**
369 Ignore spaces before '('
370
371 Server
372 ------
373
374 Parser can ignore spaces before '('.
375
376 Client
377 ------
378
379 Let the parser ignore spaces before '('.
381#define CLIENT_IGNORE_SPACE 256
382/**
383 New 4.1 protocol
384
385 @todo Reference the new 4.1 protocol
386
387 Server
388 ------
389
390 Supports the 4.1 protocol.
391
392 Client
393 ------
394
395 Uses the 4.1 protocol.
396
397 @note this value was CLIENT_CHANGE_USER in 3.22, unused in 4.0
399#define CLIENT_PROTOCOL_41 512
400/**
401 This is an interactive client
402
403 Use @ref System_variables::net_wait_timeout
404 versus @ref System_variables::net_interactive_timeout.
405
406 Server
407 ------
408
409 Supports interactive and noninteractive clients.
410
411 Client
412 ------
413
414 Client is interactive.
415
416 @sa mysql_real_connect()
418#define CLIENT_INTERACTIVE 1024
419/**
420 Use SSL encryption for the session
421
422 @todo Reference SSL
423
424 Server
425 ------
426
427 Supports SSL
428
429 Client
430 ------
431
432 Switch to SSL after sending the capability-flags.
434#define CLIENT_SSL 2048
435/**
436 Client only flag. Not used.
437
438 Client
439 ------
440
441 Do not issue SIGPIPE if network failures occur (libmysqlclient only).
442
443 @sa mysql_real_connect()
445#define CLIENT_IGNORE_SIGPIPE 4096
446/**
447 Client knows about transactions
448
449 Server
450 ------
451
452 Can send status flags in @ref page_protocol_basic_ok_packet /
453 @ref page_protocol_basic_eof_packet.
454
455 Client
456 ------
457
458 Expects status flags in @ref page_protocol_basic_ok_packet /
459 @ref page_protocol_basic_eof_packet.
460
461 @note This flag is optional in 3.23, but always set by the server since 4.0.
462 @sa send_server_handshake_packet(), parse_client_handshake_packet(),
463 net_send_ok(), net_send_eof()
465#define CLIENT_TRANSACTIONS 8192
466#define CLIENT_RESERVED 16384 /**< DEPRECATED: Old flag for 4.1 protocol */
467#define CLIENT_RESERVED2 \
468 32768 /**< DEPRECATED: Old flag for 4.1 authentication \
469 CLIENT_SECURE_CONNECTION */
470/**
471 Enable/disable multi-stmt support
472
473 Also sets @ref CLIENT_MULTI_RESULTS. Currently not checked anywhere.
474
475 Server
476 ------
477
478 Can handle multiple statements per COM_QUERY and COM_STMT_PREPARE.
479
480 Client
481 -------
482
483 May send multiple statements per COM_QUERY and COM_STMT_PREPARE.
484
485 @note Was named ::CLIENT_MULTI_QUERIES in 4.1.0, renamed later.
486
487 Requires
488 --------
489
490 ::CLIENT_PROTOCOL_41
491
492 @todo Reference COM_QUERY and COM_STMT_PREPARE
494#define CLIENT_MULTI_STATEMENTS (1UL << 16)
495/**
496 Enable/disable multi-results
497
498 Server
499 ------
500
501 Can send multiple resultsets for COM_QUERY.
502 Error if the server needs to send them and client
503 does not support them.
504
505 Client
506 -------
507
508 Can handle multiple resultsets for COM_QUERY.
509
510 Requires
511 --------
512
513 ::CLIENT_PROTOCOL_41
514
515 @sa mysql_execute_command(), sp_head::MULTI_RESULTS
517#define CLIENT_MULTI_RESULTS (1UL << 17)
518/**
519 Multi-results and OUT parameters in PS-protocol.
520
521 Server
522 ------
523
524 Can send multiple resultsets for COM_STMT_EXECUTE.
525
526 Client
527 ------
528
529 Can handle multiple resultsets for COM_STMT_EXECUTE.
530
531 Requires
532 --------
533
534 ::CLIENT_PROTOCOL_41
535
536 @todo Reference COM_STMT_EXECUTE and PS-protocol
537
538 @sa Protocol_binary::send_out_parameters
540#define CLIENT_PS_MULTI_RESULTS (1UL << 18)
541
542/**
543 Client supports plugin authentication
544
545 Server
546 ------
547
548 Sends extra data in Initial Handshake Packet and supports the pluggable
549 authentication protocol.
550
551 Client
552 ------
553
554 Supports authentication plugins.
555
556 Requires
557 --------
558
559 ::CLIENT_PROTOCOL_41
560
561 @todo Reference plugin authentication, Initial Handshake Packet,
562 Authentication plugins
563
564 @sa send_change_user_packet(), send_client_reply_packet(), run_plugin_auth(),
565 parse_com_change_user_packet(), parse_client_handshake_packet()
567#define CLIENT_PLUGIN_AUTH (1UL << 19)
568/**
569 Client supports connection attributes
570
571 Server
572 ------
573
574 Permits connection attributes in Protocol::HandshakeResponse41.
575
576 Client
577 ------
578
579 Sends connection attributes in Protocol::HandshakeResponse41.
580
581 @todo Reference Protocol::HandshakeResponse41
582
583 @sa send_client_connect_attrs(), read_client_connect_attrs()
585#define CLIENT_CONNECT_ATTRS (1UL << 20)
586
587/**
588 Enable authentication response packet to be larger than 255 bytes.
589
590 When the ability to change default plugin require that the initial password
591 field in the Protocol::HandshakeResponse41 paclet can be of arbitrary size.
592 However, the 4.1 client-server protocol limits the length of the
593 auth-data-field sent from client to server to 255 bytes.
594 The solution is to change the type of the field to a true length encoded
595 string and indicate the protocol change
596 with this client capability flag.
597
598 Server
599 ------
600
601 Understands length-encoded integer for auth response data in
602 Protocol::HandshakeResponse41.
603
604 Client
605 ------
606
607 Length of auth response data in Protocol::HandshakeResponse41
608 is a length-encoded integer.
609
610 @todo Reference Protocol::HandshakeResponse41
611
612 @note The flag was introduced in 5.6.6, but had the wrong value.
613
614 @sa send_client_reply_packet(), parse_client_handshake_packet(),
615 get_56_lenc_string(), get_41_lenc_string()
617#define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21)
618
619/**
620 Don't close the connection for a user account with expired password.
621
622 Server
623 ------
624
625 Announces support for expired password extension.
626
627 Client
628 ------
629
630 Can handle expired passwords.
631
632 @todo Reference expired password
633
634 @sa MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, disconnect_on_expired_password
635 ACL_USER::password_expired, check_password_lifetime(), acl_authenticate()
637#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22)
638
639/**
640 Capable of handling server state change information. Its a hint to the
641 server to include the state change information in
642 @ref page_protocol_basic_ok_packet.
643
644 Server
645 ------
646 Can set ::SERVER_SESSION_STATE_CHANGED in the ::SERVER_STATUS_flags_enum
647 and send @ref sect_protocol_basic_ok_packet_sessinfo in a
648 @ref page_protocol_basic_ok_packet.
649
650 Client
651 ------
652
653 Expects the server to send @ref sect_protocol_basic_ok_packet_sessinfo in
654 a @ref page_protocol_basic_ok_packet.
655
656 @sa enum_session_state_type, read_ok_ex(), net_send_ok(), Session_tracker,
657 State_tracker
659#define CLIENT_SESSION_TRACK (1UL << 23)
660/**
661 Client no longer needs @ref page_protocol_basic_eof_packet and will
662 use @ref page_protocol_basic_ok_packet instead.
663 @sa net_send_ok()
664
665 Server
666 ------
667
668 Can send OK after a Text Resultset.
669
670 Client
671 ------
672
673 Expects an @ref page_protocol_basic_ok_packet (instead of
674 @ref page_protocol_basic_eof_packet) after the resultset rows of a
675 Text Resultset.
676
677 Background
678 ----------
679
680 To support ::CLIENT_SESSION_TRACK, additional information must be sent after
681 all successful commands. Although the @ref page_protocol_basic_ok_packet is
682 extensible, the @ref page_protocol_basic_eof_packet is not due to the overlap
683 of its bytes with the content of the Text Resultset Row.
684
685 Therefore, the @ref page_protocol_basic_eof_packet in the
686 Text Resultset is replaced with an @ref page_protocol_basic_ok_packet.
687 @ref page_protocol_basic_eof_packet is deprecated as of MySQL 5.7.5.
688
689 @todo Reference Text Resultset
690
691 @sa cli_safe_read_with_ok(), read_ok_ex(), net_send_ok(), net_send_eof()
693#define CLIENT_DEPRECATE_EOF (1UL << 24)
694
695/**
696 The client can handle optional metadata information in the resultset.
698#define CLIENT_OPTIONAL_RESULTSET_METADATA (1UL << 25)
699
700/**
701 Compression protocol extended to support zstd compression method
702
703 This capability flag is used to send zstd compression level between
704 client and server provided both client and server are enabled with
705 this flag.
706
707 Server
708 ------
709 Server sets this flag when global variable protocol-compression-algorithms
710 has zstd in its list of supported values.
711
712 Client
713 ------
714 Client sets this flag when it is configured to use zstd compression method.
715
717#define CLIENT_ZSTD_COMPRESSION_ALGORITHM (1UL << 26)
718
719/**
720 Support optional extension for query parameters into the @ref
721 page_protocol_com_query and @ref page_protocol_com_stmt_execute packets.
722
723 Server
724 ------
725
726 Expects an optional part containing the query parameter set(s). Executes the
727 query for each set of parameters or returns an error if more than 1 set of
728 parameters is sent and the server can't execute it.
729
730 Client
731 ------
732
733 Can send the optional part containing the query parameter set(s).
735#define CLIENT_QUERY_ATTRIBUTES (1UL << 27)
736
737/**
738 Support Multi factor authentication.
739
740 Server
741 ------
742 Server sends AuthNextFactor packet after every nth factor authentication
743 method succeeds, except the last factor authentication.
744
745 Client
746 ------
747 Client reads AuthNextFactor packet sent by server and initiates next factor
748 authentication method.
750#define MULTI_FACTOR_AUTHENTICATION (1UL << 28)
751
752/**
753 This flag is reserved to extend the 32bit capabilities structure to
754 64bits.
756#define CLIENT_CAPABILITY_EXTENSION (1UL << 29)
757
758/**
759 Verify server certificate.
760
761 Client only flag.
762
763 @deprecated in favor of --ssl-mode.
765#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
766
767/**
768 Don't reset the options after an unsuccessful connect
769
770 Client only flag.
771
772 Typically passed via ::mysql_real_connect() 's client_flag parameter.
773
774 @sa mysql_real_connect()
776#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
777/** @}*/
778
779/** a compatibility alias for CLIENT_COMPRESS */
780#define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
781
782/** Gather all possible capabilities (flags) supported by the client and/or
783 * server */
784#define CLIENT_ALL_FLAGS \
785 (CLIENT_LONG_PASSWORD | CLIENT_FOUND_ROWS | CLIENT_LONG_FLAG | \
786 CLIENT_CONNECT_WITH_DB | CLIENT_NO_SCHEMA | CLIENT_COMPRESS | CLIENT_ODBC | \
787 CLIENT_LOCAL_FILES | CLIENT_IGNORE_SPACE | CLIENT_PROTOCOL_41 | \
788 CLIENT_INTERACTIVE | CLIENT_SSL | CLIENT_IGNORE_SIGPIPE | \
789 CLIENT_TRANSACTIONS | CLIENT_RESERVED | CLIENT_RESERVED2 | \
790 CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS | CLIENT_PS_MULTI_RESULTS | \
791 CLIENT_SSL_VERIFY_SERVER_CERT | CLIENT_REMEMBER_OPTIONS | \
792 CLIENT_PLUGIN_AUTH | CLIENT_CONNECT_ATTRS | \
793 CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \
794 CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS | CLIENT_SESSION_TRACK | \
795 CLIENT_DEPRECATE_EOF | CLIENT_OPTIONAL_RESULTSET_METADATA | \
796 CLIENT_ZSTD_COMPRESSION_ALGORITHM | CLIENT_QUERY_ATTRIBUTES | \
797 MULTI_FACTOR_AUTHENTICATION)
798
799/** Flags only supported by the client. */
800#define CLIENT_ONLY_ALL_FLAGS \
801 (CLIENT_IGNORE_SIGPIPE | CLIENT_SSL_VERIFY_SERVER_CERT | \
802 CLIENT_REMEMBER_OPTIONS)
803
804/**
805 Switch off from ::CLIENT_ALL_FLAGS the flags that are optional and
806 depending on build flags.
807 If any of the optional flags is supported by the build it will be switched
808 on before sending to the client during the connection handshake.
810#define CLIENT_BASIC_FLAGS \
811 (CLIENT_ALL_FLAGS & \
812 ~(CLIENT_SSL | CLIENT_COMPRESS | CLIENT_SSL_VERIFY_SERVER_CERT | \
813 CLIENT_ZSTD_COMPRESSION_ALGORITHM))
814
815/** The status flags are a bit-field */
817 /**
818 Is raised when a multi-statement transaction
819 has been started, either explicitly, by means
820 of BEGIN or COMMIT AND CHAIN, or
821 implicitly, by the first transactional
822 statement, when autocommit=off.
823 */
825 SERVER_STATUS_AUTOCOMMIT = 2, /**< Server in auto_commit mode */
826 SERVER_MORE_RESULTS_EXISTS = 8, /**< Multi query - next query exists */
829 /**
830 The server was able to fulfill the clients request and opened a
831 read-only non-scrollable cursor for a query. This flag comes
832 in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
833 Used by Binary Protocol Resultset to signal that COM_STMT_FETCH
834 must be used to fetch the row-data.
835 @todo Refify "Binary Protocol Resultset" and "COM_STMT_FETCH".
836 */
838 /**
839 This flag is sent when a read-only cursor is exhausted, in reply to
840 COM_STMT_FETCH command.
841 */
843 SERVER_STATUS_DB_DROPPED = 256, /**< A database was dropped */
845 /**
846 Sent to the client if after a prepared statement reprepare
847 we discovered that the new statement returns a different
848 number of result set columns.
849 */
852 /**
853 To mark ResultSet containing output parameter values.
854 */
856
857 /**
858 Set at the same time as SERVER_STATUS_IN_TRANS if the started
859 multi-statement transaction is a read-only transaction. Cleared
860 when the transaction commits or aborts. Since this flag is sent
861 to clients in OK and EOF packets, the flag indicates the
862 transaction status at the end of command execution.
863 */
865
866 /**
867 This status flag, when on, implies that one of the state information has
868 changed on the server because of the execution of the last statement.
869 */
871};
872
873/**
874 Server status flags that must be cleared when starting
875 execution of a new SQL statement.
876 Flags from this set are only added to the
877 current server status by the execution engine, but
878 never removed -- the execution engine expects them
879 to disappear automagically by the next command.
881#define SERVER_STATUS_CLEAR_SET \
882 (SERVER_QUERY_NO_GOOD_INDEX_USED | SERVER_QUERY_NO_INDEX_USED | \
883 SERVER_MORE_RESULTS_EXISTS | SERVER_STATUS_METADATA_CHANGED | \
884 SERVER_QUERY_WAS_SLOW | SERVER_STATUS_DB_DROPPED | \
885 SERVER_STATUS_CURSOR_EXISTS | SERVER_STATUS_LAST_ROW_SENT | \
886 SERVER_SESSION_STATE_CHANGED)
887
888/** Max length of a error message. Should be kept in sync with ::ERRMSGSIZE. */
889#define MYSQL_ERRMSG_SIZE 512
890#define NET_READ_TIMEOUT 30 /**< Timeout on read */
891#define NET_WRITE_TIMEOUT 60 /**< Timeout on write */
892#define NET_WAIT_TIMEOUT 8 * 60 * 60 /**< Wait for new query */
893
894/**
895 Flag used by the parser. Kill only the query and not the connection.
896
897 @sa SQLCOM_KILL, sql_kill(), LEX::type
899#define ONLY_KILL_QUERY 1
900
901#ifndef MYSQL_VIO
902struct Vio;
903#define MYSQL_VIO struct Vio *
904#endif
906#define MAX_TINYINT_WIDTH 3 /**< Max width for a TINY w.o. sign */
907#define MAX_SMALLINT_WIDTH 5 /**< Max width for a SHORT w.o. sign */
908#define MAX_MEDIUMINT_WIDTH 8 /**< Max width for a INT24 w.o. sign */
909#define MAX_INT_WIDTH 10 /**< Max width for a LONG w.o. sign */
910#define MAX_BIGINT_WIDTH 20 /**< Max width for a LONGLONG */
911/// Max width for a CHAR column, in number of characters
912#define MAX_CHAR_WIDTH 255
913/// Default width for blob in bytes @todo - align this with sizes from field.h
914#define MAX_BLOB_WIDTH 16777216
916#define NET_ERROR_UNSET 0 /**< No error has occurred yet */
917#define NET_ERROR_SOCKET_RECOVERABLE 1 /**< Socket still usable */
918#define NET_ERROR_SOCKET_UNUSABLE 2 /**< Do not use the socket */
919#define NET_ERROR_SOCKET_NOT_READABLE 3 /**< Try write and close socket */
920#define NET_ERROR_SOCKET_NOT_WRITABLE 4 /**< Try read and close socket */
922typedef struct NET {
924 unsigned char *buff, *buff_end, *write_pos, *read_pos;
925 my_socket fd; /* For Perl DBI/dbd */
926 /**
927 Set if we are doing several queries in one
928 command ( as in LOAD TABLE ... FROM MASTER ),
929 and do not want to confuse the client with OK at the wrong time
930 */
933 unsigned int pkt_nr, compress_pkt_nr;
935 int fcntl;
936 unsigned int *return_status;
937 unsigned char reading_or_writing;
938 unsigned char save_char;
940 unsigned int last_errno;
941 unsigned char error;
942 /** Client library error message buffer. Actually belongs to struct MYSQL. */
944 /** Client library sqlstate buffer. Set along with the error message. */
945 char sqlstate[SQLSTATE_LENGTH + 1];
946 /**
947 Extension pointer, for the caller private use.
948 Any program linking with the networking library can use this pointer,
949 which is handy when private connection specific data needs to be
950 maintained.
951 The mysqld server process uses this pointer internally,
952 to maintain the server internal instrumentation for the connection.
953 */
955} NET;
957#define packet_error (~(unsigned long)0)
958
959/**
960 @addtogroup group_cs_backward_compatibility Backward compatibility
961 @ingroup group_cs
962 @{
964#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
965#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
966#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
967#define FIELD_TYPE_TINY MYSQL_TYPE_TINY
968#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
969#define FIELD_TYPE_LONG MYSQL_TYPE_LONG
970#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
971#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
972#define FIELD_TYPE_NULL MYSQL_TYPE_NULL
973#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
974#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
975#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
976#define FIELD_TYPE_DATE MYSQL_TYPE_DATE
977#define FIELD_TYPE_TIME MYSQL_TYPE_TIME
978#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
979#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
980#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
981#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
982#define FIELD_TYPE_SET MYSQL_TYPE_SET
983#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
984#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
985#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
986#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
987#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
988#define FIELD_TYPE_STRING MYSQL_TYPE_STRING
989#define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
990#define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
991#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
992#define FIELD_TYPE_BIT MYSQL_TYPE_BIT
993/** @}*/
994
995/**
996 @addtogroup group_cs_shutdown_kill_constants Shutdown/kill enums and constants
997 @ingroup group_cs
998
999 @sa THD::is_killable
1000 @{
1002#define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
1003#define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
1004#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
1005#define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
1006
1007/**
1008 We want levels to be in growing order of hardness (because we use number
1009 comparisons).
1010
1011 @note ::SHUTDOWN_DEFAULT does not respect the growing property, but it's ok.
1014 SHUTDOWN_DEFAULT = 0,
1015 /** Wait for existing connections to finish */
1017 /** Wait for existing transactons to finish */
1019 /** Wait for existing updates to finish (=> no partial MyISAM update) */
1021 /** Flush InnoDB buffers and other storage engines' buffers*/
1023 /** Don't flush InnoDB buffers, flush other storage engines' buffers*/
1025 /** Query level of the KILL command */
1026 KILL_QUERY = 254,
1027 /** Connection level of the KILL command */
1029};
1030/** @}*/
1033 /** No metadata will be sent. */
1035 /** The server will send all metadata. */
1037};
1038
1039#if defined(__clang__)
1040// disable -Wdocumentation to workaround
1041// https://bugs.llvm.org/show_bug.cgi?id=38905
1042#pragma clang diagnostic push
1043#pragma clang diagnostic ignored "-Wdocumentation"
1044#endif
1045/**
1046 The flags used in COM_STMT_EXECUTE.
1047 @sa @ref Protocol_classic::parse_packet, @ref mysql_int_serialize_param_data
1048*/
1049#if defined(__clang__)
1050#pragma clang diagnostic pop
1051#endif
1057 /**
1058 On when the client will send the parameter count
1059 even for 0 parameters.
1060 */
1062};
1063
1064/** options for ::mysql_options() */
1068};
1069
1070/**
1071 Type of state change information that the server can include in the Ok
1072 packet.
1073
1074 @note
1075 - session_state_type shouldn't go past 255 (i.e. 1-byte boundary).
1076 - Modify the definition of ::SESSION_TRACK_END when a new member is added.
1079 SESSION_TRACK_SYSTEM_VARIABLES, /**< Session system variables */
1080 SESSION_TRACK_SCHEMA, /**< Current schema */
1081 SESSION_TRACK_STATE_CHANGE, /**< track session state changes */
1082 SESSION_TRACK_GTIDS, /**< See also: session_track_gtids */
1083 SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /**< Transaction chistics */
1084 SESSION_TRACK_TRANSACTION_STATE /**< Transaction state */
1085};
1086
1087/** start of ::enum_session_state_type */
1088#define SESSION_TRACK_BEGIN SESSION_TRACK_SYSTEM_VARIABLES
1089
1090/** End of ::enum_session_state_type */
1091#define SESSION_TRACK_END SESSION_TRACK_TRANSACTION_STATE
1092
1093/** is T a valid session state type */
1094#define IS_SESSION_STATE_TYPE(T) \
1095 (((int)(T) >= SESSION_TRACK_BEGIN) && ((T) <= SESSION_TRACK_END))
1097#define net_new_transaction(net) ((net)->pkt_nr = 0)
1099bool my_net_init(struct NET *net, MYSQL_VIO vio);
1100void my_net_local_init(struct NET *net);
1101void net_end(struct NET *net);
1102void net_clear(struct NET *net, bool check_buffer);
1103void net_claim_memory_ownership(struct NET *net, bool claim);
1104bool net_realloc(struct NET *net, size_t length);
1105bool net_flush(struct NET *net);
1106bool my_net_write(struct NET *net, const unsigned char *packet, size_t len);
1107bool net_write_command(struct NET *net, unsigned char command,
1108 const unsigned char *header, size_t head_len,
1109 const unsigned char *packet, size_t len);
1110bool net_write_packet(struct NET *net, const unsigned char *packet,
1111 size_t length);
1112unsigned long my_net_read(struct NET *net);
1113void my_net_set_write_timeout(struct NET *net, unsigned int timeout);
1114void my_net_set_read_timeout(struct NET *net, unsigned int timeout);
1115void my_net_set_retry_count(struct NET *net, unsigned int retry_count);
1118 unsigned long seed1, seed2, max_value;
1119 double max_value_dbl;
1120};
1121
1122/* Include the types here so existing UDFs can keep compiling */
1124
1125/**
1126 @addtogroup group_cs_compresson_constants Constants when using compression
1127 @ingroup group_cs
1128 @{
1130#define NET_HEADER_SIZE 4 /**< standard header size */
1131#define COMP_HEADER_SIZE 3 /**< compression header extra size */
1132/** @}*/
1133
1134/* Prototypes to password functions */
1135
1136/* used in both client and server */
1137char *octet2hex(char *to, const char *str, unsigned int len);
1138
1139/* end of password.c */
1140
1141bool generate_sha256_scramble(unsigned char *dst, size_t dst_size,
1142 const char *src, size_t src_size, const char *rnd,
1143 size_t rnd_size);
1144
1145// extern "C" since it is an (undocumented) part of the libmysql ABI.
1146#ifdef __cplusplus
1147extern "C" {
1148#endif
1149char *get_tty_password(const char *opt_message);
1150#ifdef __cplusplus
1151}
1152#endif
1154const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
1155
1156/* Some other useful functions */
1157
1158bool my_thread_init(void);
1159void my_thread_end(void);
1160
1161#ifdef STDCALL
1162unsigned long STDCALL net_field_length(unsigned char **packet);
1163unsigned long STDCALL net_field_length_checked(unsigned char **packet,
1164 unsigned long max_length);
1165#endif
1166uint64_t net_field_length_ll(unsigned char **packet);
1167unsigned char *net_store_length(unsigned char *pkg, unsigned long long length);
1168unsigned int net_length_size(unsigned long long num);
1169unsigned int net_field_length_size(const unsigned char *pos);
1170uint64_t net_length_size_including_self(uint64_t length_without_self);
1172#define NULL_LENGTH ((unsigned long)~0) /**< For ::net_store_length() */
1173#define MYSQL_STMT_HEADER 4
1174#define MYSQL_LONG_DATA_HEADER 6
1175
1176/* clang-format off */
1177/**
1178 Describes the current state of Asynchronous connection phase state machine
1179
1180 @startuml
1181 [*] --> CONNECT_STAGE_INVALID
1182 [*] --> CONNECT_STAGE_NOT_STARTED
1183
1184 CONNECT_STAGE_NOT_STARTED --> CONNECT_STAGE_NET_BEGIN_CONNECT
1185 CONNECT_STAGE_NOT_STARTED --> CONNECT_STAGE_COMPLETE
1186
1187 CONNECT_STAGE_NET_BEGIN_CONNECT --> CONNECT_STAGE_NET_WAIT_CONNECT
1188 CONNECT_STAGE_NET_BEGIN_CONNECT --> CONNECT_STAGE_NET_COMPLETE_CONNECT
1189 CONNECT_STAGE_NET_BEGIN_CONNECT --> STATE_MACHINE_FAILED
1190
1191 CONNECT_STAGE_NET_WAIT_CONNECT --> CONNECT_STAGE_NET_COMPLETE_CONNECT
1192 CONNECT_STAGE_NET_WAIT_CONNECT --> STATE_MACHINE_FAILED
1193
1194 CONNECT_STAGE_NET_COMPLETE_CONNECT --> STATE_MACHINE_FAILED
1195 CONNECT_STAGE_NET_COMPLETE_CONNECT --> CONNECT_STAGE_READ_GREETING
1196
1197 CONNECT_STAGE_READ_GREETING --> STATE_MACHINE_FAILED
1198 CONNECT_STAGE_READ_GREETING --> CONNECT_STAGE_PARSE_HANDSHAKE
1199
1200 CONNECT_STAGE_PARSE_HANDSHAKE --> STATE_MACHINE_FAILED
1201 CONNECT_STAGE_PARSE_HANDSHAKE --> CONNECT_STAGE_ESTABLISH_SSL
1202
1203 CONNECT_STAGE_ESTABLISH_SSL --> STATE_MACHINE_FAILED
1204 CONNECT_STAGE_ESTABLISH_SSL --> CONNECT_STAGE_AUTHENTICATE
1205
1206 CONNECT_STAGE_AUTHENTICATE --> STATE_MACHINE_FAILED
1207 CONNECT_STAGE_AUTHENTICATE --> CONNECT_STAGE_AUTH_BEGIN
1208
1209 CONNECT_STAGE_AUTH_BEGIN --> STATE_MACHINE_FAILED
1210 CONNECT_STAGE_AUTH_BEGIN --> CONNECT_STAGE_AUTH_RUN_FIRST_AUTHENTICATE_USER
1211
1212 CONNECT_STAGE_AUTH_RUN_FIRST_AUTHENTICATE_USER --> CONNECT_STAGE_AUTH_HANDLE_FIRST_AUTHENTICATE_USER
1213
1214 CONNECT_STAGE_AUTH_HANDLE_FIRST_AUTHENTICATE_USER --> STATE_MACHINE_FAILED
1215 CONNECT_STAGE_AUTH_HANDLE_FIRST_AUTHENTICATE_USER --> CONNECT_STAGE_AUTH_READ_CHANGE_USER_RESULT
1216
1217 CONNECT_STAGE_AUTH_READ_CHANGE_USER_RESULT --> CONNECT_STAGE_AUTH_HANDLE_CHANGE_USER_REQUEST
1218
1219 CONNECT_STAGE_AUTH_HANDLE_CHANGE_USER_REQUEST --> STATE_MACHINE_FAILED
1220 CONNECT_STAGE_AUTH_HANDLE_CHANGE_USER_REQUEST --> CONNECT_STAGE_AUTH_RUN_SECOND_AUTHENTICATE_USER
1221 CONNECT_STAGE_AUTH_HANDLE_CHANGE_USER_REQUEST --> CONNECT_STAGE_AUTH_INIT_MULTI_AUTH
1222 CONNECT_STAGE_AUTH_HANDLE_CHANGE_USER_REQUEST --> CONNECT_STAGE_AUTH_FINISH_AUTH
1223
1224 CONNECT_STAGE_AUTH_RUN_SECOND_AUTHENTICATE_USER --> STATE_MACHINE_FAILED
1225 CONNECT_STAGE_AUTH_RUN_SECOND_AUTHENTICATE_USER --> CONNECT_STAGE_AUTH_HANDLE_SECOND_AUTHENTICATE_USER
1226
1227 CONNECT_STAGE_AUTH_HANDLE_SECOND_AUTHENTICATE_USER --> STATE_MACHINE_FAILED
1228 CONNECT_STAGE_AUTH_HANDLE_SECOND_AUTHENTICATE_USER --> CONNECT_STAGE_AUTH_INIT_MULTI_AUTH
1229 CONNECT_STAGE_AUTH_HANDLE_SECOND_AUTHENTICATE_USER --> CONNECT_STAGE_AUTH_FINISH_AUTH
1230
1231 CONNECT_STAGE_AUTH_INIT_MULTI_AUTH --> STATE_MACHINE_FAILED
1232 CONNECT_STAGE_AUTH_INIT_MULTI_AUTH --> CONNECT_STAGE_AUTH_DO_MULTI_PLUGIN_AUTH
1233
1234 CONNECT_STAGE_AUTH_DO_MULTI_PLUGIN_AUTH --> STATE_MACHINE_FAILED
1235 CONNECT_STAGE_AUTH_DO_MULTI_PLUGIN_AUTH --> CONNECT_STAGE_AUTH_HANDLE_MULTI_AUTH_RESPONSE
1236
1237 CONNECT_STAGE_AUTH_HANDLE_MULTI_AUTH_RESPONSE --> STATE_MACHINE_FAILED
1238 CONNECT_STAGE_AUTH_HANDLE_MULTI_AUTH_RESPONSE --> CONNECT_STAGE_AUTH_INIT_MULTI_AUTH
1239 CONNECT_STAGE_AUTH_HANDLE_MULTI_AUTH_RESPONSE --> CONNECT_STAGE_AUTH_FINISH_AUTH
1240
1241 CONNECT_STAGE_AUTH_FINISH_AUTH --> STATE_MACHINE_FAILED
1242 CONNECT_STAGE_AUTH_FINISH_AUTH --> CONNECT_STAGE_PREP_SELECT_DATABASE
1243
1244 CONNECT_STAGE_PREP_SELECT_DATABASE --> CONNECT_STAGE_COMPLETE
1245 CONNECT_STAGE_PREP_SELECT_DATABASE --> CONNECT_STAGE_PREP_INIT_COMMANDS
1246
1247 CONNECT_STAGE_PREP_INIT_COMMANDS --> CONNECT_STAGE_COMPLETE
1248 CONNECT_STAGE_PREP_INIT_COMMANDS --> CONNECT_STAGE_SEND_ONE_INIT_COMMAND
1249
1250 CONNECT_STAGE_SEND_ONE_INIT_COMMAND --> CONNECT_STAGE_SEND_ONE_INIT_COMMAND
1251 CONNECT_STAGE_SEND_ONE_INIT_COMMAND --> STATE_MACHINE_FAILED
1252 CONNECT_STAGE_SEND_ONE_INIT_COMMAND --> CONNECT_STAGE_COMPLETE
1253
1254 STATE_MACHINE_FAILED --> [*]
1255 CONNECT_STAGE_COMPLETE --> [*]
1256 CONNECT_STAGE_INVALID --> [*]
1257 @enduml
1258*/
1259/* clang-format on */
1260enum connect_stage {
1261 /** MYSQL not valid or an unknown state */
1263 /** not connected */
1265 /** begin connection to the server */
1267 /** wait for connection to be established */
1269 /** init the local data structures post connect */
1271 /** read the first packet */
1273 /** parse the first packet */
1275 /** tls establishment */
1277 /** authentication phase */
1279 /** determine the plugin to use */
1281 /** run first auth plugin */
1283 /** handle the result of the first auth plugin run */
1285 /** read the implied changed user auth, if any */
1287 /** Check if server asked to use a different authentication plugin */
1289 /** Start the authentication process again with the plugin which
1290 server asked for */
1292 /** Start multi factor authentication */
1294 /** Final cleanup */
1296 /** Now read the results of the second plugin run */
1298 /** Invoke client plugins multi-auth authentication method */
1300 /** Handle response from client plugins authentication method */
1302 /** Authenticated, set initial database if specified */
1304 /** Prepare to send a sequence of init commands. */
1306 /** Send an init command. This is called once per init command until
1307 they've all been run (or a failure occurs) */
1309 /** Connected or no async connect in progress */
1311};
1312#endif
mysql_enum_shutdown_level
We want levels to be in growing order of hardness (because we use number comparisons).
Definition: mysql_com.h:1012
#define MYSQL_SHUTDOWN_KILLABLE_CONNECT
Definition: mysql_com.h:1001
#define MYSQL_SHUTDOWN_KILLABLE_UPDATE
Definition: mysql_com.h:1004
#define MYSQL_SHUTDOWN_KILLABLE_TRANS
Definition: mysql_com.h:1002
@ SHUTDOWN_WAIT_CRITICAL_BUFFERS
Don't flush InnoDB buffers, flush other storage engines' buffers.
Definition: mysql_com.h:1023
@ SHUTDOWN_WAIT_ALL_BUFFERS
Flush InnoDB buffers and other storage engines' buffers.
Definition: mysql_com.h:1021
@ SHUTDOWN_WAIT_CONNECTIONS
Wait for existing connections to finish.
Definition: mysql_com.h:1015
@ SHUTDOWN_WAIT_TRANSACTIONS
Wait for existing transactons to finish.
Definition: mysql_com.h:1017
@ KILL_QUERY
Query level of the KILL command.
Definition: mysql_com.h:1025
@ SHUTDOWN_WAIT_UPDATES
Wait for existing updates to finish (=> no partial MyISAM update)
Definition: mysql_com.h:1019
@ KILL_CONNECTION
Connection level of the KILL command.
Definition: mysql_com.h:1027
@ SHUTDOWN_DEFAULT
Definition: mysql_com.h:1013
static int rnd(int max_value)
Definition: hp_test2.cc:551
#define STDCALL
Definition: my_compiler.h:137
Common #defines and includes for file and socket I/O.
Types to make file and socket I/O compatible.
unsigned int STDCALL mysql_errno(MYSQL *mysql)
Definition: client.cc:9483
int my_socket
Definition: mysql.h:65
unsigned char * net_store_length(unsigned char *pkg, unsigned long long length)
enum_session_state_type
Type of state change information that the server can include in the Ok packet.
Definition: mysql_com.h:1077
@ SESSION_TRACK_GTIDS
See also: session_track_gtids.
Definition: mysql_com.h:1081
@ SESSION_TRACK_SCHEMA
Current schema.
Definition: mysql_com.h:1079
@ SESSION_TRACK_TRANSACTION_CHARACTERISTICS
Transaction chistics.
Definition: mysql_com.h:1082
@ SESSION_TRACK_TRANSACTION_STATE
Transaction state.
Definition: mysql_com.h:1083
@ SESSION_TRACK_STATE_CHANGE
track session state changes
Definition: mysql_com.h:1080
@ SESSION_TRACK_SYSTEM_VARIABLES
Session system variables.
Definition: mysql_com.h:1078
SERVER_STATUS_flags_enum
The status flags are a bit-field.
Definition: mysql_com.h:815
@ SERVER_STATUS_LAST_ROW_SENT
This flag is sent when a read-only cursor is exhausted, in reply to COM_STMT_FETCH command.
Definition: mysql_com.h:841
@ SERVER_QUERY_WAS_SLOW
Definition: mysql_com.h:850
@ SERVER_STATUS_IN_TRANS
Is raised when a multi-statement transaction has been started, either explicitly, by means of BEGIN o...
Definition: mysql_com.h:823
@ SERVER_STATUS_NO_BACKSLASH_ESCAPES
Definition: mysql_com.h:843
@ SERVER_STATUS_DB_DROPPED
A database was dropped.
Definition: mysql_com.h:842
@ SERVER_STATUS_CURSOR_EXISTS
The server was able to fulfill the clients request and opened a read-only non-scrollable cursor for a...
Definition: mysql_com.h:836
@ SERVER_STATUS_AUTOCOMMIT
Server in auto_commit mode.
Definition: mysql_com.h:824
@ SERVER_SESSION_STATE_CHANGED
This status flag, when on, implies that one of the state information has changed on the server becaus...
Definition: mysql_com.h:869
@ SERVER_QUERY_NO_GOOD_INDEX_USED
Definition: mysql_com.h:826
@ SERVER_STATUS_IN_TRANS_READONLY
Set at the same time as SERVER_STATUS_IN_TRANS if the started multi-statement transaction is a read-o...
Definition: mysql_com.h:863
@ SERVER_QUERY_NO_INDEX_USED
Definition: mysql_com.h:827
@ SERVER_MORE_RESULTS_EXISTS
Multi query - next query exists.
Definition: mysql_com.h:825
@ SERVER_STATUS_METADATA_CHANGED
Sent to the client if after a prepared statement reprepare we discovered that the new statement retur...
Definition: mysql_com.h:849
@ SERVER_PS_OUT_PARAMS
To mark ResultSet containing output parameter values.
Definition: mysql_com.h:854
connect_stage
Describes the current state of Asynchronous connection phase state machine.
Definition: mysql_com.h:1259
@ CONNECT_STAGE_COMPLETE
Connected or no async connect in progress.
Definition: mysql_com.h:1309
@ CONNECT_STAGE_AUTH_INIT_MULTI_AUTH
Start multi factor authentication.
Definition: mysql_com.h:1292
@ CONNECT_STAGE_AUTH_HANDLE_FIRST_AUTHENTICATE_USER
handle the result of the first auth plugin run
Definition: mysql_com.h:1283
@ CONNECT_STAGE_NET_COMPLETE_CONNECT
init the local data structures post connect
Definition: mysql_com.h:1269
@ CONNECT_STAGE_AUTHENTICATE
authentication phase
Definition: mysql_com.h:1277
@ CONNECT_STAGE_SEND_ONE_INIT_COMMAND
Send an init command.
Definition: mysql_com.h:1307
@ CONNECT_STAGE_NET_WAIT_CONNECT
wait for connection to be established
Definition: mysql_com.h:1267
@ CONNECT_STAGE_PREP_SELECT_DATABASE
Authenticated, set initial database if specified.
Definition: mysql_com.h:1302
@ CONNECT_STAGE_AUTH_RUN_SECOND_AUTHENTICATE_USER
Start the authentication process again with the plugin which server asked for.
Definition: mysql_com.h:1290
@ CONNECT_STAGE_PARSE_HANDSHAKE
parse the first packet
Definition: mysql_com.h:1273
@ CONNECT_STAGE_AUTH_HANDLE_SECOND_AUTHENTICATE_USER
Now read the results of the second plugin run.
Definition: mysql_com.h:1296
@ CONNECT_STAGE_PREP_INIT_COMMANDS
Prepare to send a sequence of init commands.
Definition: mysql_com.h:1304
@ CONNECT_STAGE_AUTH_RUN_FIRST_AUTHENTICATE_USER
run first auth plugin
Definition: mysql_com.h:1281
@ CONNECT_STAGE_AUTH_DO_MULTI_PLUGIN_AUTH
Invoke client plugins multi-auth authentication method.
Definition: mysql_com.h:1298
@ CONNECT_STAGE_AUTH_HANDLE_CHANGE_USER_REQUEST
Check if server asked to use a different authentication plugin.
Definition: mysql_com.h:1287
@ CONNECT_STAGE_AUTH_HANDLE_MULTI_AUTH_RESPONSE
Handle response from client plugins authentication method.
Definition: mysql_com.h:1300
@ CONNECT_STAGE_AUTH_FINISH_AUTH
Final cleanup.
Definition: mysql_com.h:1294
@ CONNECT_STAGE_NOT_STARTED
not connected
Definition: mysql_com.h:1263
@ CONNECT_STAGE_ESTABLISH_SSL
tls establishment
Definition: mysql_com.h:1275
@ CONNECT_STAGE_NET_BEGIN_CONNECT
begin connection to the server
Definition: mysql_com.h:1265
@ CONNECT_STAGE_AUTH_BEGIN
determine the plugin to use
Definition: mysql_com.h:1279
@ CONNECT_STAGE_READ_GREETING
read the first packet
Definition: mysql_com.h:1271
@ CONNECT_STAGE_INVALID
MYSQL not valid or an unknown state.
Definition: mysql_com.h:1261
@ CONNECT_STAGE_AUTH_READ_CHANGE_USER_RESULT
read the implied changed user auth, if any
Definition: mysql_com.h:1285
bool my_net_init(struct NET *net, MYSQL_VIO vio)
bool net_write_command(struct NET *net, unsigned char command, const unsigned char *header, size_t head_len, const unsigned char *packet, size_t len)
Send a command to the server.
Definition: net_serv.cc:879
void my_net_set_read_timeout(struct NET *net, unsigned int timeout)
void my_net_set_write_timeout(struct NET *net, unsigned int timeout)
bool my_thread_init(void)
Allocate thread specific memory for the thread, used by mysys and dbug.
Definition: my_thr_init.cc:264
enum_cursor_type
The flags used in COM_STMT_EXECUTE.
Definition: mysql_com.h:1051
@ CURSOR_TYPE_NO_CURSOR
Definition: mysql_com.h:1052
@ CURSOR_TYPE_FOR_UPDATE
Definition: mysql_com.h:1054
@ CURSOR_TYPE_SCROLLABLE
Definition: mysql_com.h:1055
@ CURSOR_TYPE_READ_ONLY
Definition: mysql_com.h:1053
@ PARAMETER_COUNT_AVAILABLE
On when the client will send the parameter count even for 0 parameters.
Definition: mysql_com.h:1060
#define MYSQL_ERRMSG_SIZE
Max length of a error message.
Definition: mysql_com.h:888
char * get_tty_password(const char *opt_message)
Read a password from the terminal without echoing the typed characters.
Definition: get_password.cc:217
unsigned long my_net_read(struct NET *net)
Read a packet from the client/server and return it without the internal package header.
Definition: net_serv.cc:2285
#define MYSQL_VIO
Definition: mysql_com.h:902
enum_mysql_set_option
options for mysql_options()
Definition: mysql_com.h:1064
@ MYSQL_OPTION_MULTI_STATEMENTS_OFF
Definition: mysql_com.h:1066
@ MYSQL_OPTION_MULTI_STATEMENTS_ON
Definition: mysql_com.h:1065
void my_thread_end(void)
Deallocate memory used by the thread for book-keeping.
Definition: my_thr_init.cc:315
void my_net_set_retry_count(struct NET *net, unsigned int retry_count)
unsigned int net_field_length_size(const unsigned char *pos)
length of buffer required to represent a length-encoded string give the length part of length encoded...
Definition: pack.cc:179
void net_clear(struct NET *net, bool check_buffer)
Clear (reinitialize) the NET structure for a new command.
Definition: net_serv.cc:271
struct NET NET
#define SQLSTATE_LENGTH
Definition: mysql_com.h:75
uint64_t net_length_size_including_self(uint64_t length_without_self)
Calculates length of the field in case value of this field includes length of this field (self)
Definition: pack.cc:194
unsigned int net_length_size(unsigned long long num)
bool generate_sha256_scramble(unsigned char *dst, size_t dst_size, const char *src, size_t src_size, const char *rnd, size_t rnd_size)
Definition: sha2_password_common.cc:384
bool net_write_packet(struct NET *net, const unsigned char *packet, size_t length)
Write a MySQL protocol packet to the network handler.
Definition: net_serv.cc:1303
const char * mysql_errno_to_sqlstate(unsigned int mysql_errno)
bool net_realloc(struct NET *net, size_t length)
Realloc the packet buffer.
Definition: net_serv.cc:217
bool my_net_write(struct NET *net, const unsigned char *packet, size_t len)
Write a logical packet with packet header.
Definition: net_serv.cc:443
void net_end(struct NET *net)
Definition: net_serv.cc:198
enum_resultset_metadata
Definition: mysql_com.h:1031
@ RESULTSET_METADATA_NONE
No metadata will be sent.
Definition: mysql_com.h:1033
@ RESULTSET_METADATA_FULL
The server will send all metadata.
Definition: mysql_com.h:1035
char * octet2hex(char *to, const char *str, unsigned int len)
void my_net_local_init(struct NET *net)
Definition: libmysql.cc:1037
bool net_flush(struct NET *net)
Flush write_buffer if not empty.
Definition: net_serv.cc:292
uint64_t net_field_length_ll(unsigned char **packet)
Definition: pack.cc:91
void net_claim_memory_ownership(struct NET *net, bool claim)
Definition: net_serv.cc:211
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:499
Definition: buffer.h:45
ulong STDCALL net_field_length(uchar **packet)
Definition: pack.cc:39
ulong STDCALL net_field_length_checked(uchar **packet, ulong max_length)
Definition: pack.cc:62
Definition: mysql_com.h:921
unsigned int pkt_nr
Definition: mysql_com.h:932
char sqlstate[SQLSTATE_LENGTH+1]
Client library sqlstate buffer.
Definition: mysql_com.h:944
MYSQL_VIO vio
Definition: mysql_com.h:922
unsigned char error
Definition: mysql_com.h:940
unsigned char * read_pos
Definition: mysql_com.h:923
unsigned char reading_or_writing
Definition: mysql_com.h:936
unsigned int retry_count
Definition: mysql_com.h:933
bool compress
Definition: mysql_com.h:938
unsigned int * return_status
Definition: mysql_com.h:935
unsigned long length
Definition: mysql_com.h:930
unsigned long max_packet_size
Definition: mysql_com.h:931
unsigned long where_b
Definition: mysql_com.h:930
unsigned long max_packet
Definition: mysql_com.h:931
void * extension
Extension pointer, for the caller private use.
Definition: mysql_com.h:953
unsigned char save_char
Definition: mysql_com.h:937
unsigned int last_errno
Definition: mysql_com.h:939
unsigned char * buff
Definition: mysql_com.h:923
int fcntl
Definition: mysql_com.h:934
my_socket fd
Definition: mysql_com.h:924
unsigned char * write_pos
Definition: mysql_com.h:923
unsigned long remain_in_buf
Set if we are doing several queries in one command ( as in LOAD TABLE ... FROM MASTER ),...
Definition: mysql_com.h:930
char last_error[MYSQL_ERRMSG_SIZE]
Client library error message buffer.
Definition: mysql_com.h:942
unsigned int compress_pkt_nr
Definition: mysql_com.h:932
unsigned int read_timeout
Definition: mysql_com.h:933
unsigned char * buff_end
Definition: mysql_com.h:923
unsigned int write_timeout
Definition: mysql_com.h:933
unsigned long buf_length
Definition: mysql_com.h:930
Definition: violite.h:315
Definition: mysql_com.h:1116
unsigned long seed2
Definition: mysql_com.h:1117
unsigned long max_value
Definition: mysql_com.h:1117
double max_value_dbl
Definition: mysql_com.h:1118
unsigned long seed1
Definition: mysql_com.h:1117