[Maria-developers] mdev6027 RLIKE: "." no longer matching new line (default_regex_flags)
Hello Serg, Please review a patch implementing a new system variable default_regex_flags, to address the remaining incompatibilities between PCRE and the old regex library. Greetings.
Hi, Alexander! On Apr 17, Alexander Barkov wrote:
Hello Serg,
Please review a patch implementing a new system variable default_regex_flags, to address the remaining incompatibilities between PCRE and the old regex library.
Greetings.
Just one comment:
=== modified file 'sql/item_cmpfunc.cc' --- sql/item_cmpfunc.cc 2014-03-26 21:25:38 +0000 +++ sql/item_cmpfunc.cc 2014-04-16 12:53:20 +0000 @@ -32,6 +32,7 @@ #include "sql_parse.h" // check_stack_overrun #include "sql_time.h" // make_truncated_value_warning #include "sql_base.h" // dynamic_column_error_message +#include "sys_vars_shared.h" // default_regex_flags_pcre
default_regex_flags_pcre should not be in sys_vars_shared.h and item_cmpfunc.cc should not include sys_vars_shared.h. See the comment in sys_vars_shared.h: This header is included by files implementing support and utility functions of sys_var's (set_var.cc) and files implementing classes in the sys_var hierarchy (sql_plugin.cc) so, this is not a file for exporting symbols to sysvar users. But set_var.h is. You can put your default_regex_flags_pcre() in set_var.h, where expand_sql_mode() and sql_mode_string_representation() are. Regards, Sergei
Hi, Alexander! On Apr 22, Sergei Golubchik wrote:
On Apr 17, Alexander Barkov wrote:
Hello Serg,
Please review a patch implementing a new system variable default_regex_flags, to address the remaining incompatibilities between PCRE and the old regex library.
Ah, something else. Please, make sure this new variable is documented. Regards, Sergei
Hi Jan, Sergei, On 04/23/2014 11:25 AM, Sergei Golubchik wrote:
Hi, Alexander!
On Apr 22, Sergei Golubchik wrote:
On Apr 17, Alexander Barkov wrote:
Hello Serg,
Please review a patch implementing a new system variable default_regex_flags, to address the remaining incompatibilities between PCRE and the old regex library.
Ah, something else. Please, make sure this new variable is documented.
Yeah, I just finished writing a description for Jan :)
Regards, Sergei
Jan, can you please update the manual? A new system variable default_regexp_flags was added, to set the default behaviour of the PCRE regex engine. Scope: global, session. Affected functions and operators: RLIKE, REGEXP_SUBSTR, REGEXP_REPLACE. Possible values: any combination of zero or more of the following options, comma separated: DOTALL DUPNAMES EXTENDED EXTRA MULTILINE UNGREEDY Default value: empty (all options are off). Example: SET default_regex_flags=''; SET default_regex_flags='DOTALL'; SET default_regex_flags='DOTALL,DUPNAMES,EXTENDED,EXTRA,MULTILINE,UNGREEDY'; The meaning of the values: Value Pattern equivalent Meaning --------- ------------------ ------- DOTALL (?s) . matches anything including NL DUPNAMES (?J) Allow duplicate names for subpatterns EXTENDED (?x) Ignore white space and # comments EXTRA (?X) extra features (e.g. error on unknown escape character) MULTILINE (?m) ^ and $ match newlines within data UNGREEDY (?U) Invert greediness of quantifiers See here for the list of the equivalent PCRE options: https://mariadb.com/kb/en/pcre-regular-expressions/#option-setting Examples: # The default behaviour (multiline match is off) mysql> SELECT 'a\nb\nc' RLIKE '^b$'; +---------------------------+ | '(?m)a\nb\nc' RLIKE '^b$' | +---------------------------+ | 0 | +---------------------------+ # Enabling the multiline option using the PCRE option syntax: mysql> SELECT 'a\nb\nc' RLIKE '(?m)^b$'; +---------------------------+ | 'a\nb\nc' RLIKE '(?m)^b$' | +---------------------------+ | 1 | +---------------------------+ # Enabling the miltiline option using default_regex_flags mysql> SET default_regex_flags='MULTILINE'; mysql> SELECT 'a\nb\nc' RLIKE '^b$'; +-----------------------+ | 'a\nb\nc' RLIKE '^b$' | +-----------------------+ | 1 | +-----------------------+ The goal of the new variable is to simplify writing PCRE patterns, as well as to have a way to configure the default behaviour of the PCRE engine in a more compatible way with the old regex engine used in MariaDB-5.5 and MySQL. Note, unlike the old regex engine, dot (.) does not match a new line character in PCRE by default. Those who need a better compatibility with the old regex engine might consider adding this command into /etc/my.cnf: [mysqld] default-regex-flags=DOTALL Thanks.
On 23/04/2014 09:28, Alexander Barkov wrote:
Jan, can you please update the manual?
Sure, will do. Thanks for the detailed writeup. Which release is this variable scheduled to be included in? It's Ian, not Jan btw, although all comes from one and the same root name originally ;) ian
On 04/23/2014 11:44 AM, Ian Gilfillan wrote:
On 23/04/2014 09:28, Alexander Barkov wrote:
Jan, can you please update the manual?
Sure, will do. Thanks for the detailed writeup. Which release is this variable scheduled to be included in?
It's Ian, not Jan btw, although all comes from one and the same root name originally ;)
Oops. Sorry for the typo :)
ian
participants (3)
-
Alexander Barkov
-
Ian Gilfillan
-
Sergei Golubchik