MySQL 8.4.0
Source Code Documentation
log_builtins_filter_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 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 LOG_FILTER_INTERNAL_H
25#define LOG_FILTER_INTERNAL_H
27
29 public:
30 /**
31 Initialize built-in log filter.
32 */
33 static void init();
34
35 /**
36 De-initialize built-in log filter.
37 */
38 static void deinit();
39
40 public: /* Service Implementations */
41 /**
42 Create a new set of filter rules.
43
44 @param tag identifying tag of the rule-set creator
45 @param count number of rules to allocate
46
47 @returns a pointer to a ruleset structure, or nullptr on failure
48 */
50 (log_filter_tag * tag, size_t count));
51
52 /**
53 Lock and get the filter rules.
54
55 @param ruleset a ruleset (usually allocated with filter_ruleset_new())
56 @param locktype LOG_BUILTINS_LOCK_SHARED lock for reading
57 LOG_BUILTINS_LOCK_EXCLUSIVE lock for writing
58
59 @returns 0 lock acquired
60 @returns !0 failed to acquire lock
61 */
63 (log_filter_ruleset * ruleset,
64 log_builtins_filter_lock locktype));
65
66 /**
67 Release lock on filter rules.
68
69 @param ruleset a ruleset (usually allocated with filter_ruleset_new())
70 */
72 (log_filter_ruleset * ruleset));
73
74 /**
75 Drop an entire filter rule-set. Must hold lock.
76
77 @param ruleset a ruleset * (usually allocated with filter_ruleset_new())
78 */
80 (log_filter_ruleset * ruleset));
81
82 /**
83 Free an entire filter rule-set. Must hold lock. Lock will be destroyed.
84
85 @param ruleset a ruleset * (usually allocated with filter_ruleset_new())
86 the pointer pointed to will be a nullptr on return.
87 */
89 (log_filter_ruleset * *ruleset));
90
91 /**
92 Move rules from one ruleset to another. Origin will be empty afterwards.
93
94 @param from source ruleset
95 @param to destination ruleset
96 */
99
100 /**
101 Initialize a new rule.
102 This clears the first unused rule. It does not update the rules
103 count; this is for the caller to do if it succeeds in setting up
104 the rule to its satisfaction. If the caller fails, it should
105 log_builtins_filter_rule_free() the incomplete rule.
106
107 @param ruleset a ruleset (usually allocated with filter_ruleset_new())
108
109 @returns nullptr could not initialize rule. Do not call rule_free.
110 @returns !nullptr the address of the rule. fill in. on success,
111 caller must increase rule count. on failure,
112 it must call rule_free.
113 */
114 static DEFINE_METHOD(void *, filter_rule_init,
115 (log_filter_ruleset * ruleset));
116
117 /**
118 Apply all matching rules from a filter rule set to a given log line.
119
120 @param ruleset a ruleset (usually allocated with filter_ruleset_new())
121 @param ll the current log line
122
123 @returns int number of matched rules
124 */
125 static DEFINE_METHOD(int, filter_run,
126 (log_filter_ruleset * ruleset, log_line *ll));
127};
128
130 public:
131 /**
132 Initialize built-in log filter debug functionality.
133 */
134 static void init();
135
136 /**
137 De-initialize built-in log filter debug functionality.
138 */
139 static void deinit();
140
141 public: /* Service Implementations */
142 /**
143 Get filter rules used in built-in filter. For debug purposes only.
144 Third party code should not use this, nor rely on this API to be stable.
145
146 @returns a pointer to a ruleset structure, or nullptr
147 */
149};
150
151/**
152 Deinitialize filtering engine.
153
154 @returns 0 Success!
155 @returns -1 De-initialize? Filter wasn't even initialized!
156*/
158
159/**
160 Initialize filtering engine.
161 We need to do this early, before the component system is up.
162
163 @returns 0 Success!
164 @returns -1 Couldn't initialize ruleset lock
165 @returns -2 Filter was already initialized?
166*/
168
170
171#ifdef MYSQL_SERVER
172
173int log_builtins_filter_update_verbosity(int verbosity);
174
176
177#endif /* MYSQL_SERVER */
178
179#endif /* LOG_FILTER_INTERNAL_H */
Definition: log_builtins_filter_imp.h:129
static void deinit()
De-initialize built-in log filter debug functionality.
static log_filter_ruleset * filter_debug_ruleset_get(void) noexcept
Get filter rules used in built-in filter.
Definition: log_builtins_filter.cc:1059
static void init()
Initialize built-in log filter debug functionality.
Definition: log_builtins_filter_imp.h:28
static int filter_run(log_filter_ruleset *ruleset, log_line *ll) noexcept
Apply all matching rules from a filter rule set to a given log line.
Definition: log_builtins_filter.cc:1054
static void init()
Initialize built-in log filter.
static void filter_ruleset_free(log_filter_ruleset **ruleset) noexcept
Free an entire filter rule-set.
Definition: log_builtins_filter.cc:1021
static void deinit()
De-initialize built-in log filter.
static int filter_ruleset_lock(log_filter_ruleset *ruleset, log_builtins_filter_lock locktype) noexcept
Lock and get the filter rules.
Definition: log_builtins_filter.cc:1006
static void filter_ruleset_unlock(log_filter_ruleset *ruleset) noexcept
Release lock on filter rules.
Definition: log_builtins_filter.cc:1011
static void filter_ruleset_drop(log_filter_ruleset *ruleset) noexcept
Drop an entire filter rule-set.
Definition: log_builtins_filter.cc:1016
static void * filter_rule_init(log_filter_ruleset *ruleset) noexcept
Initialize a new rule.
Definition: log_builtins_filter.cc:1048
static log_filter_ruleset * filter_ruleset_new(log_filter_tag *tag, size_t count) noexcept
Create a new set of filter rules.
Definition: log_builtins_filter.cc:1000
static int filter_ruleset_move(log_filter_ruleset *from, log_filter_ruleset *to) noexcept
Move rules from one ruleset to another.
Definition: log_builtins_filter.cc:1026
enum enum_log_builtins_lock log_builtins_filter_lock
int log_builtins_filter_exit()
Deinitialize filtering engine.
Definition: log_builtins_filter.cc:339
int log_builtins_filter_init()
Initialize filtering engine.
Definition: log_builtins_filter.cc:365
int log_builtins_filter_parse_suppression_list(char *list, bool update)
@global.log_error_suppression_list accepts a comma-separated list of error-codes that should not be i...
Definition: log_builtins_filter.cc:866
int log_builtins_filter_update_verbosity(int verbosity)
This is part of the 5.7 emulation: If –log_error_verbosity is changed, we generate an artificial filt...
Definition: log_builtins_filter.cc:774
int log_builtins_filter_run(log_filter_ruleset *ruleset, log_line *ll)
Apply all matching rules from a filter rule set to a given log line.
Definition: log_builtins_filter.cc:644
static int count
Definition: myisam_ftdump.cc:45
static uint update
Definition: myisamlog.cc:94
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2878
#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
Definition: log_builtins_filter.h:169
Definition: log_builtins_filter.h:108
log_line ("log event")
Definition: keyring_log_builtins_definition.cc:72