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