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