diff options
author | Daniel Black <daniel.black@au.ibm.com> | 2017-04-18 17:20:34 +1000 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-05-15 22:23:10 +0200 |
commit | 602b5e4c498ad2e2d045adfa4fd1478ac437582a (patch) | |
tree | 3e91ba4fab05d00c207adcebe1df68de661d3c63 /sql | |
parent | b30311e52a614a199e54767bb77d0419ad2d49c1 (diff) | |
download | mariadb-git-602b5e4c498ad2e2d045adfa4fd1478ac437582a.tar.gz |
WIP: global readonly variable pcre_frame_size
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_cmpfunc.h | 8 | ||||
-rw-r--r-- | sql/mysqld.cc | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 8 | ||||
-rw-r--r-- | sql/sql_parse.h | 1 | ||||
-rw-r--r-- | sql/sys_vars.cc | 8 |
5 files changed, 28 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index bd552bfc952..b5b94888330 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -25,6 +25,7 @@ #include "thr_malloc.h" /* sql_calloc */ #include "item_func.h" /* Item_int_func, Item_bool_func */ +long check_stack_available(long margin, uchar *dummy); #define PCRE_STATIC 1 /* Important on Windows */ #include "pcre.h" /* pcre header file */ @@ -1576,8 +1577,13 @@ public: m_library_charset(&my_charset_utf8_general_ci), m_subpatterns_needed(0) { +#ifndef EMBEDDED_LIBRARY + uchar dummy; m_pcre_extra.flags= PCRE_EXTRA_MATCH_LIMIT_RECURSION; - m_pcre_extra.match_limit_recursion= 100L; + m_pcre_extra.match_limit_recursion= check_stack_available(100, &dummy) / my_pcre_frame_size; +#else + m_pcre_extra.flags= 0L; +#endif } int default_regex_flags(); void init(CHARSET_INFO *data_charset, int extra_flags, uint nsubpatterns) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 79966f6f5e6..f6c6778e906 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -100,6 +100,7 @@ #include "sp_rcontext.h" #include "sp_cache.h" #include "sql_reload.h" // reload_acl_and_cache +#include "pcre.h" #ifdef HAVE_POLL_H #include <poll.h> @@ -3503,6 +3504,9 @@ static void init_pcre() pcre_free= pcre_stack_free= my_str_free_mysqld; #ifndef EMBEDDED_LIBRARY pcre_stack_guard= check_enough_stack_size_slow; + /* my_pcre_frame_size= -pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0) + 16; + http://pcre.org/original/doc/html/pcrestack.html has reason for + 16 + my_pcre_frame_size= -pcre_match(NULL, NULL, NULL, 0, NULL, NULL, 0) + 16; */ #endif } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e059be4860b..edeb34418b2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6208,6 +6208,14 @@ bool check_stack_overrun(THD *thd, long margin, return 0; } +long check_stack_available(long margin, + uchar *buf __attribute__((unused))) +{ + long stack_top; + DBUG_ASSERT(current_thd); + return my_thread_stack_size - margin \ + - used_stack(current_thd->thread_stack,(char*) &stack_top); +} #define MY_YACC_INIT 1000 // Start with big alloc #define MY_YACC_MAX 32000 // Because of 'short' diff --git a/sql/sql_parse.h b/sql/sql_parse.h index fa414911093..b67692fec90 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -134,6 +134,7 @@ bool check_simple_select(); Item *normalize_cond(Item *cond); Item *negate_expression(THD *thd, Item *expr); bool check_stack_overrun(THD *thd, long margin, uchar *dummy); +long check_stack_available(long margin, uchar *dummy); /* Variables */ diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 5ff79a2f235..e50217a4459 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2493,6 +2493,14 @@ static Sys_var_ulonglong Sys_thread_stack( VALID_RANGE(128*1024, ULONGLONG_MAX), DEFAULT(DEFAULT_THREAD_STACK), BLOCK_SIZE(1024)); +#ifndef EMBEDDED_LIBRARY +static Sys_var_ulonglong Sys_my_pcre_frame_size( + "pcre_frame_size", "Frame size for pcre_recursion", + GLOBAL_VAR(my_pcre_frame_size), NO_CMD_LINE, + VALID_RANGE(500,1024), DEFAULT(640 + 16), 1, NO_MUTEX_GUARD, + NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0)); +#endif + static Sys_var_charptr Sys_tmpdir( "tmpdir", "Path for temporary files. Several paths may " "be specified, separated by a " |