capabilities.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //
  2. // Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_IMPL_INTERNAL_PROTOCOL_CAPABILITIES_HPP
  8. #define BOOST_MYSQL_IMPL_INTERNAL_PROTOCOL_CAPABILITIES_HPP
  9. #include <cstdint>
  10. namespace boost {
  11. namespace mysql {
  12. namespace detail {
  13. enum class capabilities : std::uint32_t
  14. {
  15. // CLIENT_LONG_PASSWORD: Use the improved version of Old Password Authentication
  16. long_password = 1,
  17. // CLIENT_FOUND_ROWS: Send found rows instead of affected rows in EOF_Packet
  18. found_rows = 2,
  19. // CLIENT_LONG_FLAG: Get all column flags
  20. long_flag = 4,
  21. // CLIENT_CONNECT_WITH_DB: Database (schema) name can be specified on connect in Handshake Response Packet
  22. connect_with_db = 8,
  23. // CLIENT_NO_SCHEMA: Don't allow database.table.column
  24. no_schema = 16,
  25. // CLIENT_COMPRESS: Compression protocol supported
  26. compress = 32,
  27. // CLIENT_ODBC: Special handling of ODBC behavior
  28. odbc = 64,
  29. // CLIENT_LOCAL_FILES: Can use LOAD DATA LOCAL
  30. local_files = 128,
  31. // CLIENT_IGNORE_SPACE: Ignore spaces before '('
  32. ignore_space = 256,
  33. // CLIENT_PROTOCOL_41: New 4.1 protocol
  34. protocol_41 = 512,
  35. // CLIENT_INTERACTIVE: This is an interactive client
  36. interactive = 1024,
  37. // CLIENT_SSL: Use SSL encryption for the session
  38. ssl = 2048,
  39. // CLIENT_IGNORE_SIGPIPE: Client only flag
  40. ignore_sigpipe = 4096,
  41. // CLIENT_TRANSACTIONS: Client knows about transactions
  42. transactions = 8192,
  43. // CLIENT_RESERVED: DEPRECATED: Old flag for 4.1 protocol
  44. reserved = 16384,
  45. // CLIENT_SECURE_CONNECTION: DEPRECATED: Old flag for 4.1 authentication, required by MariaDB
  46. secure_connection = 32768,
  47. // CLIENT_MULTI_STATEMENTS: Enable/disable multi-stmt support
  48. multi_statements = (1UL << 16),
  49. // CLIENT_MULTI_RESULTS: Enable/disable multi-results
  50. multi_results = (1UL << 17),
  51. // CLIENT_PS_MULTI_RESULTS: Multi-results and OUT parameters in PS-protocol
  52. ps_multi_results = (1UL << 18),
  53. // CLIENT_PLUGIN_AUTH: Client supports plugin authentication
  54. plugin_auth = (1UL << 19),
  55. // CLIENT_CONNECT_ATTRS: Client supports connection attributes
  56. connect_attrs = (1UL << 20),
  57. // CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA: Enable authentication response packet to be larger than 255
  58. // bytes
  59. plugin_auth_lenenc_data = (1UL << 21),
  60. // CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS: Don't close the connection for a user account with expired
  61. // password
  62. can_handle_expired_passwords = (1UL << 22),
  63. // CLIENT_SESSION_TRACK: Capable of handling server state change information
  64. session_track = (1UL << 23),
  65. // CLIENT_DEPRECATE_EOF: Client no longer needs EOF_Packet and will use OK_Packet instead
  66. deprecate_eof = (1UL << 24),
  67. // CLIENT_SSL_VERIFY_SERVER_CERT: Verify server certificate
  68. ssl_verify_server_cert = (1UL << 30),
  69. // CLIENT_OPTIONAL_RESULTSET_METADATA: The client can handle optional metadata information in the
  70. // resultset
  71. optional_resultset_metadata = (1UL << 25),
  72. // CLIENT_REMEMBER_OPTIONS: Don't reset the options after an unsuccessful connect
  73. remember_options = (1UL << 31),
  74. };
  75. constexpr capabilities operator&(capabilities lhs, capabilities rhs)
  76. {
  77. return static_cast<capabilities>(static_cast<std::uint32_t>(lhs) & static_cast<std::uint32_t>(rhs));
  78. }
  79. constexpr capabilities operator|(capabilities lhs, capabilities rhs)
  80. {
  81. return static_cast<capabilities>(static_cast<std::uint32_t>(lhs) | static_cast<std::uint32_t>(rhs));
  82. }
  83. // Are all capabilities in subset in caps?
  84. constexpr bool has_capabilities(capabilities caps, capabilities subset) { return (caps & subset) == subset; }
  85. } // namespace detail
  86. } // namespace mysql
  87. } // namespace boost
  88. #endif