PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "catalog/pg_type.h"
#include "funcapi.h"
#include "regex/regex.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
struct | pg_re_flags |
struct | regexp_matches_ctx |
struct | cached_re_str |
Macros | |
#define | PG_GETARG_TEXT_PP_IF_EXISTS(_n) (PG_NARGS() > (_n) ? PG_GETARG_TEXT_PP(_n) : NULL) |
#define | MAX_CACHED_RES 32 |
Typedefs | |
typedef struct pg_re_flags | pg_re_flags |
typedef struct regexp_matches_ctx | regexp_matches_ctx |
typedef struct cached_re_str | cached_re_str |
Variables | |
static MemoryContext | RegexpCacheMemoryContext |
static int | num_res = 0 |
static cached_re_str | re_array [MAX_CACHED_RES] |
#define PG_GETARG_TEXT_PP_IF_EXISTS | ( | _n | ) | (PG_NARGS() > (_n) ? PG_GETARG_TEXT_PP(_n) : NULL) |
typedef struct cached_re_str cached_re_str |
typedef struct pg_re_flags pg_re_flags |
typedef struct regexp_matches_ctx regexp_matches_ctx |
|
static |
Definition at line 1620 of file regexp.c.
References Assert, buf, construct_md_array(), regexp_matches_ctx::conv_buf, cstring_to_text_with_len(), DirectFunctionCall3, regexp_matches_ctx::elems, i, Int32GetDatum(), len, regexp_matches_ctx::match_locs, regexp_matches_ctx::next_match, regexp_matches_ctx::npatterns, regexp_matches_ctx::nulls, regexp_matches_ctx::orig_str, pg_wchar2mb_with_len(), PointerGetDatum(), text_substr(), and regexp_matches_ctx::wide_str.
Referenced by regexp_match(), and regexp_matches().
|
static |
Definition at line 1791 of file regexp.c.
References Assert, buf, regexp_matches_ctx::conv_buf, cstring_to_text_with_len(), DirectFunctionCall3, elog, endpos, ERROR, Int32GetDatum(), len, regexp_matches_ctx::match_locs, regexp_matches_ctx::next_match, regexp_matches_ctx::orig_str, pg_wchar2mb_with_len(), PointerGetDatum(), startpos, text_substr(), and regexp_matches_ctx::wide_str.
Referenced by regexp_split_to_array(), and regexp_split_to_table().
Datum nameicregexeq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 522 of file regexp.c.
References NameStr, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, RE_compile_and_execute(), REG_ADVANCED, and REG_ICASE.
Datum nameicregexne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 536 of file regexp.c.
References NameStr, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, RE_compile_and_execute(), REG_ADVANCED, and REG_ICASE.
Datum nameregexeq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 459 of file regexp.c.
References NameStr, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, RE_compile_and_execute(), and REG_ADVANCED.
Datum nameregexne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 473 of file regexp.c.
References NameStr, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, RE_compile_and_execute(), and REG_ADVANCED.
|
static |
Definition at line 385 of file regexp.c.
References pg_re_flags::cflags, ereport, errcode(), errmsg(), ERROR, pg_re_flags::glob, i, opts, pg_mblen(), REG_ADVANCED, REG_EXPANDED, REG_EXTENDED, REG_ICASE, REG_NEWLINE, REG_NLANCH, REG_NLSTOP, REG_QUOTE, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by regexp_count(), regexp_instr(), regexp_like(), regexp_match(), regexp_matches(), regexp_split_to_array(), regexp_split_to_table(), regexp_substr(), textregexreplace(), and textregexreplace_extended().
Definition at line 141 of file regexp.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, Assert, cached_re_str::cre_collation, cached_re_str::cre_context, cached_re_str::cre_flags, cached_re_str::cre_pat, cached_re_str::cre_pat_len, cached_re_str::cre_re, CurrentMemoryContext, ereport, errcode(), errmsg(), ERROR, i, MAX_CACHED_RES, MemoryContextDelete(), MemoryContextSetIdentifier(), MemoryContextSetParent(), MemoryContextSwitchTo(), num_res, palloc(), pfree(), pg_mb2wchar_with_len(), pg_regcomp(), pg_regerror(), re_array, REG_OKAY, RegexpCacheMemoryContext, TopMemoryContext, unlikely, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by RE_compile_and_execute(), regexp_fixed_prefix(), replace_text_regexp(), setup_regexp_matches(), and textregexsubstr().
bool RE_compile_and_execute | ( | text * | text_re, |
char * | dat, | ||
int | dat_len, | ||
int | cflags, | ||
Oid | collation, | ||
int | nmatch, | ||
regmatch_t * | pmatch | ||
) |
Definition at line 358 of file regexp.c.
References RE_compile_and_cache(), RE_execute(), REG_NOSUB, and regex_t.
Referenced by executeLikeRegex(), nameicregexeq(), nameicregexne(), nameregexeq(), nameregexne(), regexp_like(), texticregexeq(), texticregexne(), textregexeq(), and textregexne().
|
static |
Definition at line 324 of file regexp.c.
References data, palloc(), pfree(), pg_mb2wchar_with_len(), and RE_wchar_execute().
Referenced by RE_compile_and_execute(), and textregexsubstr().
|
static |
Definition at line 282 of file regexp.c.
References data, ereport, errcode(), errmsg(), ERROR, pg_regerror(), pg_regexec(), REG_NOMATCH, and REG_OKAY.
Referenced by RE_execute(), and setup_regexp_matches().
Datum regexp_count | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1066 of file regexp.c.
References ereport, errcode(), errmsg(), ERROR, pg_re_flags::glob, regexp_matches_ctx::nmatches, parse_re_flags(), PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_GETARG_TEXT_PP_IF_EXISTS, PG_NARGS, PG_RETURN_INT32, setup_regexp_matches(), start, and str.
Referenced by regexp_count_no_flags(), and regexp_count_no_start().
Datum regexp_count_no_flags | ( | PG_FUNCTION_ARGS | ) |
Datum regexp_count_no_start | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1109 of file regexp.c.
References regexp_count().
Definition at line 1953 of file regexp.c.
References Assert, ereport, errcode(), errmsg(), ERROR, palloc(), pfree(), pg_database_encoding_max_length(), pg_regerror(), pg_regprefix(), pg_wchar2mb_with_len(), RE_compile_and_cache(), REG_ADVANCED, REG_EXACT, REG_ICASE, REG_NOMATCH, REG_NOSUB, REG_PREFIX, regex_t, and str.
Referenced by regex_fixed_prefix().
Datum regexp_instr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1126 of file regexp.c.
References ereport, errcode(), errmsg(), ERROR, pg_re_flags::glob, if(), regexp_matches_ctx::match_locs, regexp_matches_ctx::nmatches, regexp_matches_ctx::npatterns, parse_re_flags(), PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_GETARG_TEXT_PP_IF_EXISTS, PG_NARGS, PG_RETURN_INT32, setup_regexp_matches(), start, and str.
Referenced by regexp_instr_no_endoption(), regexp_instr_no_flags(), regexp_instr_no_n(), regexp_instr_no_start(), and regexp_instr_no_subexpr().
Datum regexp_instr_no_endoption | ( | PG_FUNCTION_ARGS | ) |
Datum regexp_instr_no_flags | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1240 of file regexp.c.
References regexp_instr().
Datum regexp_instr_no_n | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1226 of file regexp.c.
References regexp_instr().
Datum regexp_instr_no_start | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1219 of file regexp.c.
References regexp_instr().
Datum regexp_instr_no_subexpr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1247 of file regexp.c.
References regexp_instr().
Datum regexp_like | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1257 of file regexp.c.
References pg_re_flags::cflags, ereport, errcode(), errmsg(), ERROR, pg_re_flags::glob, parse_re_flags(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_GETARG_TEXT_PP_IF_EXISTS, PG_RETURN_BOOL, RE_compile_and_execute(), str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by regexp_like_no_flags().
Datum regexp_like_no_flags | ( | PG_FUNCTION_ARGS | ) |
Datum regexp_match | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1295 of file regexp.c.
References Assert, build_regexp_match_result(), regexp_matches_ctx::elems, ereport, errcode(), errhint(), errmsg(), ERROR, pg_re_flags::glob, regexp_matches_ctx::nmatches, regexp_matches_ctx::npatterns, regexp_matches_ctx::nulls, palloc(), parse_re_flags(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_GETARG_TEXT_PP_IF_EXISTS, PG_RETURN_DATUM, PG_RETURN_NULL, PointerGetDatum(), and setup_regexp_matches().
Referenced by regexp_match_no_flags().
Datum regexp_match_no_flags | ( | PG_FUNCTION_ARGS | ) |
Datum regexp_matches | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1341 of file regexp.c.
References build_regexp_match_result(), regexp_matches_ctx::elems, if(), MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, regexp_matches_ctx::next_match, regexp_matches_ctx::nmatches, regexp_matches_ctx::npatterns, regexp_matches_ctx::nulls, palloc(), parse_re_flags(), PG_GET_COLLATION, PG_GETARG_TEXT_P_COPY, PG_GETARG_TEXT_PP, PG_GETARG_TEXT_PP_IF_EXISTS, PointerGetDatum(), setup_regexp_matches(), SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, and FuncCallContext::user_fctx.
Referenced by regexp_matches_no_flags().
Datum regexp_matches_no_flags | ( | PG_FUNCTION_ARGS | ) |
Datum regexp_split_to_array | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1740 of file regexp.c.
References accumArrayResult(), build_regexp_split_result(), CurrentMemoryContext, ereport, errcode(), errmsg(), ERROR, pg_re_flags::glob, makeArrayResult(), regexp_matches_ctx::next_match, regexp_matches_ctx::nmatches, parse_re_flags(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_GETARG_TEXT_PP_IF_EXISTS, PG_RETURN_DATUM, and setup_regexp_matches().
Referenced by regexp_split_to_array_no_flags().
Datum regexp_split_to_array_no_flags | ( | PG_FUNCTION_ARGS | ) |
Datum regexp_split_to_table | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1676 of file regexp.c.
References build_regexp_split_result(), ereport, errcode(), errmsg(), ERROR, pg_re_flags::glob, if(), MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, regexp_matches_ctx::next_match, regexp_matches_ctx::nmatches, parse_re_flags(), PG_GET_COLLATION, PG_GETARG_TEXT_P_COPY, PG_GETARG_TEXT_PP, PG_GETARG_TEXT_PP_IF_EXISTS, setup_regexp_matches(), SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, and FuncCallContext::user_fctx.
Referenced by regexp_split_to_table_no_flags().
Datum regexp_split_to_table_no_flags | ( | PG_FUNCTION_ARGS | ) |
Datum regexp_substr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1832 of file regexp.c.
References DirectFunctionCall3, ereport, errcode(), errmsg(), ERROR, pg_re_flags::glob, if(), Int32GetDatum(), regexp_matches_ctx::match_locs, regexp_matches_ctx::nmatches, regexp_matches_ctx::npatterns, regexp_matches_ctx::orig_str, parse_re_flags(), PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_GETARG_TEXT_PP_IF_EXISTS, PG_NARGS, PG_RETURN_DATUM, PG_RETURN_NULL, PointerGetDatum(), setup_regexp_matches(), start, str, and text_substr().
Referenced by regexp_substr_no_flags(), regexp_substr_no_n(), regexp_substr_no_start(), and regexp_substr_no_subexpr().
Datum regexp_substr_no_flags | ( | PG_FUNCTION_ARGS | ) |
Datum regexp_substr_no_n | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1927 of file regexp.c.
References regexp_substr().
Datum regexp_substr_no_start | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1920 of file regexp.c.
References regexp_substr().
Datum regexp_substr_no_subexpr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1941 of file regexp.c.
References regexp_substr().
|
static |
Definition at line 1416 of file regexp.c.
References pg_re_flags::cflags, regexp_matches_ctx::conv_buf, regexp_matches_ctx::conv_bufsiz, ereport, errcode(), errmsg(), ERROR, pg_re_flags::glob, i, regexp_matches_ctx::match_locs, MaxAllocSize, regexp_matches_ctx::nmatches, regexp_matches_ctx::npatterns, regexp_matches_ctx::orig_str, palloc(), palloc0(), pfree(), pg_database_encoding_max_length(), pg_mb2wchar_with_len(), RE_compile_and_cache(), RE_wchar_execute(), REG_NOSUB, regex_t, regmatch_t, repalloc(), VARDATA_ANY, VARSIZE_ANY_EXHDR, and regexp_matches_ctx::wide_str.
Referenced by regexp_count(), regexp_instr(), regexp_match(), regexp_matches(), regexp_split_to_array(), regexp_split_to_table(), and regexp_substr().
Datum similar_escape | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1040 of file regexp.c.
References PG_ARGISNULL, PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, and similar_escape_internal().
Definition at line 767 of file regexp.c.
References ereport, errcode(), errhint(), errmsg(), ERROR, palloc(), pg_mblen(), pg_mbstrlen_with_len(), SET_VARSIZE, VARDATA, VARDATA_ANY, VARHDRSZ, and VARSIZE_ANY_EXHDR.
Referenced by similar_escape(), similar_to_escape_1(), and similar_to_escape_2().
Datum similar_to_escape_1 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1022 of file regexp.c.
References PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, and similar_escape_internal().
Datum similar_to_escape_2 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1006 of file regexp.c.
References PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, and similar_escape_internal().
Datum texticregexeq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 550 of file regexp.c.
References PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, RE_compile_and_execute(), REG_ADVANCED, REG_ICASE, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum texticregexne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 564 of file regexp.c.
References PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, RE_compile_and_execute(), REG_ADVANCED, REG_ICASE, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum textregexeq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 487 of file regexp.c.
References PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, RE_compile_and_execute(), REG_ADVANCED, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum textregexne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 501 of file regexp.c.
References PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, RE_compile_and_execute(), REG_ADVANCED, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum textregexreplace | ( | PG_FUNCTION_ARGS | ) |
Definition at line 658 of file regexp.c.
References pg_re_flags::cflags, ereport, errcode(), errhint(), errmsg(), ERROR, pg_re_flags::glob, parse_re_flags(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, pg_mblen(), PG_RETURN_TEXT_P, replace_text_regexp(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by execute_extension_script().
Datum textregexreplace_extended | ( | PG_FUNCTION_ARGS | ) |
Definition at line 699 of file regexp.c.
References pg_re_flags::cflags, ereport, errcode(), errmsg(), ERROR, pg_re_flags::glob, parse_re_flags(), PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_GETARG_TEXT_PP_IF_EXISTS, PG_NARGS, PG_RETURN_TEXT_P, replace_text_regexp(), and start.
Referenced by textregexreplace_extended_no_flags(), and textregexreplace_extended_no_n().
Datum textregexreplace_extended_no_flags | ( | PG_FUNCTION_ARGS | ) |
Datum textregexreplace_extended_no_n | ( | PG_FUNCTION_ARGS | ) |
Definition at line 744 of file regexp.c.
References textregexreplace_extended().
Datum textregexreplace_noopt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 642 of file regexp.c.
References PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, REG_ADVANCED, and replace_text_regexp().
Datum textregexsubstr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 583 of file regexp.c.
References DirectFunctionCall3, Int32GetDatum(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_NULL, PointerGetDatum(), RE_compile_and_cache(), RE_execute(), REG_ADVANCED, regex_t, regmatch_t, text_substr(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
|
static |
Definition at line 112 of file regexp.c.
Referenced by RE_compile_and_cache().
|
static |
Definition at line 113 of file regexp.c.
Referenced by RE_compile_and_cache().
|
static |
Definition at line 99 of file regexp.c.
Referenced by RE_compile_and_cache().