MySQL 8.3.0
Source Code Documentation
log_builtins_filter_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef LOG_FILTER_INTERNAL_H
24#define LOG_FILTER_INTERNAL_H
26
28 public:
29 /**
30 Initialize built-in log filter.
31 */
32 static void init();
33
34 /**
35 De-initialize built-in log filter.
36 */
37 static void deinit();
38
39 public: /* Service Implementations */
40 /**
41 Create a new set of filter rules.
42
43 @param tag identifying tag of the rule-set creator
44 @param count number of rules to allocate
45
46 @returns a pointer to a ruleset structure, or nullptr on failure
47 */
49 (log_filter_tag * tag, size_t count));
50
51 /**
52 Lock and get the filter rules.
53
54 @param ruleset a ruleset (usually allocated with filter_ruleset_new())
55 @param locktype LOG_BUILTINS_LOCK_SHARED lock for reading
56 LOG_BUILTINS_LOCK_EXCLUSIVE lock for writing
57
58 @returns 0 lock acquired
59 @returns !0 failed to acquire lock
60 */
62 (log_filter_ruleset * ruleset,
63 log_builtins_filter_lock locktype));
64
65 /**
66 Release lock on filter rules.
67
68 @param ruleset a ruleset (usually allocated with filter_ruleset_new())
69 */
71 (log_filter_ruleset * ruleset));
72
73 /**
74 Drop an entire filter rule-set. Must hold lock.
75
76 @param ruleset a ruleset * (usually allocated with filter_ruleset_new())
77 */
79 (log_filter_ruleset * ruleset));
80
81 /**
82 Free an entire filter rule-set. Must hold lock. Lock will be destroyed.
83
84 @param ruleset a ruleset * (usually allocated with filter_ruleset_new())
85 the pointer pointed to will be a nullptr on return.
86 */
88 (log_filter_ruleset * *ruleset));
89
90 /**
91 Move rules from one ruleset to another. Origin will be empty afterwards.
92
93 @param from source ruleset
94 @param to destination ruleset
95 */
98
99 /**
100 Initialize a new rule.
101 This clears the first unused rule. It does not update the rules
102 count; this is for the caller to do if it succeeds in setting up
103 the rule to its satisfaction. If the caller fails, it should
104 log_builtins_filter_rule_free() the incomplete rule.
105
106 @param ruleset a ruleset (usually allocated with filter_ruleset_new())
107
108 @returns nullptr could not initialize rule. Do not call rule_free.
109 @returns !nullptr the address of the rule. fill in. on success,
110 caller must increase rule count. on failure,
111 it must call rule_free.
112 */
113 static DEFINE_METHOD(void *, filter_rule_init,
114 (log_filter_ruleset * ruleset));
115
116 /**
117 Apply all matching rules from a filter rule set to a given log line.
118
119 @param ruleset a ruleset (usually allocated with filter_ruleset_new())
120 @param ll the current log line
121
122 @returns int number of matched rules
123 */
124 static DEFINE_METHOD(int, filter_run,
125 (log_filter_ruleset * ruleset, log_line *ll));
126};
127
129 public:
130 /**
131 Initialize built-in log filter debug functionality.
132 */
133 static void init();
134
135 /**
136 De-initialize built-in log filter debug functionality.
137 */
138 static void deinit();
139
140 public: /* Service Implementations */
141 /**
142 Get filter rules used in built-in filter. For debug purposes only.
143 Third party code should not use this, nor rely on this API to be stable.
144
145 @returns a pointer to a ruleset structure, or nullptr
146 */
148};
149
150/**
151 Deinitialize filtering engine.
152
153 @returns 0 Success!
154 @returns -1 De-initialize? Filter wasn't even initialized!
155*/
157
158/**
159 Initialize filtering engine.
160 We need to do this early, before the component system is up.
161
162 @returns 0 Success!
163 @returns -1 Couldn't initialize ruleset lock
164 @returns -2 Filter was already initialized?
165*/
167
169
170#ifdef MYSQL_SERVER
171
172int log_builtins_filter_update_verbosity(int verbosity);
173
175
176#endif /* MYSQL_SERVER */
177
178#endif /* LOG_FILTER_INTERNAL_H */
Definition: log_builtins_filter_imp.h:128
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:1058
static void init()
Initialize built-in log filter debug functionality.
Definition: log_builtins_filter_imp.h:27
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:1053
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:1020
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:1005
static void filter_ruleset_unlock(log_filter_ruleset *ruleset) noexcept
Release lock on filter rules.
Definition: log_builtins_filter.cc:1010
static void filter_ruleset_drop(log_filter_ruleset *ruleset) noexcept
Drop an entire filter rule-set.
Definition: log_builtins_filter.cc:1015
static void * filter_rule_init(log_filter_ruleset *ruleset) noexcept
Initialize a new rule.
Definition: log_builtins_filter.cc:1047
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:999
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:1025
enum enum_log_builtins_lock log_builtins_filter_lock
int log_builtins_filter_exit()
Deinitialize filtering engine.
Definition: log_builtins_filter.cc:338
int log_builtins_filter_init()
Initialize filtering engine.
Definition: log_builtins_filter.cc:364
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:865
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:773
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:643
static int count
Definition: myisam_ftdump.cc:44
static uint update
Definition: myisamlog.cc:93
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2877
#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:78
Definition: log_builtins_filter.h:168
Definition: log_builtins_filter.h:107
log_line ("log event")
Definition: keyring_log_builtins_definition.cc:71