MaxScale 25.01 Regex Filter
The Regex filter is a filter module for MariaDB MaxScale that is able to rewrite
query content using regular expression matches and text substitution. The
regular expressions use the .
PCRE2 library uses a different syntax than POSIX to refer to capture
groups in the replacement string. The main difference is the usage of the dollar
character instead of the backslash character for references e.g. $1 instead of\1. For more details about the replacement string differences, please read the
chapter in the PCRE2 manual.
The following demonstrates a minimal configuration.
The Regex filter has two mandatory parameters: match and replace.
Defines the text in the SQL statements that is replaced.
The options-parameter affects how the patterns are compiled as .
This is the text that should replace the part of the SQL-query matching the
pattern defined in match.
The optional source parameter defines an address that is used to match against
the address from which the client connection to MariaDB MaxScale
originates. Only sessions that originate from this address will have the match
and replacement applied to them.
The optional user parameter defines a username that is used to match against
the user from which the client connection to MariaDB MaxScale originates. Only
sessions that are connected using this username will have the match and
replacement applied to them.
The optional log_file parameter defines a log file in which the filter writes
all queries that are not matched and matching queries with their replacement
queries. All sessions will log to this file so this should only be used for
diagnostic purposes.
The optional log_trace parameter toggles the logging of non-matching and
matching queries with their replacements into the log file on the info level.
This is the preferred method of diagnosing the matching of queries since the log
level can be changed at runtime. For more details about logging levels and
session specific logging, please read the .
Example 1 - Replace MySQL 5.1 create table syntax with that for later versions
MySQL 5.1 used the parameter TYPE = to set the storage engine that should be
used for a table. In later versions this changed to be ENGINE =. Imagine you
have an application that you cannot change for some reason, but you wish to
migrate to a newer version of MySQL. The regexfilter can be used to transform
the create table statements into the form that could be used by MySQL 5.5
This page is licensed: CC BY-SA / Gnu FDL