| 1 | /* Copyright (c) 2000, 2025, 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" |
| 51 | #include "mysql/components/services/bits/my_io_bits.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 180 |
| 94 | #define 2048 |
| 95 | #define COLUMN_COMMENT_MAXLEN 1024 |
| 96 | #define 1024 |
| 97 | #define 1024 |
| 98 | #define 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 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 NUM_FLAG 32768 /**< Field is num (for clients) */ |
| 171 | #define PART_KEY_FLAG 16384 /**< Intern; Part of some key */ |
| 172 | #define GROUP_FLAG 32768 /**< Intern: Group field */ |
| 173 | #define UNIQUE_FLAG 65536 /**< Intern: Used by sql_yacc */ |
| 174 | #define BINCMP_FLAG 131072 /**< Intern: Used by sql_yacc */ |
| 175 | #define GET_FIXED_FIELDS_FLAG \ |
| 176 | (1 << 18) /**< Used to get fields in item tree \ |
| 177 | */ |
| 178 | #define FIELD_IN_PART_FUNC_FLAG (1 << 19) /**< Field part of partition func */ |
| 179 | /** |
| 180 | Intern: Field in TABLE object for new version of altered table, |
| 181 | which participates in a newly added index. |
| 182 | */ |
| 183 | #define FIELD_IN_ADD_INDEX (1 << 20) |
| 184 | #define FIELD_IS_RENAMED (1 << 21) /**< Intern: Field is being renamed */ |
| 185 | #define FIELD_FLAGS_STORAGE_MEDIA 22 /**< Field storage media, bit 22-23 */ |
| 186 | #define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA) |
| 187 | #define FIELD_FLAGS_COLUMN_FORMAT 24 /**< Field column format, bit 24-25 */ |
| 188 | #define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT) |
| 189 | #define FIELD_IS_DROPPED (1 << 26) /**< Intern: Field is being dropped */ |
| 190 | #define EXPLICIT_NULL_FLAG \ |
| 191 | (1 << 27) /**< Field is explicitly specified as \ |
| 192 | NULL by the user */ |
| 193 | /* 1 << 28 is unused. */ |
| 194 | |
| 195 | /** Field will not be loaded in secondary engine. */ |
| 196 | #define NOT_SECONDARY_FLAG (1 << 29) |
| 197 | /** Field is explicitly marked as invisible by the user. */ |
| 198 | #define FIELD_IS_INVISIBLE (1 << 30) |
| 199 | |
| 200 | /** @}*/ |
| 201 | |
| 202 | /** |
| 203 | @defgroup group_cs_com_refresh_flags COM_REFRESH Flags |
| 204 | @ingroup group_cs |
| 205 | |
| 206 | @brief Values for the `sub_command` in ::COM_REFRESH |
| 207 | |
| 208 | Currently the protocol carries only 8 bits of these flags. |
| 209 | |
| 210 | The rest (8-end) are used only internally in the server. |
| 211 | */ |
| 212 | |
| 213 | /** |
| 214 | @addtogroup group_cs_com_refresh_flags |
| 215 | @{ |
| 216 | */ |
| 217 | |
| 218 | #define REFRESH_GRANT 1 /**< Refresh grant tables, FLUSH PRIVILEGES */ |
| 219 | #define REFRESH_LOG 2 /**< Start on new log file, FLUSH LOGS */ |
| 220 | #define REFRESH_TABLES 4 /**< close all tables, FLUSH TABLES */ |
| 221 | #define REFRESH_HOSTS 8 /**< Flush host cache, FLUSH HOSTS */ |
| 222 | #define REFRESH_STATUS 16 /**< Flush status variables, FLUSH STATUS */ |
| 223 | #define REFRESH_THREADS 32 /**< Flush thread cache */ |
| 224 | #define REFRESH_REPLICA \ |
| 225 | 64 /**< Reset master info and restart replica \ |
| 226 | thread, RESET REPLICA */ |
| 227 | #define REFRESH_SLAVE \ |
| 228 | REFRESH_REPLICA /**< Reset master info and restart replica \ |
| 229 | thread, RESET REPLICA. This is deprecated, \ |
| 230 | use REFRESH_REPLICA instead. */ |
| 231 | |
| 232 | #define REFRESH_MASTER \ |
| 233 | 128 /**< Remove all bin logs in the index \ |
| 234 | and truncate the index, RESET MASTER */ |
| 235 | #define REFRESH_ERROR_LOG 256 /**< Rotate only the error log */ |
| 236 | #define REFRESH_ENGINE_LOG 512 /**< Flush all storage engine logs */ |
| 237 | #define REFRESH_BINARY_LOG 1024 /**< Flush the binary log */ |
| 238 | #define REFRESH_RELAY_LOG 2048 /**< Flush the relay log */ |
| 239 | #define REFRESH_GENERAL_LOG 4096 /**< Flush the general log */ |
| 240 | #define REFRESH_SLOW_LOG 8192 /**< Flush the slow query log */ |
| 241 | #define REFRESH_READ_LOCK 16384 /**< Lock tables for read. */ |
| 242 | /** |
| 243 | Wait for an impending flush before closing the tables. |
| 244 | |
| 245 | @sa REFRESH_READ_LOCK, handle_reload_request, close_cached_tables |
| 246 | */ |
| 247 | #define REFRESH_FAST 32768 |
| 248 | #define REFRESH_USER_RESOURCES \ |
| 249 | 0x80000L /** FLUSH RESOURCES. @sa ::reset_mqh \ |
| 250 | */ |
| 251 | #define REFRESH_FOR_EXPORT 0x100000L /** FLUSH TABLES ... FOR EXPORT */ |
| 252 | #define REFRESH_OPTIMIZER_COSTS 0x200000L /** FLUSH OPTIMIZER_COSTS */ |
| 253 | #define REFRESH_PERSIST 0x400000L /** RESET PERSIST */ |
| 254 | |
| 255 | /** @}*/ |
| 256 | |
| 257 | /** |
| 258 | @defgroup group_cs_capabilities_flags Capabilities Flags |
| 259 | @ingroup group_cs |
| 260 | |
| 261 | @brief Values for the capabilities flag bitmask used by the MySQL protocol |
| 262 | |
| 263 | Currently need to fit into 32 bits. |
| 264 | |
| 265 | Each bit represents an optional feature of the protocol. |
| 266 | |
| 267 | Both the client and the server are sending these. |
| 268 | |
| 269 | The intersection of the two determines whast optional parts of the |
| 270 | protocol will be used. |
| 271 | */ |
| 272 | |
| 273 | /** |
| 274 | @addtogroup group_cs_capabilities_flags |
| 275 | @{ |
| 276 | */ |
| 277 | |
| 278 | /** |
| 279 | Use the improved version of Old Password Authentication. |
| 280 | |
| 281 | Not used. |
| 282 | |
| 283 | @note Assumed to be set since 4.1.1. |
| 284 | */ |
| 285 | #define CLIENT_LONG_PASSWORD 1 |
| 286 | /** |
| 287 | Send found rows instead of affected rows in @ref |
| 288 | page_protocol_basic_eof_packet |
| 289 | */ |
| 290 | #define CLIENT_FOUND_ROWS 2 |
| 291 | /** |
| 292 | @brief Get all column flags |
| 293 | |
| 294 | Longer flags in Protocol::ColumnDefinition320. |
| 295 | |
| 296 | @todo Reference Protocol::ColumnDefinition320 |
| 297 | |
| 298 | Server |
| 299 | ------ |
| 300 | |
| 301 | Supports longer flags. |
| 302 | |
| 303 | Client |
| 304 | ------ |
| 305 | |
| 306 | Expects longer flags. |
| 307 | */ |
| 308 | #define CLIENT_LONG_FLAG 4 |
| 309 | /** |
| 310 | Database (schema) name can be specified on connect in Handshake Response |
| 311 | Packet. |
| 312 | |
| 313 | @todo Reference Handshake Response Packet. |
| 314 | |
| 315 | Server |
| 316 | ------ |
| 317 | |
| 318 | Supports schema-name in Handshake Response Packet. |
| 319 | |
| 320 | Client |
| 321 | ------ |
| 322 | |
| 323 | Handshake Response Packet contains a schema-name. |
| 324 | |
| 325 | @sa send_client_reply_packet() |
| 326 | */ |
| 327 | #define CLIENT_CONNECT_WITH_DB 8 |
| 328 | #define CLIENT_NO_SCHEMA \ |
| 329 | 16 /**< DEPRECATED: Don't allow database.table.column */ |
| 330 | /** |
| 331 | Compression protocol supported. |
| 332 | |
| 333 | @todo Reference Compression |
| 334 | |
| 335 | Server |
| 336 | ------ |
| 337 | |
| 338 | Supports compression. |
| 339 | |
| 340 | Client |
| 341 | ------ |
| 342 | |
| 343 | Switches to Compression compressed protocol after successful authentication. |
| 344 | */ |
| 345 | #define CLIENT_COMPRESS 32 |
| 346 | /** |
| 347 | Special handling of ODBC behavior. |
| 348 | |
| 349 | @note No special behavior since 3.22. |
| 350 | */ |
| 351 | #define CLIENT_ODBC 64 |
| 352 | /** |
| 353 | Can use LOAD DATA LOCAL. |
| 354 | |
| 355 | Server |
| 356 | ------ |
| 357 | |
| 358 | Enables the LOCAL INFILE request of LOAD DATA|XML. |
| 359 | |
| 360 | Client |
| 361 | ------ |
| 362 | |
| 363 | Will handle LOCAL INFILE request. |
| 364 | */ |
| 365 | #define CLIENT_LOCAL_FILES 128 |
| 366 | /** |
| 367 | Ignore spaces before '(' |
| 368 | |
| 369 | Server |
| 370 | ------ |
| 371 | |
| 372 | Parser can ignore spaces before '('. |
| 373 | |
| 374 | Client |
| 375 | ------ |
| 376 | |
| 377 | Let the parser ignore spaces before '('. |
| 378 | */ |
| 379 | #define CLIENT_IGNORE_SPACE 256 |
| 380 | /** |
| 381 | New 4.1 protocol |
| 382 | |
| 383 | @todo Reference the new 4.1 protocol |
| 384 | |
| 385 | Server |
| 386 | ------ |
| 387 | |
| 388 | Supports the 4.1 protocol. |
| 389 | |
| 390 | Client |
| 391 | ------ |
| 392 | |
| 393 | Uses the 4.1 protocol. |
| 394 | |
| 395 | @note this value was CLIENT_CHANGE_USER in 3.22, unused in 4.0 |
| 396 | */ |
| 397 | #define CLIENT_PROTOCOL_41 512 |
| 398 | /** |
| 399 | This is an interactive client |
| 400 | |
| 401 | Use @ref System_variables::net_wait_timeout |
| 402 | versus @ref System_variables::net_interactive_timeout. |
| 403 | |
| 404 | Server |
| 405 | ------ |
| 406 | |
| 407 | Supports interactive and noninteractive clients. |
| 408 | |
| 409 | Client |
| 410 | ------ |
| 411 | |
| 412 | Client is interactive. |
| 413 | |
| 414 | @sa mysql_real_connect() |
| 415 | */ |
| 416 | #define CLIENT_INTERACTIVE 1024 |
| 417 | /** |
| 418 | Use SSL encryption for the session |
| 419 | |
| 420 | @todo Reference SSL |
| 421 | |
| 422 | Server |
| 423 | ------ |
| 424 | |
| 425 | Supports SSL |
| 426 | |
| 427 | Client |
| 428 | ------ |
| 429 | |
| 430 | Switch to SSL after sending the capability-flags. |
| 431 | */ |
| 432 | #define CLIENT_SSL 2048 |
| 433 | /** |
| 434 | Client only flag. Not used. |
| 435 | |
| 436 | Client |
| 437 | ------ |
| 438 | |
| 439 | Do not issue SIGPIPE if network failures occur (libmysqlclient only). |
| 440 | |
| 441 | @sa mysql_real_connect() |
| 442 | */ |
| 443 | #define CLIENT_IGNORE_SIGPIPE 4096 |
| 444 | /** |
| 445 | Client knows about transactions |
| 446 | |
| 447 | Server |
| 448 | ------ |
| 449 | |
| 450 | Can send status flags in @ref page_protocol_basic_ok_packet / |
| 451 | @ref page_protocol_basic_eof_packet. |
| 452 | |
| 453 | Client |
| 454 | ------ |
| 455 | |
| 456 | Expects status flags in @ref page_protocol_basic_ok_packet / |
| 457 | @ref page_protocol_basic_eof_packet. |
| 458 | |
| 459 | @note This flag is optional in 3.23, but always set by the server since 4.0. |
| 460 | @sa send_server_handshake_packet(), parse_client_handshake_packet(), |
| 461 | net_send_ok(), net_send_eof() |
| 462 | */ |
| 463 | #define CLIENT_TRANSACTIONS 8192 |
| 464 | #define CLIENT_RESERVED 16384 /**< DEPRECATED: Old flag for 4.1 protocol */ |
| 465 | #define CLIENT_RESERVED2 \ |
| 466 | 32768 /**< DEPRECATED: Old flag for 4.1 authentication \ |
| 467 | CLIENT_SECURE_CONNECTION */ |
| 468 | /** |
| 469 | Enable/disable multi-stmt support |
| 470 | |
| 471 | Also sets @ref CLIENT_MULTI_RESULTS. Currently not checked anywhere. |
| 472 | |
| 473 | Server |
| 474 | ------ |
| 475 | |
| 476 | Can handle multiple statements per COM_QUERY and COM_STMT_PREPARE. |
| 477 | |
| 478 | Client |
| 479 | ------- |
| 480 | |
| 481 | May send multiple statements per COM_QUERY and COM_STMT_PREPARE. |
| 482 | |
| 483 | @note Was named ::CLIENT_MULTI_QUERIES in 4.1.0, renamed later. |
| 484 | |
| 485 | Requires |
| 486 | -------- |
| 487 | |
| 488 | ::CLIENT_PROTOCOL_41 |
| 489 | |
| 490 | @todo Reference COM_QUERY and COM_STMT_PREPARE |
| 491 | */ |
| 492 | #define CLIENT_MULTI_STATEMENTS (1UL << 16) |
| 493 | /** |
| 494 | Enable/disable multi-results |
| 495 | |
| 496 | Server |
| 497 | ------ |
| 498 | |
| 499 | Can send multiple resultsets for COM_QUERY. |
| 500 | Error if the server needs to send them and client |
| 501 | does not support them. |
| 502 | |
| 503 | Client |
| 504 | ------- |
| 505 | |
| 506 | Can handle multiple resultsets for COM_QUERY. |
| 507 | |
| 508 | Requires |
| 509 | -------- |
| 510 | |
| 511 | ::CLIENT_PROTOCOL_41 |
| 512 | |
| 513 | @sa mysql_execute_command(), sp_head::MULTI_RESULTS |
| 514 | */ |
| 515 | #define CLIENT_MULTI_RESULTS (1UL << 17) |
| 516 | /** |
| 517 | Multi-results and OUT parameters in PS-protocol. |
| 518 | |
| 519 | Server |
| 520 | ------ |
| 521 | |
| 522 | Can send multiple resultsets for COM_STMT_EXECUTE. |
| 523 | |
| 524 | Client |
| 525 | ------ |
| 526 | |
| 527 | Can handle multiple resultsets for COM_STMT_EXECUTE. |
| 528 | |
| 529 | Requires |
| 530 | -------- |
| 531 | |
| 532 | ::CLIENT_PROTOCOL_41 |
| 533 | |
| 534 | @todo Reference COM_STMT_EXECUTE and PS-protocol |
| 535 | |
| 536 | @sa Protocol_binary::send_out_parameters |
| 537 | */ |
| 538 | #define CLIENT_PS_MULTI_RESULTS (1UL << 18) |
| 539 | |
| 540 | /** |
| 541 | Client supports plugin authentication |
| 542 | |
| 543 | Server |
| 544 | ------ |
| 545 | |
| 546 | Sends extra data in Initial Handshake Packet and supports the pluggable |
| 547 | authentication protocol. |
| 548 | |
| 549 | Client |
| 550 | ------ |
| 551 | |
| 552 | Supports authentication plugins. |
| 553 | |
| 554 | Requires |
| 555 | -------- |
| 556 | |
| 557 | ::CLIENT_PROTOCOL_41 |
| 558 | |
| 559 | @todo Reference plugin authentication, Initial Handshake Packet, |
| 560 | Authentication plugins |
| 561 | |
| 562 | @sa send_change_user_packet(), send_client_reply_packet(), run_plugin_auth(), |
| 563 | parse_com_change_user_packet(), parse_client_handshake_packet() |
| 564 | */ |
| 565 | #define CLIENT_PLUGIN_AUTH (1UL << 19) |
| 566 | /** |
| 567 | Client supports connection attributes |
| 568 | |
| 569 | Server |
| 570 | ------ |
| 571 | |
| 572 | Permits connection attributes in Protocol::HandshakeResponse41. |
| 573 | |
| 574 | Client |
| 575 | ------ |
| 576 | |
| 577 | Sends connection attributes in Protocol::HandshakeResponse41. |
| 578 | |
| 579 | @todo Reference Protocol::HandshakeResponse41 |
| 580 | |
| 581 | @sa send_client_connect_attrs(), read_client_connect_attrs() |
| 582 | */ |
| 583 | #define CLIENT_CONNECT_ATTRS (1UL << 20) |
| 584 | |
| 585 | /** |
| 586 | Enable authentication response packet to be larger than 255 bytes. |
| 587 | |
| 588 | When the ability to change default plugin require that the initial password |
| 589 | field in the Protocol::HandshakeResponse41 paclet can be of arbitrary size. |
| 590 | However, the 4.1 client-server protocol limits the length of the |
| 591 | auth-data-field sent from client to server to 255 bytes. |
| 592 | The solution is to change the type of the field to a true length encoded |
| 593 | string and indicate the protocol change |
| 594 | with this client capability flag. |
| 595 | |
| 596 | Server |
| 597 | ------ |
| 598 | |
| 599 | Understands length-encoded integer for auth response data in |
| 600 | Protocol::HandshakeResponse41. |
| 601 | |
| 602 | Client |
| 603 | ------ |
| 604 | |
| 605 | Length of auth response data in Protocol::HandshakeResponse41 |
| 606 | is a length-encoded integer. |
| 607 | |
| 608 | @todo Reference Protocol::HandshakeResponse41 |
| 609 | |
| 610 | @note The flag was introduced in 5.6.6, but had the wrong value. |
| 611 | |
| 612 | @sa send_client_reply_packet(), parse_client_handshake_packet(), |
| 613 | get_56_lenc_string(), get_41_lenc_string() |
| 614 | */ |
| 615 | #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21) |
| 616 | |
| 617 | /** |
| 618 | Don't close the connection for a user account with expired password. |
| 619 | |
| 620 | Server |
| 621 | ------ |
| 622 | |
| 623 | Announces support for expired password extension. |
| 624 | |
| 625 | Client |
| 626 | ------ |
| 627 | |
| 628 | Can handle expired passwords. |
| 629 | |
| 630 | @todo Reference expired password |
| 631 | |
| 632 | @sa MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, disconnect_on_expired_password |
| 633 | ACL_USER::password_expired, check_password_lifetime(), acl_authenticate() |
| 634 | */ |
| 635 | #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) |
| 636 | |
| 637 | /** |
| 638 | Capable of handling server state change information. Its a hint to the |
| 639 | server to include the state change information in |
| 640 | @ref page_protocol_basic_ok_packet. |
| 641 | |
| 642 | Server |
| 643 | ------ |
| 644 | Can set ::SERVER_SESSION_STATE_CHANGED in the ::SERVER_STATUS_flags_enum |
| 645 | and send @ref sect_protocol_basic_ok_packet_sessinfo in a |
| 646 | @ref page_protocol_basic_ok_packet. |
| 647 | |
| 648 | Client |
| 649 | ------ |
| 650 | |
| 651 | Expects the server to send @ref sect_protocol_basic_ok_packet_sessinfo in |
| 652 | a @ref page_protocol_basic_ok_packet. |
| 653 | |
| 654 | @sa enum_session_state_type, read_ok_ex(), net_send_ok(), Session_tracker, |
| 655 | State_tracker |
| 656 | */ |
| 657 | #define CLIENT_SESSION_TRACK (1UL << 23) |
| 658 | /** |
| 659 | Client no longer needs @ref page_protocol_basic_eof_packet and will |
| 660 | use @ref page_protocol_basic_ok_packet instead. |
| 661 | @sa net_send_ok() |
| 662 | |
| 663 | Server |
| 664 | ------ |
| 665 | |
| 666 | Can send OK after a Text Resultset. |
| 667 | |
| 668 | Client |
| 669 | ------ |
| 670 | |
| 671 | Expects an @ref page_protocol_basic_ok_packet (instead of |
| 672 | @ref page_protocol_basic_eof_packet) after the resultset rows of a |
| 673 | Text Resultset. |
| 674 | |
| 675 | Background |
| 676 | ---------- |
| 677 | |
| 678 | To support ::CLIENT_SESSION_TRACK, additional information must be sent after |
| 679 | all successful commands. Although the @ref page_protocol_basic_ok_packet is |
| 680 | extensible, the @ref page_protocol_basic_eof_packet is not due to the overlap |
| 681 | of its bytes with the content of the Text Resultset Row. |
| 682 | |
| 683 | Therefore, the @ref page_protocol_basic_eof_packet in the |
| 684 | Text Resultset is replaced with an @ref page_protocol_basic_ok_packet. |
| 685 | @ref page_protocol_basic_eof_packet is deprecated as of MySQL 5.7.5. |
| 686 | |
| 687 | @todo Reference Text Resultset |
| 688 | |
| 689 | @sa cli_safe_read_with_ok(), read_ok_ex(), net_send_ok(), net_send_eof() |
| 690 | */ |
| 691 | #define CLIENT_DEPRECATE_EOF (1UL << 24) |
| 692 | |
| 693 | /** |
| 694 | The client can handle optional metadata information in the resultset. |
| 695 | */ |
| 696 | #define CLIENT_OPTIONAL_RESULTSET_METADATA (1UL << 25) |
| 697 | |
| 698 | /** |
| 699 | Compression protocol extended to support zstd compression method |
| 700 | |
| 701 | This capability flag is used to send zstd compression level between |
| 702 | client and server provided both client and server are enabled with |
| 703 | this flag. |
| 704 | |
| 705 | Server |
| 706 | ------ |
| 707 | Server sets this flag when global variable protocol-compression-algorithms |
| 708 | has zstd in its list of supported values. |
| 709 | |
| 710 | Client |
| 711 | ------ |
| 712 | Client sets this flag when it is configured to use zstd compression method. |
| 713 | |
| 714 | */ |
| 715 | #define CLIENT_ZSTD_COMPRESSION_ALGORITHM (1UL << 26) |
| 716 | |
| 717 | /** |
| 718 | Support optional extension for query parameters into the @ref |
| 719 | page_protocol_com_query and @ref page_protocol_com_stmt_execute packets. |
| 720 | |
| 721 | Server |
| 722 | ------ |
| 723 | |
| 724 | Expects an optional part containing the query parameter set(s). Executes the |
| 725 | query for each set of parameters or returns an error if more than 1 set of |
| 726 | parameters is sent and the server can't execute it. |
| 727 | |
| 728 | Client |
| 729 | ------ |
| 730 | |
| 731 | Can send the optional part containing the query parameter set(s). |
| 732 | */ |
| 733 | #define CLIENT_QUERY_ATTRIBUTES (1UL << 27) |
| 734 | |
| 735 | /** |
| 736 | Support Multi factor authentication. |
| 737 | |
| 738 | Server |
| 739 | ------ |
| 740 | Server sends AuthNextFactor packet after every nth factor authentication |
| 741 | method succeeds, except the last factor authentication. |
| 742 | |
| 743 | Client |
| 744 | ------ |
| 745 | Client reads AuthNextFactor packet sent by server and initiates next factor |
| 746 | authentication method. |
| 747 | */ |
| 748 | #define MULTI_FACTOR_AUTHENTICATION (1UL << 28) |
| 749 | |
| 750 | /** |
| 751 | This flag will be reserved to extend the 32bit capabilities structure to |
| 752 | 64bits. |
| 753 | */ |
| 754 | #define CLIENT_CAPABILITY_EXTENSION (1UL << 29) |
| 755 | |
| 756 | /** |
| 757 | Verify server certificate. |
| 758 | |
| 759 | Client only flag. |
| 760 | |
| 761 | @deprecated in favor of --ssl-mode. |
| 762 | */ |
| 763 | #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) |
| 764 | |
| 765 | /** |
| 766 | Don't reset the options after an unsuccessful connect |
| 767 | |
| 768 | Client only flag. |
| 769 | |
| 770 | Typically passed via ::mysql_real_connect() 's client_flag parameter. |
| 771 | |
| 772 | @sa mysql_real_connect() |
| 773 | */ |
| 774 | #define CLIENT_REMEMBER_OPTIONS (1UL << 31) |
| 775 | /** @}*/ |
| 776 | |
| 777 | /** a compatibility alias for CLIENT_COMPRESS */ |
| 778 | #define CAN_CLIENT_COMPRESS CLIENT_COMPRESS |
| 779 | |
| 780 | /** Gather all possible capabilities (flags) supported by the server */ |
| 781 | #define CLIENT_ALL_FLAGS \ |
| 782 | (CLIENT_LONG_PASSWORD | CLIENT_FOUND_ROWS | CLIENT_LONG_FLAG | \ |
| 783 | CLIENT_CONNECT_WITH_DB | CLIENT_NO_SCHEMA | CLIENT_COMPRESS | CLIENT_ODBC | \ |
| 784 | CLIENT_LOCAL_FILES | CLIENT_IGNORE_SPACE | CLIENT_PROTOCOL_41 | \ |
| 785 | CLIENT_INTERACTIVE | CLIENT_SSL | CLIENT_IGNORE_SIGPIPE | \ |
| 786 | CLIENT_TRANSACTIONS | CLIENT_RESERVED | CLIENT_RESERVED2 | \ |
| 787 | CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS | CLIENT_PS_MULTI_RESULTS | \ |
| 788 | CLIENT_SSL_VERIFY_SERVER_CERT | CLIENT_REMEMBER_OPTIONS | \ |
| 789 | CLIENT_PLUGIN_AUTH | CLIENT_CONNECT_ATTRS | \ |
| 790 | CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \ |
| 791 | CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS | CLIENT_SESSION_TRACK | \ |
| 792 | CLIENT_DEPRECATE_EOF | CLIENT_OPTIONAL_RESULTSET_METADATA | \ |
| 793 | CLIENT_ZSTD_COMPRESSION_ALGORITHM | CLIENT_QUERY_ATTRIBUTES | \ |
| 794 | MULTI_FACTOR_AUTHENTICATION) |
| 795 | |
| 796 | /** |
| 797 | Switch off from ::CLIENT_ALL_FLAGS the flags that are optional and |
| 798 | depending on build flags. |
| 799 | If any of the optional flags is supported by the build it will be switched |
| 800 | on before sending to the client during the connection handshake. |
| 801 | */ |
| 802 | #define CLIENT_BASIC_FLAGS \ |
| 803 | (CLIENT_ALL_FLAGS & \ |
| 804 | ~(CLIENT_SSL | CLIENT_COMPRESS | CLIENT_SSL_VERIFY_SERVER_CERT | \ |
| 805 | CLIENT_ZSTD_COMPRESSION_ALGORITHM)) |
| 806 | |
| 807 | /** The status flags are a bit-field */ |
| 808 | enum SERVER_STATUS_flags_enum { |
| 809 | /** |
| 810 | Is raised when a multi-statement transaction |
| 811 | has been started, either explicitly, by means |
| 812 | of BEGIN or COMMIT AND CHAIN, or |
| 813 | implicitly, by the first transactional |
| 814 | statement, when autocommit=off. |
| 815 | */ |
| 816 | SERVER_STATUS_IN_TRANS = 1, |
| 817 | SERVER_STATUS_AUTOCOMMIT = 2, /**< Server in auto_commit mode */ |
| 818 | SERVER_MORE_RESULTS_EXISTS = 8, /**< Multi query - next query exists */ |
| 819 | SERVER_QUERY_NO_GOOD_INDEX_USED = 16, |
| 820 | SERVER_QUERY_NO_INDEX_USED = 32, |
| 821 | /** |
| 822 | The server was able to fulfill the clients request and opened a |
| 823 | read-only non-scrollable cursor for a query. This flag comes |
| 824 | in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. |
| 825 | Used by Binary Protocol Resultset to signal that COM_STMT_FETCH |
| 826 | must be used to fetch the row-data. |
| 827 | @todo Refify "Binary Protocol Resultset" and "COM_STMT_FETCH". |
| 828 | */ |
| 829 | SERVER_STATUS_CURSOR_EXISTS = 64, |
| 830 | /** |
| 831 | This flag is sent when a read-only cursor is exhausted, in reply to |
| 832 | COM_STMT_FETCH command. |
| 833 | */ |
| 834 | SERVER_STATUS_LAST_ROW_SENT = 128, |
| 835 | SERVER_STATUS_DB_DROPPED = 256, /**< A database was dropped */ |
| 836 | SERVER_STATUS_NO_BACKSLASH_ESCAPES = 512, |
| 837 | /** |
| 838 | Sent to the client if after a prepared statement reprepare |
| 839 | we discovered that the new statement returns a different |
| 840 | number of result set columns. |
| 841 | */ |
| 842 | SERVER_STATUS_METADATA_CHANGED = 1024, |
| 843 | SERVER_QUERY_WAS_SLOW = 2048, |
| 844 | /** |
| 845 | To mark ResultSet containing output parameter values. |
| 846 | */ |
| 847 | SERVER_PS_OUT_PARAMS = 4096, |
| 848 | |
| 849 | /** |
| 850 | Set at the same time as SERVER_STATUS_IN_TRANS if the started |
| 851 | multi-statement transaction is a read-only transaction. Cleared |
| 852 | when the transaction commits or aborts. Since this flag is sent |
| 853 | to clients in OK and EOF packets, the flag indicates the |
| 854 | transaction status at the end of command execution. |
| 855 | */ |
| 856 | SERVER_STATUS_IN_TRANS_READONLY = 8192, |
| 857 | |
| 858 | /** |
| 859 | This status flag, when on, implies that one of the state information has |
| 860 | changed on the server because of the execution of the last statement. |
| 861 | */ |
| 862 | SERVER_SESSION_STATE_CHANGED = (1UL << 14) |
| 863 | }; |
| 864 | |
| 865 | /** |
| 866 | Server status flags that must be cleared when starting |
| 867 | execution of a new SQL statement. |
| 868 | Flags from this set are only added to the |
| 869 | current server status by the execution engine, but |
| 870 | never removed -- the execution engine expects them |
| 871 | to disappear automagically by the next command. |
| 872 | */ |
| 873 | #define SERVER_STATUS_CLEAR_SET \ |
| 874 | (SERVER_QUERY_NO_GOOD_INDEX_USED | SERVER_QUERY_NO_INDEX_USED | \ |
| 875 | SERVER_MORE_RESULTS_EXISTS | SERVER_STATUS_METADATA_CHANGED | \ |
| 876 | SERVER_QUERY_WAS_SLOW | SERVER_STATUS_DB_DROPPED | \ |
| 877 | SERVER_STATUS_CURSOR_EXISTS | SERVER_STATUS_LAST_ROW_SENT | \ |
| 878 | SERVER_SESSION_STATE_CHANGED) |
| 879 | |
| 880 | /** Max length of a error message. Should be kept in sync with ::ERRMSGSIZE. */ |
| 881 | #define MYSQL_ERRMSG_SIZE 512 |
| 882 | #define NET_READ_TIMEOUT 30 /**< Timeout on read */ |
| 883 | #define NET_WRITE_TIMEOUT 60 /**< Timeout on write */ |
| 884 | #define NET_WAIT_TIMEOUT 8 * 60 * 60 /**< Wait for new query */ |
| 885 | |
| 886 | /** |
| 887 | Flag used by the parser. Kill only the query and not the connection. |
| 888 | |
| 889 | @sa SQLCOM_KILL, sql_kill(), LEX::type |
| 890 | */ |
| 891 | #define ONLY_KILL_QUERY 1 |
| 892 | |
| 893 | #ifndef MYSQL_VIO |
| 894 | struct Vio; |
| 895 | #define MYSQL_VIO struct Vio * |
| 896 | #endif |
| 897 | |
| 898 | #define MAX_TINYINT_WIDTH 3 /**< Max width for a TINY w.o. sign */ |
| 899 | #define MAX_SMALLINT_WIDTH 5 /**< Max width for a SHORT w.o. sign */ |
| 900 | #define MAX_MEDIUMINT_WIDTH 8 /**< Max width for a INT24 w.o. sign */ |
| 901 | #define MAX_INT_WIDTH 10 /**< Max width for a LONG w.o. sign */ |
| 902 | #define MAX_BIGINT_WIDTH 20 /**< Max width for a LONGLONG */ |
| 903 | /// Max width for a CHAR column, in number of characters |
| 904 | #define MAX_CHAR_WIDTH 255 |
| 905 | /// Default width for blob in bytes @todo - align this with sizes from field.h |
| 906 | #define MAX_BLOB_WIDTH 16777216 |
| 907 | |
| 908 | #define NET_ERROR_UNSET 0 /**< No error has occurred yet */ |
| 909 | #define NET_ERROR_SOCKET_RECOVERABLE 1 /**< Socket still usable */ |
| 910 | #define NET_ERROR_SOCKET_UNUSABLE 2 /**< Do not use the socket */ |
| 911 | #define NET_ERROR_SOCKET_NOT_READABLE 3 /**< Try write and close socket */ |
| 912 | #define NET_ERROR_SOCKET_NOT_WRITABLE 4 /**< Try read and close socket */ |
| 913 | |
| 914 | typedef struct NET { |
| 915 | MYSQL_VIO vio; |
| 916 | unsigned char *buff, *buff_end, *write_pos, *read_pos; |
| 917 | my_socket fd; /* For Perl DBI/dbd */ |
| 918 | /** |
| 919 | Set if we are doing several queries in one |
| 920 | command ( as in LOAD TABLE ... FROM MASTER ), |
| 921 | and do not want to confuse the client with OK at the wrong time |
| 922 | */ |
| 923 | unsigned long remain_in_buf, length, buf_length, where_b; |
| 924 | unsigned long max_packet, max_packet_size; |
| 925 | unsigned int pkt_nr, compress_pkt_nr; |
| 926 | unsigned int write_timeout, read_timeout, retry_count; |
| 927 | int fcntl; |
| 928 | unsigned int *return_status; |
| 929 | unsigned char reading_or_writing; |
| 930 | unsigned char save_char; |
| 931 | bool compress; |
| 932 | unsigned int last_errno; |
| 933 | unsigned char error; |
| 934 | /** Client library error message buffer. Actually belongs to struct MYSQL. */ |
| 935 | char last_error[MYSQL_ERRMSG_SIZE]; |
| 936 | /** Client library sqlstate buffer. Set along with the error message. */ |
| 937 | char sqlstate[SQLSTATE_LENGTH + 1]; |
| 938 | /** |
| 939 | Extension pointer, for the caller private use. |
| 940 | Any program linking with the networking library can use this pointer, |
| 941 | which is handy when private connection specific data needs to be |
| 942 | maintained. |
| 943 | The mysqld server process uses this pointer internally, |
| 944 | to maintain the server internal instrumentation for the connection. |
| 945 | */ |
| 946 | void *extension; |
| 947 | } NET; |
| 948 | |
| 949 | #define packet_error (~(unsigned long)0) |
| 950 | |
| 951 | /** |
| 952 | @addtogroup group_cs_backward_compatibility Backward compatibility |
| 953 | @ingroup group_cs |
| 954 | @{ |
| 955 | */ |
| 956 | #define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS |
| 957 | #define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL |
| 958 | #define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL |
| 959 | #define FIELD_TYPE_TINY MYSQL_TYPE_TINY |
| 960 | #define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT |
| 961 | #define FIELD_TYPE_LONG MYSQL_TYPE_LONG |
| 962 | #define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT |
| 963 | #define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE |
| 964 | #define FIELD_TYPE_NULL MYSQL_TYPE_NULL |
| 965 | #define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP |
| 966 | #define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG |
| 967 | #define FIELD_TYPE_INT24 MYSQL_TYPE_INT24 |
| 968 | #define FIELD_TYPE_DATE MYSQL_TYPE_DATE |
| 969 | #define FIELD_TYPE_TIME MYSQL_TYPE_TIME |
| 970 | #define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME |
| 971 | #define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR |
| 972 | #define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE |
| 973 | #define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM |
| 974 | #define FIELD_TYPE_SET MYSQL_TYPE_SET |
| 975 | #define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB |
| 976 | #define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB |
| 977 | #define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB |
| 978 | #define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB |
| 979 | #define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING |
| 980 | #define FIELD_TYPE_STRING MYSQL_TYPE_STRING |
| 981 | #define FIELD_TYPE_CHAR MYSQL_TYPE_TINY |
| 982 | #define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM |
| 983 | #define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY |
| 984 | #define FIELD_TYPE_BIT MYSQL_TYPE_BIT |
| 985 | /** @}*/ |
| 986 | |
| 987 | /** |
| 988 | @addtogroup group_cs_shutdown_kill_constants Shutdown/kill enums and constants |
| 989 | @ingroup group_cs |
| 990 | |
| 991 | @sa THD::is_killable |
| 992 | @{ |
| 993 | */ |
| 994 | #define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0) |
| 995 | #define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1) |
| 996 | #define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2) |
| 997 | #define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3) |
| 998 | |
| 999 | /** |
| 1000 | We want levels to be in growing order of hardness (because we use number |
| 1001 | comparisons). |
| 1002 | |
| 1003 | @note ::SHUTDOWN_DEFAULT does not respect the growing property, but it's ok. |
| 1004 | */ |
| 1005 | enum mysql_enum_shutdown_level { |
| 1006 | SHUTDOWN_DEFAULT = 0, |
| 1007 | /** Wait for existing connections to finish */ |
| 1008 | SHUTDOWN_WAIT_CONNECTIONS = MYSQL_SHUTDOWN_KILLABLE_CONNECT, |
| 1009 | /** Wait for existing transactons to finish */ |
| 1010 | SHUTDOWN_WAIT_TRANSACTIONS = MYSQL_SHUTDOWN_KILLABLE_TRANS, |
| 1011 | /** Wait for existing updates to finish (=> no partial MyISAM update) */ |
| 1012 | SHUTDOWN_WAIT_UPDATES = MYSQL_SHUTDOWN_KILLABLE_UPDATE, |
| 1013 | /** Flush InnoDB buffers and other storage engines' buffers*/ |
| 1014 | SHUTDOWN_WAIT_ALL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1), |
| 1015 | /** Don't flush InnoDB buffers, flush other storage engines' buffers*/ |
| 1016 | SHUTDOWN_WAIT_CRITICAL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, |
| 1017 | /** Query level of the KILL command */ |
| 1018 | KILL_QUERY = 254, |
| 1019 | /** Connection level of the KILL command */ |
| 1020 | KILL_CONNECTION = 255 |
| 1021 | }; |
| 1022 | /** @}*/ |
| 1023 | |
| 1024 | enum enum_resultset_metadata { |
| 1025 | /** No metadata will be sent. */ |
| 1026 | RESULTSET_METADATA_NONE = 0, |
| 1027 | /** The server will send all metadata. */ |
| 1028 | RESULTSET_METADATA_FULL = 1 |
| 1029 | }; |
| 1030 | |
| 1031 | #if defined(__clang__) |
| 1032 | // disable -Wdocumentation to workaround |
| 1033 | // https://bugs.llvm.org/show_bug.cgi?id=38905 |
| 1034 | #pragma clang diagnostic push |
| 1035 | #pragma clang diagnostic ignored "-Wdocumentation" |
| 1036 | #endif |
| 1037 | /** |
| 1038 | The flags used in COM_STMT_EXECUTE. |
| 1039 | @sa @ref Protocol_classic::parse_packet, @ref mysql_int_serialize_param_data |
| 1040 | */ |
| 1041 | #if defined(__clang__) |
| 1042 | #pragma clang diagnostic pop |
| 1043 | #endif |
| 1044 | enum enum_cursor_type { |
| 1045 | CURSOR_TYPE_NO_CURSOR = 0, |
| 1046 | CURSOR_TYPE_READ_ONLY = 1, |
| 1047 | CURSOR_TYPE_FOR_UPDATE = 2, |
| 1048 | CURSOR_TYPE_SCROLLABLE = 4, |
| 1049 | /** |
| 1050 | On when the client will send the parameter count |
| 1051 | even for 0 parameters. |
| 1052 | */ |
| 1053 | PARAMETER_COUNT_AVAILABLE = 8 |
| 1054 | }; |
| 1055 | |
| 1056 | /** options for ::mysql_options() */ |
| 1057 | enum enum_mysql_set_option { |
| 1058 | MYSQL_OPTION_MULTI_STATEMENTS_ON, |
| 1059 | MYSQL_OPTION_MULTI_STATEMENTS_OFF |
| 1060 | }; |
| 1061 | |
| 1062 | /** |
| 1063 | Type of state change information that the server can include in the Ok |
| 1064 | packet. |
| 1065 | |
| 1066 | @note |
| 1067 | - session_state_type shouldn't go past 255 (i.e. 1-byte boundary). |
| 1068 | - Modify the definition of ::SESSION_TRACK_END when a new member is added. |
| 1069 | */ |
| 1070 | enum enum_session_state_type { |
| 1071 | SESSION_TRACK_SYSTEM_VARIABLES, /**< Session system variables */ |
| 1072 | SESSION_TRACK_SCHEMA, /**< Current schema */ |
| 1073 | SESSION_TRACK_STATE_CHANGE, /**< track session state changes */ |
| 1074 | SESSION_TRACK_GTIDS, /**< See also: session_track_gtids */ |
| 1075 | SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /**< Transaction chistics */ |
| 1076 | SESSION_TRACK_TRANSACTION_STATE /**< Transaction state */ |
| 1077 | }; |
| 1078 | |
| 1079 | /** start of ::enum_session_state_type */ |
| 1080 | #define SESSION_TRACK_BEGIN SESSION_TRACK_SYSTEM_VARIABLES |
| 1081 | |
| 1082 | /** End of ::enum_session_state_type */ |
| 1083 | #define SESSION_TRACK_END SESSION_TRACK_TRANSACTION_STATE |
| 1084 | |
| 1085 | /** is T a valid session state type */ |
| 1086 | #define IS_SESSION_STATE_TYPE(T) \ |
| 1087 | (((int)(T) >= SESSION_TRACK_BEGIN) && ((T) <= SESSION_TRACK_END)) |
| 1088 | |
| 1089 | #define net_new_transaction(net) ((net)->pkt_nr = 0) |
| 1090 | |
| 1091 | bool my_net_init(struct NET *net, MYSQL_VIO vio); |
| 1092 | void my_net_local_init(struct NET *net); |
| 1093 | void net_end(struct NET *net); |
| 1094 | void net_clear(struct NET *net, bool check_buffer); |
| 1095 | void net_claim_memory_ownership(struct NET *net, bool claim); |
| 1096 | bool net_realloc(struct NET *net, size_t length); |
| 1097 | bool net_flush(struct NET *net); |
| 1098 | bool my_net_write(struct NET *net, const unsigned char *packet, size_t len); |
| 1099 | bool net_write_command(struct NET *net, unsigned char command, |
| 1100 | const unsigned char *, size_t head_len, |
| 1101 | const unsigned char *packet, size_t len); |
| 1102 | bool net_write_packet(struct NET *net, const unsigned char *packet, |
| 1103 | size_t length); |
| 1104 | unsigned long my_net_read(struct NET *net); |
| 1105 | void my_net_set_write_timeout(struct NET *net, unsigned int timeout); |
| 1106 | void my_net_set_read_timeout(struct NET *net, unsigned int timeout); |
| 1107 | void my_net_set_retry_count(struct NET *net, unsigned int retry_count); |
| 1108 | |
| 1109 | struct rand_struct { |
| 1110 | unsigned long seed1, seed2, max_value; |
| 1111 | double max_value_dbl; |
| 1112 | }; |
| 1113 | |
| 1114 | /* Include the types here so existing UDFs can keep compiling */ |
| 1115 | #include "mysql/udf_registration_types.h" |
| 1116 | |
| 1117 | /** |
| 1118 | @addtogroup group_cs_compresson_constants Constants when using compression |
| 1119 | @ingroup group_cs |
| 1120 | @{ |
| 1121 | */ |
| 1122 | #define 4 /**< standard header size */ |
| 1123 | #define 3 /**< compression header extra size */ |
| 1124 | /** @}*/ |
| 1125 | |
| 1126 | /* Prototypes to password functions */ |
| 1127 | |
| 1128 | /* |
| 1129 | These functions are used for authentication by client and server and |
| 1130 | implemented in sql/password.c |
| 1131 | */ |
| 1132 | |
| 1133 | void randominit(struct rand_struct *, unsigned long seed1, unsigned long seed2); |
| 1134 | double my_rnd(struct rand_struct *); |
| 1135 | void create_random_string(char *to, unsigned int length, |
| 1136 | struct rand_struct *rand_st); |
| 1137 | |
| 1138 | void hash_password(unsigned long *to, const char *password, |
| 1139 | unsigned int password_len); |
| 1140 | void make_scrambled_password_323(char *to, const char *password); |
| 1141 | void scramble_323(char *to, const char *message, const char *password); |
| 1142 | bool check_scramble_323(const unsigned char *reply, const char *message, |
| 1143 | unsigned long *salt); |
| 1144 | void get_salt_from_password_323(unsigned long *res, const char *password); |
| 1145 | void make_password_from_salt_323(char *to, const unsigned long *salt); |
| 1146 | |
| 1147 | void make_scrambled_password(char *to, const char *password); |
| 1148 | void scramble(char *to, const char *message, const char *password); |
| 1149 | bool check_scramble(const unsigned char *reply, const char *message, |
| 1150 | const unsigned char *hash_stage2); |
| 1151 | void get_salt_from_password(unsigned char *res, const char *password); |
| 1152 | void make_password_from_salt(char *to, const unsigned char *hash_stage2); |
| 1153 | char *octet2hex(char *to, const char *str, unsigned int len); |
| 1154 | |
| 1155 | /* end of password.c */ |
| 1156 | |
| 1157 | bool generate_sha256_scramble(unsigned char *dst, size_t dst_size, |
| 1158 | const char *src, size_t src_size, const char *rnd, |
| 1159 | size_t rnd_size); |
| 1160 | |
| 1161 | // extern "C" since it is an (undocumented) part of the libmysql ABI. |
| 1162 | #ifdef __cplusplus |
| 1163 | extern "C" { |
| 1164 | #endif |
| 1165 | char *get_tty_password(const char *opt_message); |
| 1166 | #ifdef __cplusplus |
| 1167 | } |
| 1168 | #endif |
| 1169 | |
| 1170 | const char *mysql_errno_to_sqlstate(unsigned int mysql_errno); |
| 1171 | |
| 1172 | /* Some other useful functions */ |
| 1173 | |
| 1174 | // Need to be extern "C" for the time being, due to memcached. |
| 1175 | #ifdef __cplusplus |
| 1176 | extern "C" { |
| 1177 | #endif |
| 1178 | bool my_thread_init(void); |
| 1179 | void my_thread_end(void); |
| 1180 | #ifdef __cplusplus |
| 1181 | } |
| 1182 | #endif |
| 1183 | |
| 1184 | #ifdef STDCALL |
| 1185 | unsigned long STDCALL net_field_length(unsigned char **packet); |
| 1186 | unsigned long STDCALL net_field_length_checked(unsigned char **packet, |
| 1187 | unsigned long max_length); |
| 1188 | #endif |
| 1189 | uint64_t net_field_length_ll(unsigned char **packet); |
| 1190 | unsigned char *net_store_length(unsigned char *pkg, unsigned long long length); |
| 1191 | unsigned int net_length_size(unsigned long long num); |
| 1192 | unsigned int net_field_length_size(const unsigned char *pos); |
| 1193 | |
| 1194 | #define NULL_LENGTH ((unsigned long)~0) /**< For ::net_store_length() */ |
| 1195 | #define 4 |
| 1196 | #define 6 |
| 1197 | #endif |
| 1198 | |