MySQL 9.1.0
Source Code Documentation
regular_expressions.h
Go to the documentation of this file.
1/* Copyright (c) 2019, 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 REGULAR_EXPRESSIONS_INCLUDED
25#define REGULAR_EXPRESSIONS_INCLUDED
26
27#include <regex>
28
30#include "prealloced_array.h"
31
32extern std::regex explain_re;
33extern std::regex opt_trace_re;
34extern std::regex ps_re;
35extern std::regex sp_re;
36extern std::regex view_re;
37
38struct st_regex {
39 char *pattern; /* Pattern to be replaced */
40 char *replace; /* String or expression to replace the pattern with */
41 int icase; /* true if the match is case insensitive */
42};
43
46 /* stores a list of st_regex subsitutions */
48
49 /*
50 Temporary storage areas for substitutions. To reduce unnessary copying
51 and memory freeing/allocation, we pre-allocate two buffers, and alternate
52 their use, one for input/one for output, the roles changing on the next
53 st_regex substitution. At the end of substitutions, buf points to the
54 one containing the final result.
55 */
56 char *buf{nullptr};
57 char *even_buf{nullptr};
58 char *odd_buf{nullptr};
61};
62
63int multi_reg_replace(struct st_replace_regex *r, char *val, size_t *len);
64int search_protocol_re(std::regex *re, const char *str);
65
66#endif // REGULAR_EXPRESSIONS_INCLUDED
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1105
Definition: buf0block_hint.cc:30
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
Performance schema instrumentation interface.
int multi_reg_replace(struct st_replace_regex *r, char *val, size_t *len)
Execute all substitutions on val.
Definition: regular_expressions.cc:152
std::regex explain_re
std::regex view_re
std::regex ps_re
std::regex opt_trace_re
std::regex sp_re
int search_protocol_re(std::regex *re, const char *str)
Function to check if a protocol's regular expression matches the query string.
Definition: regular_expressions.cc:241
Definition: regular_expressions.h:38
int icase
Definition: regular_expressions.h:41
char * pattern
Definition: regular_expressions.h:39
char * replace
Definition: regular_expressions.h:40
Definition: regular_expressions.h:44
Prealloced_array< st_regex, 128 > regex_arr
Definition: regular_expressions.h:47
char * even_buf
Definition: regular_expressions.h:57
char * odd_buf
Definition: regular_expressions.h:58
int odd_buf_len
Definition: regular_expressions.h:60
st_replace_regex()
Definition: regular_expressions.h:45
int even_buf_len
Definition: regular_expressions.h:59
#define PSI_NOT_INSTRUMENTED
Definition: validate_password_imp.cc:44