MySQL  8.0.27
Source Code Documentation
item_regexp_func.h File Reference

The function classes for regular expression functions. More...

#include <assert.h>
#include <unicode/uregex.h>
#include <optional>
#include <string>
#include "my_inttypes.h"
#include "sql/item_cmpfunc.h"
#include "sql/item_strfunc.h"
#include "sql/mysqld.h"
#include "sql/regexp/regexp_facade.h"
#include "sql_string.h"

Go to the source code of this file.


class  Item_func_regexp
 Base class for all regular expression function classes. More...
class  Item_func_regexp_instr
class  Item_func_regexp_like
class  Item_func_regexp_replace
class  Item_func_regexp_substr
class  Item_func_icu_version

Detailed Description

The function classes for regular expression functions.

They have a common base class Item_func_regexp, which is also the prefix of their class names. After the Item_func prefix comes the name of the SQL function, e.g. Item_func_regexp_instr represents the SQL function REGEXP_INSTR.

Type resolution

The type and name resolution procedure is hooked into by the Item_func_regexp class, which implement both Item_result_field::resolve_type() and Item::fix_fields().


The regular expression library doesn't deal with collations at all, but we need them because the 'winning' collation of the pattern and the subject strings dictates case-sensitivity. The winning collation is defined by coercion rules, and we don't delve into that here. See Item_func::agg_arg_charsets_for_comparison(). The call to this function is done in resolve_type() as this appears to be an unwritten convention.


All communication with the regular expression library is done through a Regexp_facade object, instantiated in Item_func_regexp::fix_fields().