common_constants.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License, version 2.0, as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is also distributed with certain software (including
  9. * but not limited to OpenSSL) that is licensed under separate terms,
  10. * as designated in a particular file or component or in included license
  11. * documentation. The authors of MySQL hereby grant you an
  12. * additional permission to link the program and your derivative works
  13. * with the separately licensed software that they have included with
  14. * MySQL.
  15. *
  16. * Without limiting anything contained in the foregoing, this file,
  17. * which is part of MySQL Connector/C++, is also subject to the
  18. * Universal FOSS Exception, version 1.0, a copy of which can be found at
  19. * http://oss.oracle.com/licenses/universal-foss-exception.
  20. *
  21. * This program is distributed in the hope that it will be useful, but
  22. * WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24. * See the GNU General Public License, version 2.0, for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #ifndef MYSQL_COMMON_CONSTANTS_H
  31. #define MYSQL_COMMON_CONSTANTS_H
  32. #define DEFAULT_MYSQL_PORT 3306
  33. #define DEFAULT_MYSQLX_PORT 33060
  34. // ----------------------------------------------------------------------------
  35. /*
  36. Common constants
  37. ================
  38. Warning: Values of these constants are part of the public API. Changing them
  39. is a non backward compatible API change.
  40. Note: Value of 0 is reserved for special uses and thus constant values
  41. are always > 0.
  42. */
  43. /*
  44. Note: the empty END_LIST macro at the end of list macros helps Doxygen
  45. correctly interpret documentation for the list item.
  46. */
  47. #undef END_LIST
  48. #define END_LIST
  49. #define CLIENT_OPTION_LIST(x) \
  50. OPT_BOOL(x,POOLING,1) /*!< disable/enable the pool. (Enabled by default)*/ \
  51. OPT_NUM(x,POOL_MAX_SIZE,2) /*!< size of the pool. (Defaults to 25)*/ \
  52. OPT_NUM(x,POOL_QUEUE_TIMEOUT,3) /*!< timeout for waiting for a connection in
  53. the pool (ms). (No timeout by default)*/ \
  54. OPT_NUM(x,POOL_MAX_IDLE_TIME,4)/*!< time for a connection to be in the pool
  55. without being used (ms).(Will not expire by default)*/ \
  56. OPT_END(x,LAST,5) // ALWAYS POINTS TO LAST VALUE
  57. END_LIST
  58. #define SESSION_OPTION_LIST(x) \
  59. OPT_STR(x,URI,1) /*!< connection URI or string */ \
  60. /*! DNS name of the host, IPv4 address or IPv6 address */ \
  61. OPT_STR(x,HOST,2) \
  62. OPT_NUM(x,PORT,3) /*!< X Plugin port to connect to */ \
  63. /*! Assign a priority (a number in range 1 to 100) to the last specified
  64. host; these priorities are used to determine the order in which multiple
  65. hosts are tried by the connection fail-over logic (see description
  66. of `Session` class) */ \
  67. OPT_NUM(x,PRIORITY,4) \
  68. OPT_STR(x,USER,5) /*!< user name */ \
  69. OPT_STR(x,PWD,6) /*!< password */ \
  70. OPT_STR(x,DB,7) /*!< default database */ \
  71. OPT_ANY(x,SSL_MODE,8) /*!< define `SSLMode` option to be used */ \
  72. /*! path to a PEM file specifying trusted root certificates*/ \
  73. OPT_STR(x,SSL_CA,9) \
  74. OPT_ANY(x,AUTH,10) /*!< authentication method, PLAIN, MYSQL41, etc.*/ \
  75. OPT_STR(x,SOCKET,11) \
  76. OPT_NUM(x,CONNECT_TIMEOUT,12) \
  77. END_LIST
  78. #define OPT_STR(X,Y,N) X##_str(Y,N)
  79. #define OPT_BOOL(X,Y,N) X##_bool(Y,N)
  80. #define OPT_NUM(X,Y,N) X##_num(Y,N)
  81. #define OPT_ANY(X,Y,N) X##_any(Y,N)
  82. #define OPT_END(X,Y,N) X##_end(Y,N)
  83. /*
  84. Names for options supported in the query part of a connection string and
  85. how they map to session options above.
  86. */
  87. #define URI_OPTION_LIST(X) \
  88. X("ssl-mode", SSL_MODE) \
  89. X("ssl-ca", SSL_CA) \
  90. X("auth", AUTH) \
  91. X("connect-timeout", CONNECT_TIMEOUT) \
  92. END_LIST
  93. #define SSL_MODE_LIST(x) \
  94. x(DISABLED,1) /*!< Establish an unencrypted connection. */ \
  95. x(REQUIRED,2) /*!< Establish a secure connection if the server supports
  96. secure connections. The connection attempt fails if a
  97. secure connection cannot be established. This is the
  98. default if `SSL_MODE` is not specified. */ \
  99. x(VERIFY_CA,3) /*!< Like `REQUIRED`, but additionally verify the server
  100. TLS certificate against the configured Certificate
  101. Authority (CA) certificates (defined by `SSL_CA`
  102. Option). The connection attempt fails if no valid
  103. matching CA certificates are found.*/ \
  104. x(VERIFY_IDENTITY,4) /*!< Like `VERIFY_CA`, but additionally verify that the
  105. server certificate matches the host to which the
  106. connection is attempted.*/\
  107. END_LIST
  108. #define AUTH_METHOD_LIST(x)\
  109. x(PLAIN,1) /*!< Plain text authentication method. The password is
  110. sent as a clear text. This method is used by
  111. default in encrypted connections. */ \
  112. x(MYSQL41,2) /*!< Authentication method supported by MySQL 4.1 and newer.
  113. The password is hashed before being sent to the server.
  114. This authentication method works over unencrypted
  115. connections */ \
  116. x(EXTERNAL,3) /*!< External authentication when the server establishes
  117. the user authenticity by other means such as SSL/x509
  118. certificates. Currently not supported by X Plugin */ \
  119. x(SHA256_MEMORY,4) /*!< Authentication using SHA256 password hashes stored in
  120. server-side cache. This authentication method works
  121. over unencrypted connections.
  122. */ \
  123. END_LIST
  124. /*
  125. Types that can be reported by MySQL server.
  126. */
  127. #define RESULT_TYPE_LIST(X) \
  128. X(BIT, 1) \
  129. X(TINYINT, 2) \
  130. X(SMALLINT, 3) \
  131. X(MEDIUMINT, 4) \
  132. X(INT, 5) \
  133. X(BIGINT, 6) \
  134. X(FLOAT, 7) \
  135. X(DECIMAL, 8) \
  136. X(DOUBLE, 9) \
  137. X(JSON, 10) \
  138. X(STRING, 11) \
  139. X(BYTES, 12) \
  140. X(TIME, 13) \
  141. X(DATE, 14) \
  142. X(DATETIME, 15) \
  143. X(TIMESTAMP, 16) \
  144. X(SET, 17) \
  145. X(ENUM, 18) \
  146. X(GEOMETRY, 19) \
  147. END_LIST
  148. /*
  149. Check options for an updatable view.
  150. @see https://dev.mysql.com/doc/refman/en/view-check-option.html
  151. */
  152. #define VIEW_CHECK_OPTION_LIST(x) \
  153. x(CASCADED,1) \
  154. x(LOCAL,2) \
  155. END_LIST
  156. /*
  157. Algorithms used to process views.
  158. @see https://dev.mysql.com/doc/refman/en/view-algorithms.html
  159. */
  160. #define VIEW_ALGORITHM_LIST(x) \
  161. x(UNDEFINED,1) \
  162. x(MERGE,2) \
  163. x(TEMPTABLE,3) \
  164. END_LIST
  165. /*
  166. View security settings.
  167. @see https://dev.mysql.com/doc/refman/en/stored-programs-security.html
  168. */
  169. #define VIEW_SECURITY_LIST(x) \
  170. x(DEFINER,1) \
  171. x(INVOKER,2) \
  172. END_LIST
  173. #define LOCK_MODE_LIST(X) \
  174. X(SHARED,1) /*!< Sets a shared mode lock on any rows that
  175. are read. Other sessions can read the rows,
  176. but cannot modify them until your transaction
  177. commits. If any of these rows were changed by
  178. another transaction that has not yet committed,
  179. your query waits until that transaction ends
  180. and then uses the latest values. */ \
  181. X(EXCLUSIVE,2) /*!< For index records the search encounters,
  182. locks the rows and any associated index entries, the same
  183. as if you issued an UPDATE statement for those rows. Other
  184. transactions are blocked from updating those rows,
  185. from doing locking in LOCK_SHARED, or from reading
  186. the data in certain transaction isolation levels. */ \
  187. END_LIST
  188. #define LOCK_CONTENTION_LIST(X) \
  189. X(DEFAULT,0) /*!< Block query until existing row locks are released. */ \
  190. X(NOWAIT,1) /*!< Return error if lock could not be obtained immediately. */ \
  191. X(SKIP_LOCKED,2) /*!< Execute query immediately, excluding items that are
  192. locked from the query results. */ \
  193. END_LIST
  194. // ----------------------------------------------------------------------------
  195. #endif