MySQL 9.0.0
Source Code Documentation
keyring_log_builtins_definition.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
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 KEYRING_LOG_BUILTINS_DEFINITION_INCLUDED
25#define KEYRING_LOG_BUILTINS_DEFINITION_INCLUDED
26
29
31
33
35 public:
36 /* ================ DUMMY ================ */
37 /* log_builtins */
40 }
41 static DEFINE_METHOD(int, wellknown_by_name, (const char *, size_t)) {
43 }
45 return LOG_ITEM_END;
46 }
47 static DEFINE_METHOD(const char *, wellknown_get_name, (uint)) {
48 return "--ERROR--";
49 }
50 static DEFINE_METHOD(int, item_inconsistent, (log_item *)) { return -2; }
52 return true;
53 }
55 return false;
56 }
58 return false;
59 }
60
62 (log_item *, log_item_type, const char *, uint32)) {
63 return nullptr;
64 }
66 return nullptr;
67 }
68 static DEFINE_METHOD(bool, item_set_float, (log_item_data *, double)) {
69 return false;
70 }
71
72 static DEFINE_METHOD(int, line_item_count, (log_line *)) { return 0; }
74 return nullptr;
75 }
77 return nullptr;
78 }
81 return nullptr;
82 }
84 return nullptr;
85 }
87 return nullptr;
88 }
89 static DEFINE_METHOD(int, sanitize, (log_item *)) { return -1; }
91 (const char *, size_t)) {
92 return 0;
93 }
94 static DEFINE_METHOD(const char *, label_from_prio, (int)) { return "Error"; }
96 (const char *, void **)) {
98 }
100 (void *, const char *, size_t)) {
102 }
103 static DEFINE_METHOD(int, dedicated_errstream, (void *)) { return -1; }
106 }
108 (const char *, void **)) {
110 }
111 static DEFINE_METHOD(int, message, (int, ...)) { return 0; }
112
113 /* log_builtins_string */
114 static DEFINE_METHOD(char *, find_first, (const char *, int)) {
115 return nullptr;
116 }
117 static DEFINE_METHOD(char *, find_last, (const char *, int)) {
118 return nullptr;
119 }
120 static DEFINE_METHOD(int, compare,
121 (const char *, const char *, size_t, bool)) {
122 return 0;
123 }
124 static DEFINE_METHOD(size_t, substitute,
125 (char *, size_t, const char *, ...)) {
126 return -1;
127 }
128 static DEFINE_METHOD(longlong, errcode_by_errsymbol, (const char *)) {
129 return 0;
130 }
131
132 /* ================ REQUIRED ================ */
133 /* log_builtins */
135 (log_line * ll, log_item_type t, const char *key,
136 uint32 alloc));
138 (log_line * ll, log_item_type t));
139 static DEFINE_METHOD(log_line *, line_init, ());
140 static DEFINE_METHOD(void, line_exit, (log_line * ll));
142 (log_line * ll, log_item_type_mask m));
143 static DEFINE_METHOD(bool, item_set_int, (log_item_data * lid, longlong i));
145 (log_item_data * lid, const char *s, size_t s_len));
146 static DEFINE_METHOD(bool, item_set_cstring,
147 (log_item_data * lid, const char *s));
148 static DEFINE_METHOD(int, line_submit, (log_line * ll));
149 static DEFINE_METHOD(const char *, errmsg_by_errcode, (int mysql_errcode));
150
151 /* log_builtins_string */
152 static DEFINE_METHOD(void *, malloc, (size_t len));
153 static DEFINE_METHOD(char *, strndup, (const char *fm, size_t len));
154 static DEFINE_METHOD(void, free, (void *ptr));
155 static DEFINE_METHOD(size_t, length, (const char *s));
156 static DEFINE_METHOD(size_t, substitutev,
157 (char *to, size_t n, const char *fmt, va_list ap))
158 MY_ATTRIBUTE((format(printf, 3, 0)));
159};
160
161} // namespace keyring_common::service_definition
162
163#define KEYRING_LOG_BUILTINS_IMPLEMENTOR(component_name) \
164 BEGIN_SERVICE_IMPLEMENTATION(component_name, log_builtins) \
165 keyring_common::service_definition::Log_builtins_keyring::wellknown_by_type, \
166 keyring_common::service_definition::Log_builtins_keyring:: \
167 wellknown_by_name, \
168 keyring_common::service_definition::Log_builtins_keyring:: \
169 wellknown_get_type, \
170 keyring_common::service_definition::Log_builtins_keyring:: \
171 wellknown_get_name, \
172 keyring_common::service_definition::Log_builtins_keyring:: \
173 item_inconsistent, \
174 keyring_common::service_definition::Log_builtins_keyring:: \
175 item_generic_type, \
176 keyring_common::service_definition::Log_builtins_keyring:: \
177 item_string_class, \
178 keyring_common::service_definition::Log_builtins_keyring:: \
179 item_numeric_class, \
180 keyring_common::service_definition::Log_builtins_keyring::item_set_int, \
181 keyring_common::service_definition::Log_builtins_keyring:: \
182 item_set_float, \
183 keyring_common::service_definition::Log_builtins_keyring:: \
184 item_set_lexstring, \
185 keyring_common::service_definition::Log_builtins_keyring:: \
186 item_set_cstring, \
187 keyring_common::service_definition::Log_builtins_keyring:: \
188 item_set_with_key, \
189 keyring_common::service_definition::Log_builtins_keyring::item_set, \
190 keyring_common::service_definition::Log_builtins_keyring:: \
191 line_item_set_with_key, \
192 keyring_common::service_definition::Log_builtins_keyring::line_item_set, \
193 keyring_common::service_definition::Log_builtins_keyring::line_init, \
194 keyring_common::service_definition::Log_builtins_keyring::line_exit, \
195 keyring_common::service_definition::Log_builtins_keyring:: \
196 line_item_count, \
197 keyring_common::service_definition::Log_builtins_keyring:: \
198 line_item_types_seen, \
199 keyring_common::service_definition::Log_builtins_keyring:: \
200 line_get_output_buffer, \
201 keyring_common::service_definition::Log_builtins_keyring:: \
202 line_item_iter_acquire, \
203 keyring_common::service_definition::Log_builtins_keyring:: \
204 line_item_iter_release, \
205 keyring_common::service_definition::Log_builtins_keyring:: \
206 line_item_iter_first, \
207 keyring_common::service_definition::Log_builtins_keyring:: \
208 line_item_iter_next, \
209 keyring_common::service_definition::Log_builtins_keyring:: \
210 line_item_iter_current, \
211 keyring_common::service_definition::Log_builtins_keyring::line_submit, \
212 keyring_common::service_definition::Log_builtins_keyring::message, \
213 keyring_common::service_definition::Log_builtins_keyring::sanitize, \
214 keyring_common::service_definition::Log_builtins_keyring:: \
215 errmsg_by_errcode, \
216 keyring_common::service_definition::Log_builtins_keyring:: \
217 errcode_by_errsymbol, \
218 keyring_common::service_definition::Log_builtins_keyring:: \
219 label_from_prio, \
220 keyring_common::service_definition::Log_builtins_keyring:: \
221 parse_iso8601_timestamp, \
222 keyring_common::service_definition::Log_builtins_keyring:: \
223 open_errstream, \
224 keyring_common::service_definition::Log_builtins_keyring:: \
225 write_errstream, \
226 keyring_common::service_definition::Log_builtins_keyring:: \
227 dedicated_errstream, \
228 keyring_common::service_definition::Log_builtins_keyring:: \
229 close_errstream, \
230 keyring_common::service_definition::Log_builtins_keyring:: \
231 reopen_errstream \
232 END_SERVICE_IMPLEMENTATION()
233
234#define KEYRING_LOG_BUILTINS_STRING_IMPLEMENTOR(component_name) \
235 BEGIN_SERVICE_IMPLEMENTATION(component_name, log_builtins_string) \
236 keyring_common::service_definition::Log_builtins_keyring::malloc, \
237 keyring_common::service_definition::Log_builtins_keyring::strndup, \
238 keyring_common::service_definition::Log_builtins_keyring::free, \
239 keyring_common::service_definition::Log_builtins_keyring::length, \
240 keyring_common::service_definition::Log_builtins_keyring::find_first, \
241 keyring_common::service_definition::Log_builtins_keyring::find_last, \
242 keyring_common::service_definition::Log_builtins_keyring::compare, \
243 keyring_common::service_definition::Log_builtins_keyring::substitutev, \
244 keyring_common::service_definition::Log_builtins_keyring::substitute \
245 END_SERVICE_IMPLEMENTATION()
246
247#endif /* KEYRING_LOG_BUILTINS_DEFINITION_INCLUDED */
Definition: keyring_log_builtins_definition.h:34
static bool item_set_int(log_item_data *lid, longlong i) noexcept
Definition: keyring_log_builtins_definition.cc:220
static char * find_first(const char *, int) noexcept
Definition: keyring_log_builtins_definition.h:114
static size_t substitutev(char *to, size_t n, const char *fmt, va_list ap) noexcept
Definition: keyring_log_builtins_definition.cc:373
static log_item * line_item_iter_next(log_item_iter *) noexcept
Definition: keyring_log_builtins_definition.h:83
static void * malloc(size_t len) noexcept
Definition: keyring_log_builtins_definition.cc:347
static const char * errmsg_by_errcode(int mysql_errcode) noexcept
Definition: keyring_log_builtins_definition.cc:330
static log_item * line_item_iter_first(log_item_iter *) noexcept
Definition: keyring_log_builtins_definition.h:80
static void line_exit(log_line *ll) noexcept
Definition: keyring_log_builtins_definition.cc:210
static bool item_numeric_class(log_item_class) noexcept
Definition: keyring_log_builtins_definition.h:57
static log_item_data * item_set(log_item *, log_item_type) noexcept
Definition: keyring_log_builtins_definition.h:65
static log_line * line_init() noexcept
Definition: keyring_log_builtins_definition.cc:204
static int sanitize(log_item *) noexcept
Definition: keyring_log_builtins_definition.h:89
static void line_item_iter_release(log_item_iter *) noexcept
Definition: keyring_log_builtins_definition.h:79
static size_t substitute(char *, size_t, const char *,...) noexcept
Definition: keyring_log_builtins_definition.h:125
static char * find_last(const char *, int) noexcept
Definition: keyring_log_builtins_definition.h:117
static log_service_error reopen_errstream(const char *, void **) noexcept
Definition: keyring_log_builtins_definition.h:108
static longlong errcode_by_errsymbol(const char *) noexcept
Definition: keyring_log_builtins_definition.h:128
static bool item_set_cstring(log_item_data *lid, const char *s) noexcept
Definition: keyring_log_builtins_definition.cc:239
static log_item_type_mask line_item_types_seen(log_line *ll, log_item_type_mask m) noexcept
Definition: keyring_log_builtins_definition.cc:215
static log_item * line_get_output_buffer(log_line *) noexcept
Definition: keyring_log_builtins_definition.h:73
static ulonglong parse_iso8601_timestamp(const char *, size_t) noexcept
Definition: keyring_log_builtins_definition.h:91
static int line_submit(log_line *ll) noexcept
Definition: keyring_log_builtins_definition.cc:248
static int wellknown_by_type(log_item_type) noexcept
Definition: keyring_log_builtins_definition.h:38
static bool item_set_float(log_item_data *, double) noexcept
Definition: keyring_log_builtins_definition.h:68
static int wellknown_by_name(const char *, size_t) noexcept
Definition: keyring_log_builtins_definition.h:41
static int compare(const char *, const char *, size_t, bool) noexcept
Definition: keyring_log_builtins_definition.h:121
static log_item_data * line_item_set(log_line *ll, log_item_type t) noexcept
Definition: keyring_log_builtins_definition.cc:200
static log_service_error close_errstream(void **) noexcept
Definition: keyring_log_builtins_definition.h:104
static log_service_error open_errstream(const char *, void **) noexcept
Definition: keyring_log_builtins_definition.h:96
static log_item_iter * line_item_iter_acquire(log_line *) noexcept
Definition: keyring_log_builtins_definition.h:76
static bool item_generic_type(log_item_type) noexcept
Definition: keyring_log_builtins_definition.h:51
static const char * wellknown_get_name(uint) noexcept
Definition: keyring_log_builtins_definition.h:47
static size_t length(const char *s) noexcept
Definition: keyring_log_builtins_definition.cc:368
static void free(void *ptr) noexcept
Definition: keyring_log_builtins_definition.cc:361
static log_item_data * line_item_set_with_key(log_line *ll, log_item_type t, const char *key, uint32 alloc) noexcept
Definition: keyring_log_builtins_definition.cc:195
static int line_item_count(log_line *) noexcept
Definition: keyring_log_builtins_definition.h:72
static char * strndup(const char *fm, size_t len) noexcept
Definition: keyring_log_builtins_definition.cc:352
static log_service_error write_errstream(void *, const char *, size_t) noexcept
Definition: keyring_log_builtins_definition.h:100
static const char * label_from_prio(int) noexcept
Definition: keyring_log_builtins_definition.h:94
static int dedicated_errstream(void *) noexcept
Definition: keyring_log_builtins_definition.h:103
static int message(int,...) noexcept
Definition: keyring_log_builtins_definition.h:111
static log_item * line_item_iter_current(log_item_iter *) noexcept
Definition: keyring_log_builtins_definition.h:86
static bool item_set_lexstring(log_item_data *lid, const char *s, size_t s_len) noexcept
Definition: keyring_log_builtins_definition.cc:229
static bool item_string_class(log_item_class) noexcept
Definition: keyring_log_builtins_definition.h:54
static int item_inconsistent(log_item *) noexcept
Definition: keyring_log_builtins_definition.h:50
static log_item_type wellknown_get_type(uint) noexcept
Definition: keyring_log_builtins_definition.h:44
static log_item_data * item_set_with_key(log_item *, log_item_type, const char *, uint32) noexcept
Definition: keyring_log_builtins_definition.h:62
Specifies macros to define Components.
enum enum_log_service_error log_service_error
Error codes.
@ LOG_SERVICE_COULD_NOT_MAKE_LOG_NAME
could not make log name
Definition: log_service.h:138
@ LOG_SERVICE_NOTHING_DONE
no error, but no effect either
Definition: log_service.h:102
@ LOG_ITEM_TYPE_NOT_FOUND
Definition: log_shared.h:207
enum enum_log_item_class log_item_class
@ LOG_ITEM_END
end of list, see above
Definition: log_shared.h:125
enum enum_log_item_type log_item_type
item_type – what to log
uint64 log_item_type_mask
a bit mask of log_types.
Definition: log_shared.h:216
unsigned long long int ulonglong
Definition: my_inttypes.h:56
long long int longlong
Definition: my_inttypes.h:55
uint32_t uint32
Definition: my_inttypes.h:67
Definition: keyring_encryption_service_definition.h:32
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Specifies macros to define Service Implementations.
#define DEFINE_METHOD(retval, name, args)
A macro to ensure method implementation has required properties, that is it does not throw exceptions...
Definition: service_implementation.h:79
Iterator over the key/value pairs of a log_line.
Definition: keyring_log_builtins_definition.cc:64
Definition: log_shared.h:196
log_line ("log event")
Definition: keyring_log_builtins_definition.cc:72
Definition: log_shared.h:185
int n
Definition: xcom_base.cc:509