diff options
author | Alexander Barkov <bar@mnogosearch.org> | 2014-04-23 10:57:25 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mnogosearch.org> | 2014-04-23 10:57:25 +0400 |
commit | f9e5f237f0091419c28d7d9d6ff3db5ed2ff5693 (patch) | |
tree | a359e7228a7fcaebcfa86173511caecf48b947fb /sql | |
parent | bcf16fa61239c8064426e95acf68ee2ef0b2373a (diff) | |
download | mariadb-git-f9e5f237f0091419c28d7d9d6ff3db5ed2ff5693.tar.gz |
MDEV-6027 RLIKE: "." no longer matching new line
Added a new system variable:
default_regex_flags='DOTALL,DUPNAMES,EXTENDED,EXTRA,MULTILINE,UNGREEDY'
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_cmpfunc.cc | 5 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 3 | ||||
-rw-r--r-- | sql/set_var.h | 1 | ||||
-rw-r--r-- | sql/sql_class.h | 1 | ||||
-rw-r--r-- | sql/sys_vars.cc | 40 |
5 files changed, 49 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4b9eb37488e..5028e18a6d7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -5055,6 +5055,11 @@ bool Item_func_like::find_selective_predicates_list_processor(uchar *arg) } +int Regexp_processor_pcre::default_regex_flags() +{ + return default_regex_flags_pcre(current_thd); +} + /** Convert string to lib_charset, if needed. diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 4b3acf83f85..bf28b00c908 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1513,9 +1513,10 @@ public: m_library_charset(&my_charset_utf8_general_ci), m_subpatterns_needed(0) {} + int default_regex_flags(); void init(CHARSET_INFO *data_charset, int extra_flags, uint nsubpatterns) { - m_library_flags= extra_flags | + m_library_flags= default_regex_flags() | extra_flags | (data_charset != &my_charset_bin ? (PCRE_UTF8 | PCRE_UCP) : 0) | ((data_charset->state & diff --git a/sql/set_var.h b/sql/set_var.h index 28562b72dac..564dac587d9 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -337,6 +337,7 @@ bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type); ulonglong expand_sql_mode(ulonglong sql_mode); bool sql_mode_string_representation(THD *thd, ulonglong sql_mode, LEX_STRING *ls); +int default_regex_flags_pcre(const THD *thd); extern sys_var *Sys_autocommit_ptr; diff --git a/sql/sql_class.h b/sql/sql_class.h index 801fe2d0206..d050a7b3704 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -516,6 +516,7 @@ typedef struct system_variables ulonglong join_buff_size; ulonglong sortbuff_size; ulonglong group_concat_max_len; + ulonglong default_regex_flags; ha_rows select_limit; ha_rows max_join_size; ha_rows expensive_subquery_limit; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index d22e8498642..44f47646e38 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4568,6 +4568,46 @@ static Sys_var_set Sys_log_slow_filter( log_slow_filter_names, DEFAULT(MAX_SET(array_elements(log_slow_filter_names)-1))); +static const char *default_regex_flags_names[]= +{ + "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 + 0 +}; +static const int default_regex_flags_to_pcre[]= +{ + PCRE_DOTALL, + PCRE_DUPNAMES, + PCRE_EXTENDED, + PCRE_EXTRA, + PCRE_MULTILINE, + PCRE_UNGREEDY, + 0 +}; +int default_regex_flags_pcre(const THD *thd) +{ + ulonglong src= thd->variables.default_regex_flags; + int i, res; + for (i= res= 0; default_regex_flags_to_pcre[i]; i++) + { + if (src & (1 << i)) + res|= default_regex_flags_to_pcre[i]; + } + return res; +} +static Sys_var_set Sys_default_regex_flags( + "default_regex_flags", + "Default flags for the regex library. " + "Syntax: default-regex-flags='[flag[,flag[,flag...]]]'. " + "See the manual for the complete list of valid flags", + SESSION_VAR(default_regex_flags), CMD_LINE(REQUIRED_ARG), + default_regex_flags_names, + DEFAULT(0)); + static Sys_var_ulong Sys_log_slow_rate_limit( "log_slow_rate_limit", "Write to slow log every #th slow query. Set to 1 to log everything. " |