| 1 | /* Copyright (c) 2009, 2010, Oracle and/or its affiliates. |
| 2 | Copyright (c) 2012, 2014, Monty Program Ab |
| 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 as published by |
| 6 | the Free Software Foundation; version 2 of the License. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 16 | |
| 17 | /* support for Services */ |
| 18 | #include <service_versions.h> |
| 19 | #include <mysql/service_wsrep.h> |
| 20 | |
| 21 | struct st_service_ref { |
| 22 | const char *name; |
| 23 | uint version; |
| 24 | void *service; |
| 25 | }; |
| 26 | |
| 27 | static struct my_snprintf_service_st my_snprintf_handler = { |
| 28 | my_snprintf, |
| 29 | my_vsnprintf |
| 30 | }; |
| 31 | |
| 32 | static struct thd_alloc_service_st thd_alloc_handler= { |
| 33 | thd_alloc, |
| 34 | thd_calloc, |
| 35 | thd_strdup, |
| 36 | thd_strmake, |
| 37 | thd_memdup, |
| 38 | thd_make_lex_string |
| 39 | }; |
| 40 | |
| 41 | static struct thd_wait_service_st thd_wait_handler= { |
| 42 | thd_wait_begin, |
| 43 | thd_wait_end |
| 44 | }; |
| 45 | |
| 46 | static struct progress_report_service_st progress_report_handler= { |
| 47 | thd_progress_init, |
| 48 | thd_progress_report, |
| 49 | thd_progress_next_stage, |
| 50 | thd_progress_end, |
| 51 | set_thd_proc_info |
| 52 | }; |
| 53 | |
| 54 | static struct kill_statement_service_st thd_kill_statement_handler= { |
| 55 | thd_kill_level |
| 56 | }; |
| 57 | |
| 58 | static struct thd_timezone_service_st thd_timezone_handler= { |
| 59 | thd_TIME_to_gmt_sec, |
| 60 | thd_gmt_sec_to_TIME |
| 61 | }; |
| 62 | |
| 63 | static struct my_sha2_service_st my_sha2_handler = { |
| 64 | my_sha224, |
| 65 | my_sha224_multi, |
| 66 | my_sha224_context_size, |
| 67 | my_sha224_init, |
| 68 | my_sha224_input, |
| 69 | my_sha224_result, |
| 70 | my_sha256, |
| 71 | my_sha256_multi, |
| 72 | my_sha256_context_size, |
| 73 | my_sha256_init, |
| 74 | my_sha256_input, |
| 75 | my_sha256_result, |
| 76 | my_sha384, |
| 77 | my_sha384_multi, |
| 78 | my_sha384_context_size, |
| 79 | my_sha384_init, |
| 80 | my_sha384_input, |
| 81 | my_sha384_result, |
| 82 | my_sha512, |
| 83 | my_sha512_multi, |
| 84 | my_sha512_context_size, |
| 85 | my_sha512_init, |
| 86 | my_sha512_input, |
| 87 | my_sha512_result, |
| 88 | }; |
| 89 | |
| 90 | static struct my_sha1_service_st my_sha1_handler = { |
| 91 | my_sha1, |
| 92 | my_sha1_multi, |
| 93 | my_sha1_context_size, |
| 94 | my_sha1_init, |
| 95 | my_sha1_input, |
| 96 | my_sha1_result |
| 97 | }; |
| 98 | |
| 99 | static struct my_md5_service_st my_md5_handler = { |
| 100 | my_md5, |
| 101 | my_md5_multi, |
| 102 | my_md5_context_size, |
| 103 | my_md5_init, |
| 104 | my_md5_input, |
| 105 | my_md5_result |
| 106 | }; |
| 107 | |
| 108 | static struct logger_service_st logger_service_handler= { |
| 109 | logger_init_mutexes, |
| 110 | logger_open, |
| 111 | logger_close, |
| 112 | logger_vprintf, |
| 113 | logger_printf, |
| 114 | logger_write, |
| 115 | logger_rotate |
| 116 | }; |
| 117 | |
| 118 | static struct thd_autoinc_service_st thd_autoinc_handler= { |
| 119 | thd_get_autoinc |
| 120 | }; |
| 121 | |
| 122 | static struct thd_rnd_service_st thd_rnd_handler= { |
| 123 | thd_rnd, |
| 124 | thd_create_random_password |
| 125 | }; |
| 126 | |
| 127 | static struct base64_service_st base64_handler= { |
| 128 | my_base64_needed_encoded_length, |
| 129 | my_base64_encode_max_arg_length, |
| 130 | my_base64_needed_decoded_length, |
| 131 | my_base64_decode_max_arg_length, |
| 132 | my_base64_encode, |
| 133 | my_base64_decode |
| 134 | }; |
| 135 | |
| 136 | static struct thd_error_context_service_st thd_error_context_handler= { |
| 137 | thd_get_error_message, |
| 138 | thd_get_error_number, |
| 139 | thd_get_error_row, |
| 140 | thd_inc_error_row, |
| 141 | thd_get_error_context_description |
| 142 | }; |
| 143 | |
| 144 | static struct wsrep_service_st wsrep_handler = { |
| 145 | get_wsrep, |
| 146 | get_wsrep_certify_nonPK, |
| 147 | get_wsrep_debug, |
| 148 | get_wsrep_drupal_282555_workaround, |
| 149 | get_wsrep_recovery, |
| 150 | get_wsrep_load_data_splitting, |
| 151 | get_wsrep_log_conflicts, |
| 152 | get_wsrep_protocol_version, |
| 153 | wsrep_aborting_thd_contains, |
| 154 | wsrep_aborting_thd_enqueue, |
| 155 | wsrep_consistency_check, |
| 156 | wsrep_is_wsrep_xid, |
| 157 | wsrep_xid_seqno, |
| 158 | wsrep_xid_uuid, |
| 159 | wsrep_lock_rollback, |
| 160 | wsrep_on, |
| 161 | wsrep_post_commit, |
| 162 | wsrep_prepare_key, |
| 163 | wsrep_run_wsrep_commit, |
| 164 | wsrep_thd_LOCK, |
| 165 | wsrep_thd_UNLOCK, |
| 166 | wsrep_thd_awake, |
| 167 | wsrep_thd_conflict_state, |
| 168 | wsrep_thd_conflict_state_str, |
| 169 | wsrep_thd_exec_mode, |
| 170 | wsrep_thd_exec_mode_str, |
| 171 | wsrep_thd_get_conflict_state, |
| 172 | wsrep_thd_is_BF, |
| 173 | wsrep_thd_is_wsrep, |
| 174 | wsrep_thd_query, |
| 175 | wsrep_thd_query_state, |
| 176 | wsrep_thd_query_state_str, |
| 177 | wsrep_thd_retry_counter, |
| 178 | wsrep_thd_set_conflict_state, |
| 179 | wsrep_thd_ignore_table, |
| 180 | wsrep_thd_trx_seqno, |
| 181 | wsrep_thd_ws_handle, |
| 182 | wsrep_trx_is_aborting, |
| 183 | wsrep_trx_order_before, |
| 184 | wsrep_unlock_rollback |
| 185 | }; |
| 186 | |
| 187 | static struct thd_specifics_service_st thd_specifics_handler= |
| 188 | { |
| 189 | thd_key_create, |
| 190 | thd_key_delete, |
| 191 | thd_getspecific, |
| 192 | thd_setspecific |
| 193 | }; |
| 194 | |
| 195 | static struct encryption_scheme_service_st encryption_scheme_handler= |
| 196 | { |
| 197 | encryption_scheme_encrypt, |
| 198 | encryption_scheme_decrypt |
| 199 | }; |
| 200 | |
| 201 | static struct my_crypt_service_st crypt_handler= |
| 202 | { |
| 203 | my_aes_crypt_init, |
| 204 | my_aes_crypt_update, |
| 205 | my_aes_crypt_finish, |
| 206 | my_aes_crypt, |
| 207 | my_aes_get_size, |
| 208 | my_aes_ctx_size, |
| 209 | my_random_bytes |
| 210 | }; |
| 211 | |
| 212 | static struct my_print_error_service_st my_print_error_handler= |
| 213 | { |
| 214 | my_error, |
| 215 | my_printf_error, |
| 216 | my_printv_error |
| 217 | }; |
| 218 | |
| 219 | static struct st_service_ref list_of_services[]= |
| 220 | { |
| 221 | { "base64_service" , VERSION_base64, &base64_handler }, |
| 222 | { "debug_sync_service" , VERSION_debug_sync, 0 }, // updated in plugin_init() |
| 223 | { "encryption_scheme_service" , VERSION_encryption_scheme, &encryption_scheme_handler }, |
| 224 | { "encryption_service" , VERSION_encryption, &encryption_handler }, |
| 225 | { "logger_service" , VERSION_logger, &logger_service_handler }, |
| 226 | { "my_crypt_service" , VERSION_my_crypt, &crypt_handler}, |
| 227 | { "my_md5_service" , VERSION_my_md5, &my_md5_handler}, |
| 228 | { "my_print_error_service" , VERSION_my_print_error, &my_print_error_handler}, |
| 229 | { "my_sha1_service" , VERSION_my_sha1, &my_sha1_handler}, |
| 230 | { "my_sha2_service" , VERSION_my_sha2, &my_sha2_handler}, |
| 231 | { "my_snprintf_service" , VERSION_my_snprintf, &my_snprintf_handler }, |
| 232 | { "progress_report_service" , VERSION_progress_report, &progress_report_handler }, |
| 233 | { "thd_alloc_service" , VERSION_thd_alloc, &thd_alloc_handler }, |
| 234 | { "thd_autoinc_service" , VERSION_thd_autoinc, &thd_autoinc_handler }, |
| 235 | { "thd_error_context_service" , VERSION_thd_error_context, &thd_error_context_handler }, |
| 236 | { "thd_kill_statement_service" , VERSION_kill_statement, &thd_kill_statement_handler }, |
| 237 | { "thd_rnd_service" , VERSION_thd_rnd, &thd_rnd_handler }, |
| 238 | { "thd_specifics_service" , VERSION_thd_specifics, &thd_specifics_handler }, |
| 239 | { "thd_timezone_service" , VERSION_thd_timezone, &thd_timezone_handler }, |
| 240 | { "thd_wait_service" , VERSION_thd_wait, &thd_wait_handler }, |
| 241 | { "wsrep_service" , VERSION_wsrep, &wsrep_handler } |
| 242 | }; |
| 243 | |
| 244 | |