group_replication_priv.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software Foundation,
  17. 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
  18. #ifndef GROUP_REPLICATION_PRIV_INCLUDE
  19. #define GROUP_REPLICATION_PRIV_INCLUDE
  20. #ifndef MYSQL_SERVER
  21. #define MYSQL_SERVER
  22. #endif
  23. #ifndef HAVE_REPLICATION
  24. #define HAVE_REPLICATION
  25. #endif
  26. #include <my_global.h>
  27. #include <my_thread.h>
  28. #include <my_sys.h>
  29. #include <debug_sync.h>
  30. #include <log_event.h>
  31. #include <replication.h>
  32. #include <rpl_channel_service_interface.h>
  33. #include <rpl_gtid.h>
  34. #include <rpl_write_set_handler.h>
  35. /**
  36. Server side initializations.
  37. */
  38. int group_replication_init();
  39. /**
  40. Returns the server connection attribute
  41. @Note This method implementation is on sql_class.cc
  42. @return the pthread for the connection attribute.
  43. */
  44. my_thread_attr_t *get_connection_attrib();
  45. /**
  46. Returns the server hostname, port and uuid.
  47. @param[out] hostname
  48. @param[out] port
  49. @param[out] uuid
  50. @param[out] server_version
  51. @param[out] server_ssl_variables
  52. */
  53. void get_server_parameters(char **hostname, uint *port, char **uuid,
  54. unsigned int *server_version,
  55. st_server_ssl_variables* server_ssl_variables);
  56. /**
  57. Returns the server_id.
  58. @return server_id
  59. */
  60. ulong get_server_id();
  61. /**
  62. Returns the server auto_increment_increment
  63. @return auto_increment_increment
  64. */
  65. ulong get_auto_increment_increment();
  66. /**
  67. Returns the server auto_increment_offset
  68. @return auto_increment_offset
  69. */
  70. ulong get_auto_increment_offset();
  71. /**
  72. Set server auto_increment_increment
  73. @param[in] auto_increment_increment
  74. */
  75. void set_auto_increment_increment(ulong auto_increment_increment);
  76. /**
  77. Set server auto_increment_offset
  78. @param[in] auto_increment_offset
  79. */
  80. void set_auto_increment_offset(ulong auto_increment_offset);
  81. /**
  82. Returns a struct containing all server startup information needed to evaluate
  83. if one has conditions to proceed executing master-master replication.
  84. @param[out] requirements
  85. @param[in] has_lock Caller should set this to true if the calling
  86. thread holds gtid_mode_lock; otherwise set it to false.
  87. */
  88. void get_server_startup_prerequirements(Trans_context_info& requirements,
  89. bool has_lock);
  90. /**
  91. Returns the server GTID_EXECUTED encoded as a binary string.
  92. @note Memory allocated to encoded_gtid_executed must be release by caller.
  93. @param[out] encoded_gtid_executed binary string
  94. @param[out] length binary string length
  95. */
  96. bool get_server_encoded_gtid_executed(uchar **encoded_gtid_executed,
  97. size_t *length);
  98. #if !defined(DBUG_OFF)
  99. /**
  100. Returns a text representation of a encoded GTID set.
  101. @note Memory allocated to returned pointer must be release by caller.
  102. @param[in] encoded_gtid_set binary string
  103. @param[in] length binary string length
  104. @return a pointer to text representation of the encoded set
  105. */
  106. char* encoded_gtid_set_to_string(uchar *encoded_gtid_set, size_t length);
  107. #endif
  108. /**
  109. Return last gno for a given sidno, see
  110. Gtid_state::get_last_executed_gno() for details.
  111. */
  112. rpl_gno get_last_executed_gno(rpl_sidno sidno);
  113. /**
  114. Return sidno for a given sid, see Sid_map::add_sid() for details.
  115. */
  116. rpl_sidno get_sidno_from_global_sid_map(rpl_sid sid);
  117. /**
  118. Set slave thread default options.
  119. @param[in] thd The thread
  120. */
  121. void set_slave_thread_options(THD* thd);
  122. /**
  123. Add thread to Global_THD_manager singleton.
  124. @param[in] thd The thread
  125. */
  126. void global_thd_manager_add_thd(THD *thd);
  127. /**
  128. Remove thread from Global_THD_manager singleton.
  129. @param[in] thd The thread
  130. */
  131. void global_thd_manager_remove_thd(THD *thd);
  132. /**
  133. Function that returns the write set extraction algorithm name.
  134. @param[in] algorithm The algorithm value
  135. @return the algorithm name
  136. */
  137. const char* get_write_set_algorithm_string(unsigned int algorithm);
  138. /**
  139. Returns the value of slave_max_allowed_packet.
  140. @return slave_max_allowed_packet
  141. */
  142. unsigned long get_slave_max_allowed_packet();
  143. #endif /* GROUP_REPLICATION_PRIV_INCLUDE */