1 /* 2 Copyright (c) 2013, 2020, 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, 6 as 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 additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 23 24 #ifndef TABLE_REPLICATION_CONFIGURATION_H 25 #define TABLE_REPLICATION_CONFIGURATION_H 26 27 /** 28 @file storage/perfschema/table_replication_connection_configuration.h 29 Table replication_connection_configuration (declarations). 30 */ 31 32 #include <sys/types.h> 33 34 #include "compression.h" // COMPRESSION_ALGORITHM_NAME_BUFFER_SIZE 35 #include "my_base.h" 36 #include "my_io.h" 37 #include "mysql_com.h" 38 #include "sql/rpl_info.h" /* CHANNEL_NAME_LENGTH*/ 39 #include "storage/perfschema/pfs_engine_table.h" 40 #include "storage/perfschema/table_helper.h" 41 42 class Field; 43 class Master_info; 44 class Plugin_table; 45 struct TABLE; 46 struct THR_LOCK; 47 48 /** 49 @addtogroup performance_schema_tables 50 @{ 51 */ 52 53 #ifndef ENUM_RPL_YES_NO 54 #define ENUM_RPL_YES_NO 55 enum enum_rpl_yes_no { PS_RPL_YES = 1, PS_RPL_NO }; 56 #endif 57 58 /** enum values for SSL_Allowed*/ 59 enum enum_ssl_allowed { 60 PS_SSL_ALLOWED_YES = 1, 61 PS_SSL_ALLOWED_NO, 62 PS_SSL_ALLOWED_IGNORED 63 }; 64 65 /** 66 A row in the table. The fields with string values have an additional 67 length field denoted by \<field_name\>_length. 68 */ 69 struct st_row_connect_config { 70 char channel_name[CHANNEL_NAME_LENGTH]; 71 uint channel_name_length; 72 char host[HOSTNAME_LENGTH]; 73 uint host_length; 74 uint port; 75 char user[USERNAME_LENGTH]; 76 uint user_length; 77 char network_interface[HOSTNAME_LENGTH]; 78 uint network_interface_length; 79 enum_rpl_yes_no auto_position; 80 enum_ssl_allowed ssl_allowed; 81 char ssl_ca_file[FN_REFLEN]; 82 uint ssl_ca_file_length; 83 char ssl_ca_path[FN_REFLEN]; 84 uint ssl_ca_path_length; 85 char ssl_certificate[FN_REFLEN]; 86 uint ssl_certificate_length; 87 char ssl_cipher[FN_REFLEN]; 88 uint ssl_cipher_length; 89 char ssl_key[FN_REFLEN]; 90 uint ssl_key_length; 91 enum_rpl_yes_no ssl_verify_server_certificate; 92 char ssl_crl_file[FN_REFLEN]; 93 uint ssl_crl_file_length; 94 char ssl_crl_path[FN_REFLEN]; 95 uint ssl_crl_path_length; 96 uint connection_retry_interval; 97 ulong connection_retry_count; 98 double heartbeat_interval; 99 char tls_version[FN_REFLEN]; 100 uint tls_version_length; 101 char public_key_path[FN_REFLEN]; 102 uint public_key_path_length; 103 enum_rpl_yes_no get_public_key; 104 char network_namespace[NAME_LEN]; 105 uint network_namespace_length; 106 char compression_algorithm[COMPRESSION_ALGORITHM_NAME_BUFFER_SIZE]; 107 uint compression_algorithm_length; 108 uint zstd_compression_level; 109 /* 110 tls_ciphersuites = NULL means that TLS 1.3 default ciphersuites 111 are enabled. To allow a value that can either be NULL or a string, 112 it is represented by the pair: 113 first: true if tls_ciphersuites is set to NULL 114 second: the string value when first is false 115 */ 116 std::pair<bool, std::string> tls_ciphersuites = {true, ""}; 117 }; 118 119 class PFS_index_rpl_connection_config : public PFS_engine_index { 120 public: PFS_index_rpl_connection_config()121 PFS_index_rpl_connection_config() 122 : PFS_engine_index(&m_key), m_key("CHANNEL_NAME") {} 123 ~PFS_index_rpl_connection_config()124 ~PFS_index_rpl_connection_config() {} 125 126 virtual bool match(Master_info *mi); 127 128 private: 129 PFS_key_name m_key; 130 }; 131 132 /** Table PERFORMANCE_SCHEMA.TABLE_REPLICATION_CONNECTION_CONFIGURATION. */ 133 class table_replication_connection_configuration : public PFS_engine_table { 134 typedef PFS_simple_index pos_t; 135 136 private: 137 int make_row(Master_info *); 138 139 /** Table share lock. */ 140 static THR_LOCK m_table_lock; 141 /** Table definition. */ 142 static Plugin_table m_table_def; 143 144 /** Current row */ 145 st_row_connect_config m_row; 146 /** Current position. */ 147 pos_t m_pos; 148 /** Next position. */ 149 pos_t m_next_pos; 150 151 protected: 152 /** 153 Read the current row values. 154 @param table Table handle 155 @param buf row buffer 156 @param fields Table fields 157 @param read_all true if all columns are read. 158 */ 159 160 virtual int read_row_values(TABLE *table, unsigned char *buf, Field **fields, 161 bool read_all); 162 163 table_replication_connection_configuration(); 164 165 public: 166 ~table_replication_connection_configuration(); 167 168 /** Table share. */ 169 static PFS_engine_table_share m_share; 170 static PFS_engine_table *create(PFS_engine_table_share *); 171 static ha_rows get_row_count(); 172 virtual void reset_position(void); 173 174 virtual int rnd_next(); 175 virtual int rnd_pos(const void *pos); 176 177 virtual int index_init(uint idx, bool sorted); 178 virtual int index_next(); 179 180 private: 181 PFS_index_rpl_connection_config *m_opened_index; 182 }; 183 184 /** @} */ 185 #endif 186