summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.h
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2019-12-17 01:37:59 +0400
committerSergei Golubchik <serg@mariadb.org>2019-12-21 10:34:02 +0100
commit9dadfdcde5a63a4d67f0f7a3720632bcb1d589d7 (patch)
tree5fd6298b3dfe07cc08bd6ffebbe65081818c13ac /sql/item_cmpfunc.h
parentce70573f6255d2720c39309e0d41e181dab2d685 (diff)
downloadmariadb-git-9dadfdcde5a63a4d67f0f7a3720632bcb1d589d7.tar.gz
MDEV-14024 PCRE2.
Related changes in the server code.
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r--sql/item_cmpfunc.h40
1 files changed, 19 insertions, 21 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index cb1a467c357..c6ce2f1792a 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -24,8 +24,8 @@
#endif
#include "item_func.h" /* Item_int_func, Item_bool_func */
-#define PCRE_STATIC 1 /* Important on Windows */
-#include "pcre.h" /* pcre header file */
+#define PCRE2_STATIC 1 /* Important on Windows */
+#include "pcre2.h" /* pcre2 header file */
#include "item.h"
extern Item_result item_cmp_type(Item_result a,Item_result b);
@@ -2804,41 +2804,39 @@ public:
class Regexp_processor_pcre
{
- pcre *m_pcre;
- pcre_extra m_pcre_extra;
+ pcre2_code *m_pcre;
+ pcre2_match_data *m_pcre_match_data;
bool m_conversion_is_needed;
bool m_is_const;
int m_library_flags;
CHARSET_INFO *m_library_charset;
String m_prev_pattern;
int m_pcre_exec_rc;
- int m_SubStrVec[30];
+ PCRE2_SIZE *m_SubStrVec;
void pcre_exec_warn(int rc) const;
- int pcre_exec_with_warn(const pcre *code, const pcre_extra *extra,
+ int pcre_exec_with_warn(const pcre2_code *code,
+ pcre2_match_data *data,
const char *subject, int length, int startoffset,
- int options, int *ovector, int ovecsize);
+ int options);
public:
String *convert_if_needed(String *src, String *converter);
String subject_converter;
String pattern_converter;
String replace_converter;
Regexp_processor_pcre() :
- m_pcre(NULL), m_conversion_is_needed(true), m_is_const(0),
+ m_pcre(NULL), m_pcre_match_data(NULL),
+ m_conversion_is_needed(true), m_is_const(0),
m_library_flags(0),
m_library_charset(&my_charset_utf8mb3_general_ci)
- {
- m_pcre_extra.flags= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
- m_pcre_extra.match_limit_recursion= 100L;
- }
+ {}
int default_regex_flags();
- void set_recursion_limit(THD *);
void init(CHARSET_INFO *data_charset, int extra_flags)
{
m_library_flags= default_regex_flags() | extra_flags |
(data_charset != &my_charset_bin ?
- (PCRE_UTF8 | PCRE_UCP) : 0) |
+ (PCRE2_UTF | PCRE2_UCP) : 0) |
((data_charset->state &
- (MY_CS_BINSORT | MY_CS_CSSORT)) ? 0 : PCRE_CASELESS);
+ (MY_CS_BINSORT | MY_CS_CSSORT)) ? 0 : PCRE2_CASELESS);
// Convert text data to utf-8.
m_library_charset= data_charset == &my_charset_bin ?
@@ -2859,26 +2857,28 @@ public:
bool exec(Item *item, int offset, uint n_result_offsets_to_convert);
bool match() const { return m_pcre_exec_rc < 0 ? 0 : 1; }
int nsubpatterns() const { return m_pcre_exec_rc <= 0 ? 0 : m_pcre_exec_rc; }
- int subpattern_start(int n) const
+ size_t subpattern_start(int n) const
{
return m_pcre_exec_rc <= 0 ? 0 : m_SubStrVec[n * 2];
}
- int subpattern_end(int n) const
+ size_t subpattern_end(int n) const
{
return m_pcre_exec_rc <= 0 ? 0 : m_SubStrVec[n * 2 + 1];
}
- int subpattern_length(int n) const
+ size_t subpattern_length(int n) const
{
return subpattern_end(n) - subpattern_start(n);
}
void reset()
{
m_pcre= NULL;
+ m_pcre_match_data= NULL;
m_prev_pattern.length(0);
}
void cleanup()
{
- pcre_free(m_pcre);
+ pcre2_match_data_free(m_pcre_match_data);
+ pcre2_code_free(m_pcre);
reset();
}
bool is_compiled() const { return m_pcre != NULL; }
@@ -2903,7 +2903,6 @@ public:
DBUG_VOID_RETURN;
}
longlong val_int();
- bool fix_fields(THD *thd, Item **ref);
bool fix_length_and_dec();
const char *func_name() const { return "regexp"; }
enum precedence precedence() const { return CMP_PRECEDENCE; }
@@ -2944,7 +2943,6 @@ public:
DBUG_VOID_RETURN;
}
longlong val_int();
- bool fix_fields(THD *thd, Item **ref);
bool fix_length_and_dec();
const char *func_name() const { return "regexp_instr"; }
Item *get_copy(THD *thd) { return 0; }