PostgreSQL Source Code: src/include/regex/regex.h File Reference (original) (raw)
#include <[regex.h](regex%5F8h%5Fsource.html)>
#include "[mb/pg_wchar.h](pg%5F%5Fwchar%5F8h%5Fsource.html)"
Go to the source code of this file.
Data Structures | |
---|---|
struct | pg_regex_t |
struct | pg_regmatch_t |
struct | rm_detail_t |
Macros | |
---|---|
#define | _PG_REGEX_H_ /* never again */ |
#define | REG_UBACKREF 000001 /* has back-reference (\n) */ |
#define | REG_ULOOKAROUND 000002 /* has lookahead/lookbehind constraint */ |
#define | REG_UBOUNDS 000004 /* has bounded quantifier ({m,n}) */ |
#define | REG_UBRACES 000010 /* has { that doesn't begin a quantifier */ |
#define | REG_UBSALNUM 000020 /* has backslash-alphanumeric in non-ARE */ |
#define | REG_UPBOTCH |
#define | REG_UBBS 000100 /* has backslash within bracket expr */ |
#define | REG_UNONPOSIX 000200 /* has any construct that extends POSIX */ |
#define | REG_UUNSPEC |
#define | REG_UUNPORT 001000 /* has numeric character code dependency */ |
#define | REG_ULOCALE 002000 /* has locale dependency */ |
#define | REG_UEMPTYMATCH 004000 /* can match a zero-length string */ |
#define | REG_UIMPOSSIBLE 010000 /* provably cannot match anything */ |
#define | REG_USHORTEST 020000 /* has non-greedy quantifier */ |
#define | REG_BASIC 000000 /* BREs (convenience) */ |
#define | REG_EXTENDED 000001 /* EREs */ |
#define | REG_ADVF 000002 /* advanced features in EREs */ |
#define | REG_ADVANCED 000003 /* AREs (which are also EREs) */ |
#define | REG_QUOTE 000004 /* no special characters, none */ |
#define | REG_NOSPEC REG_QUOTE /* historical synonym */ |
#define | REG_ICASE 000010 /* ignore case */ |
#define | REG_NOSUB 000020 /* caller doesn't need subexpr match data */ |
#define | REG_EXPANDED 000040 /* expanded format, white space & comments */ |
#define | REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */ |
#define | REG_NLANCH 000200 /* ^ matches after \n, $ before */ |
#define | REG_NEWLINE 000300 /* newlines are line terminators */ |
#define | REG_PEND 000400 /* ugh -- backward-compatibility hack */ |
#define | REG_EXPECT 001000 /* report details on partial/limited matches */ |
#define | REG_BOSONLY 002000 /* temporary kludge for BOS-only matches */ |
#define | REG_DUMP 004000 /* none of your business :-) */ |
#define | REG_FAKE 010000 /* none of your business :-) */ |
#define | REG_PROGRESS 020000 /* none of your business :-) */ |
#define | REG_NOTBOL 0001 /* BOS is not BOL */ |
#define | REG_NOTEOL 0002 /* EOS is not EOL */ |
#define | REG_STARTEND 0004 /* backward compatibility kludge */ |
#define | REG_FTRACE 0010 /* none of your business */ |
#define | REG_MTRACE 0020 /* none of your business */ |
#define | REG_SMALL 0040 /* none of your business */ |
#define | REG_OKAY 0 /* no errors detected */ |
#define | REG_NOMATCH 1 /* failed to match */ |
#define | REG_BADPAT 2 /* invalid regexp */ |
#define | REG_ECOLLATE 3 /* invalid collating element */ |
#define | REG_ECTYPE 4 /* invalid character class */ |
#define | REG_EESCAPE 5 /* invalid escape \ sequence */ |
#define | REG_ESUBREG 6 /* invalid backreference number */ |
#define | REG_EBRACK 7 /* brackets [] not balanced */ |
#define | REG_EPAREN 8 /* parentheses () not balanced */ |
#define | REG_EBRACE 9 /* braces {} not balanced */ |
#define | REG_BADBR 10 /* invalid repetition count(s) */ |
#define | REG_ERANGE 11 /* invalid character range */ |
#define | REG_ESPACE 12 /* out of memory */ |
#define | REG_BADRPT 13 /* quantifier operand invalid */ |
#define | REG_ASSERT 15 /* "can't happen" -- you found a bug */ |
#define | REG_INVARG 16 /* invalid argument to regex function */ |
#define | REG_MIXED 17 /* character widths of regex and string differ */ |
#define | REG_BADOPT 18 /* invalid embedded option */ |
#define | REG_ETOOBIG 19 /* regular expression is too complex */ |
#define | REG_ECOLORS 20 /* too many colors */ |
#define | REG_ATOI 101 /* convert error-code name to number */ |
#define | REG_ITOA 102 /* convert error-code number to name */ |
#define | REG_PREFIX (-1) /* identified a common prefix */ |
#define | REG_EXACT (-2) /* identified an exact match */ |
#define | regoff_t pg_regoff_t |
#define | regex_t pg_regex_t |
#define | regmatch_t pg_regmatch_t |
Functions | |
---|---|
int | pg_regcomp (regex_t *re, const pg_wchar *string, size_t len, int flags, Oid collation) |
int | pg_regexec (regex_t *re, const pg_wchar *string, size_t len, size_t search_start, rm_detail_t *details, size_t nmatch, regmatch_t pmatch[], int flags) |
int | pg_regprefix (regex_t *re, pg_wchar **string, size_t *slength) |
void | pg_regfree (regex_t *re) |
size_t | pg_regerror (int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) |
regex_t * | RE_compile_and_cache (text *text_re, int cflags, Oid collation) |
bool | RE_compile_and_execute (text *text_re, char *dat, int dat_len, int cflags, Oid collation, int nmatch, regmatch_t *pmatch) |
◆ _PG_REGEX_H_
#define _PG_REGEX_H_ /* never again */
Definition at line 2 of file regex.h.
◆ REG_ADVANCED
#define REG_ADVANCED 000003 /* AREs (which are also EREs) */
◆ REG_ADVF
#define REG_ADVF 000002 /* advanced features in EREs */
◆ REG_ASSERT
#define REG_ASSERT 15 /* "can't happen" -- you found a bug */
◆ REG_ATOI
◆ REG_BADBR
#define REG_BADBR 10 /* invalid repetition count(s) */
◆ REG_BADOPT
◆ REG_BADPAT
#define REG_BADPAT 2 /* invalid regexp */
◆ REG_BADRPT
#define REG_BADRPT 13 /* quantifier operand invalid */
◆ REG_BASIC
#define REG_BASIC 000000 /* BREs (convenience) */
◆ REG_BOSONLY
#define REG_BOSONLY 002000 /* temporary kludge for BOS-only matches */
◆ REG_DUMP
#define REG_DUMP 004000 /* none of your business :-) */
◆ REG_EBRACE
#define REG_EBRACE 9 /* braces {} not balanced */
◆ REG_EBRACK
#define REG_EBRACK 7 /* brackets [] not balanced */
◆ REG_ECOLLATE
◆ REG_ECOLORS
#define REG_ECOLORS 20 /* too many colors */
◆ REG_ECTYPE
#define REG_ECTYPE 4 /* invalid character class */
◆ REG_EESCAPE
#define REG_EESCAPE 5 /* invalid escape \ sequence */
◆ REG_EPAREN
#define REG_EPAREN 8 /* parentheses () not balanced */
◆ REG_ERANGE
◆ REG_ESPACE
#define REG_ESPACE 12 /* out of memory */
◆ REG_ESUBREG
#define REG_ESUBREG 6 /* invalid backreference number */
◆ REG_ETOOBIG
#define REG_ETOOBIG 19 /* regular expression is too complex */
◆ REG_EXACT
#define REG_EXACT (-2) /* identified an exact match */
◆ REG_EXPANDED
#define REG_EXPANDED 000040 /* expanded format, white space & comments */
◆ REG_EXPECT
#define REG_EXPECT 001000 /* report details on partial/limited matches */
◆ REG_EXTENDED
#define REG_EXTENDED 000001 /* EREs */
◆ REG_FAKE
#define REG_FAKE 010000 /* none of your business :-) */
◆ REG_FTRACE
#define REG_FTRACE 0010 /* none of your business */
◆ REG_ICASE
#define REG_ICASE 000010 /* ignore case */
◆ REG_INVARG
◆ REG_ITOA
◆ REG_MIXED
#define REG_MIXED 17 /* character widths of regex and string differ */
◆ REG_MTRACE
#define REG_MTRACE 0020 /* none of your business */
◆ REG_NEWLINE
#define REG_NEWLINE 000300 /* newlines are line terminators */
◆ REG_NLANCH
#define REG_NLANCH 000200 /* ^ matches after \n, $ before */
◆ REG_NLSTOP
#define REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */
◆ REG_NOMATCH
#define REG_NOMATCH 1 /* failed to match */
◆ REG_NOSPEC
#define REG_NOSPEC REG_QUOTE /* historical synonym */
◆ REG_NOSUB
#define REG_NOSUB 000020 /* caller doesn't need subexpr match data */
◆ REG_NOTBOL
#define REG_NOTBOL 0001 /* BOS is not BOL */
◆ REG_NOTEOL
#define REG_NOTEOL 0002 /* EOS is not EOL */
◆ REG_OKAY
#define REG_OKAY 0 /* no errors detected */
◆ REG_PEND
#define REG_PEND 000400 /* ugh -- backward-compatibility hack */
◆ REG_PREFIX
#define REG_PREFIX (-1) /* identified a common prefix */
◆ REG_PROGRESS
#define REG_PROGRESS 020000 /* none of your business :-) */
◆ REG_QUOTE
#define REG_QUOTE 000004 /* no special characters, none */
◆ REG_SMALL
#define REG_SMALL 0040 /* none of your business */
◆ REG_STARTEND
#define REG_STARTEND 0004 /* backward compatibility kludge */
◆ REG_UBACKREF
#define REG_UBACKREF 000001 /* has back-reference (\n) */
◆ REG_UBBS
#define REG_UBBS 000100 /* has backslash within bracket expr */
◆ REG_UBOUNDS
#define REG_UBOUNDS 000004 /* has bounded quantifier ({m,n}) */
◆ REG_UBRACES
#define REG_UBRACES 000010 /* has { that doesn't begin a quantifier */
◆ REG_UBSALNUM
#define REG_UBSALNUM 000020 /* has backslash-alphanumeric in non-ARE */
◆ REG_UEMPTYMATCH
#define REG_UEMPTYMATCH 004000 /* can match a zero-length string */
◆ REG_UIMPOSSIBLE
#define REG_UIMPOSSIBLE 010000 /* provably cannot match anything */
◆ REG_ULOCALE
#define REG_ULOCALE 002000 /* has locale dependency */
◆ REG_ULOOKAROUND
#define REG_ULOOKAROUND 000002 /* has lookahead/lookbehind constraint */
◆ REG_UNONPOSIX
#define REG_UNONPOSIX 000200 /* has any construct that extends POSIX */
◆ REG_UPBOTCH
◆ REG_USHORTEST
#define REG_USHORTEST 020000 /* has non-greedy quantifier */
◆ REG_UUNPORT
#define REG_UUNPORT 001000 /* has numeric character code dependency */
◆ REG_UUNSPEC
◆ regex_t
◆ regmatch_t
◆ regoff_t
◆ pg_regoff_t
◆ pg_regcomp()
int pg_regcomp | ( | regex_t * | re, |
---|---|---|---|
const pg_wchar * | string, | ||
size_t | len, | ||
int | flags, | ||
Oid | collation | ||
) |
Definition at line 372 of file regcomp.c.
377{
378 struct vars var;
379 struct vars *v = &var;
380 struct guts *g;
381 int i;
382 size_t j;
383
384#ifdef REG_DEBUG
386#else
387 FILE *debug = (FILE *) NULL;
388#endif
389
390#define CNOERR() { if (ISERR()) return freev(v, v->err); }
391
392
393
394 if (re == NULL || string == NULL)
401
402
404
405
406 v->re = re;
409 v->err = 0;
414 for (j = 0; j < v->nsubs; j++)
416 v->nfa = NULL;
417 v->cm = NULL;
420 v->tree = NULL;
423 v->cv = NULL;
424 v->cv2 = NULL;
429 re->re_info = 0;
430 re->re_csize = sizeof(chr);
431 re->re_collation = collation;
432 re->re_guts = NULL;
434
435
436 re->re_guts = VS(MALLOC(sizeof(struct guts)));
437 if (re->re_guts == NULL)
439 g = (struct guts *) re->re_guts;
440 g->tree = NULL;
448
450 if (v->cv == NULL)
452
453
454 lexstart(v);
456 {
457
460 }
466
467
470#ifdef REG_DEBUG
471 if (debug != NULL)
472 {
473 fprintf(debug, "\n\n\n========= RAW ==========\n");
476 }
477#endif
483#ifdef REG_DEBUG
484 if (debug != NULL)
485 {
486 fprintf(debug, "\n\n\n========= TREE FIXED ==========\n");
488 }
489#endif
490
491
496 {
498
499#ifdef REG_DEBUG
500 if (debug != NULL)
501 fprintf(debug, "\n\n\n========= LA%d ==========\n", i);
502#endif
503
504
506 }
510
511
512#ifdef REG_DEBUG
513 if (debug != NULL)
514 fprintf(debug, "\n\n\n========= SEARCH ==========\n");
515#endif
516
523
524
525 re->re_nsub = v->nsubexp;
526 v->re = NULL;
529 g->info = re->re_info;
530 g->nsub = re->re_nsub;
532 v->tree = NULL;
538
539#ifdef REG_DEBUG
541 {
544 }
545#endif
546
548 return freev(v, 0);
549}
#define fprintf(file, fmt, msg)
void pg_set_regex_collation(Oid collation)
static struct cvec * newcvec(int nchrs, int nranges)
static void compact(struct nfa *nfa, struct cnfa *cnfa)
static void specialcolors(struct nfa *nfa)
static void makesearch(struct vars *v, struct nfa *nfa)
static int casecmp(const chr *x, const chr *y, size_t len)
static const struct fns functions
static struct nfa * newnfa(struct vars *v, struct colormap *cm, struct nfa *parent)
static void cleanst(struct vars *v)
static long optimize(struct nfa *nfa, FILE *f)
static void okcolors(struct nfa *nfa, struct colormap *cm)
static void initcm(struct vars *v, struct colormap *cm)
static int cmp(const chr *x, const chr *y, size_t len)
static long nfanode(struct vars *v, struct subre *t, int converttosearch, FILE *f)
static void removecaptures(struct vars *v, struct subre *t)
static void lexstart(struct vars *v)
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
static color subcolor(struct colormap *cm, chr c)
static void dumpnfa(struct nfa *nfa, FILE *f)
static int numst(struct subre *t, int start)
static int freev(struct vars *v, int err)
static long nfatree(struct vars *v, struct subre *t, FILE *f)
static void markst(struct subre *t)
#define LATYPE_IS_AHEAD(la)
References assert, casecmp(), vars::cflags, guts::cflags, cleanst(), vars::cm, guts::cmap, cmp(), CNOERR, COLORLESS, compact(), vars::cv, vars::cv2, debug, DISCARD, dumpnfa(), EOS, vars::err, nfa::final, subre::flags, fprintf, freev(), functions, GUTSMAGIC, i, guts::info, nfa::init, initcm(), j, vars::lacons, guts::lacons, subre::latype, LATYPE_IS_AHEAD, len, lexstart(), guts::magic, makesearch(), MALLOC, markst(), newcvec(), newline(), newnfa(), vars::nfa, nfanode(), nfatree(), vars::nlacons, guts::nlacons, vars::nlcolor, NOTE, vars::now, guts::nsub, vars::nsubexp, vars::nsubs, vars::ntree, guts::ntree, numst(), okcolors(), optimize(), parse(), pg_set_regex_collation(), PLAIN, vars::re, REG_ADVANCED, REG_ADVF, REG_DUMP, REG_ESPACE, REG_EXPANDED, REG_EXTENDED, REG_ICASE, REG_INVARG, REG_NEWLINE, REG_NLANCH, REG_NLSTOP, REG_NOSUB, REG_PROGRESS, REG_QUOTE, REG_USHORTEST, REMAGIC, removecaptures(), guts::search, SEE, SHORTER, vars::spaceused, specialcolors(), generate_unaccent_rules::stdout, vars::stop, vars::sub10, subcolor(), vars::subs, vars::tree, guts::tree, vars::treechain, vars::treefree, VS, vars::wordchrs, and ZAPCNFA.
Referenced by NIAddAffix(), RE_compile(), RE_compile_and_cache(), regcomp_auth_token(), and test_re_compile().
◆ pg_regerror()
size_t pg_regerror | ( | int | errcode, |
---|---|---|---|
const regex_t * | preg, | ||
char * | errbuf, | ||
size_t | errbuf_size | ||
) |
Definition at line 60 of file regerror.c.
64{
65 const struct rerr *r;
66 const char *msg;
67 char convbuf[sizeof(unk) + 50];
68 size_t len;
69 int icode;
70
72 {
73 case REG_ATOI:
74 for (r = rerrs; r->code >= 0; r++)
75 if (strcmp(r->name, errbuf) == 0)
76 break;
77 sprintf(convbuf, "%d", r->code);
78 msg = convbuf;
79 break;
80 case REG_ITOA:
81 icode = atoi(errbuf);
82 for (r = rerrs; r->code >= 0; r++)
83 if (r->code == icode)
84 break;
85 if (r->code >= 0)
86 msg = r->name;
87 else
88 {
89 sprintf(convbuf, "REG_%u", (unsigned) icode);
90 msg = convbuf;
91 }
92 break;
93 default:
94 for (r = rerrs; r->code >= 0; r++)
96 break;
97 if (r->code >= 0)
99 else
100 {
102 msg = convbuf;
103 }
104 break;
105 }
106
107 len = strlen(msg) + 1;
108 if (errbuf_size > 0)
109 {
110 if (errbuf_size > len)
111 strcpy(errbuf, msg);
112 else
113 {
114 memcpy(errbuf, msg, errbuf_size - 1);
115 errbuf[errbuf_size - 1] = '\0';
116 }
117 }
118
119 return len;
120}
int errcode(int sqlerrcode)
static const struct rerr rerrs[]
References rerr::code, errcode(), rerr::explain, len, rerr::name, REG_ATOI, REG_ITOA, rerrs, sprintf, and unk.
Referenced by check_ident_usermap(), NIAddAffix(), RE_compile(), RE_compile_and_cache(), RE_wchar_execute(), regcomp_auth_token(), regexp_fixed_prefix(), replace_text_regexp(), test_re_compile(), and test_re_execute().
◆ pg_regexec()
Definition at line 185 of file regexec.c.
193{
194 struct vars var;
195 struct vars *v = &var;
196 int st;
197 size_t n;
198 size_t i;
199 int backref;
200
201#define LOCALMAT 20
203
204#define LOCALDFAS 40
206
207
208 if (re == NULL || string == NULL || re->re_magic != REMAGIC)
210 if (re->re_csize != sizeof(chr))
212 if (search_start > len)
214
215
217
218
219 v->re = re;
220 v->g = (struct guts *) re->re_guts;
227 if (backref && nmatch <= v->g->nsub)
228 {
229
233 else
235 if (v->pmatch == NULL)
238 }
239 else
240 {
241
243
244 if (nmatch > 0)
246
247 if (nmatch > v->g->nsub + 1)
250 }
255 v->err = 0;
260
261
266 else
267 {
270 {
273 }
274 }
277
280 if (n > 0)
281 {
283 if (v->ladfas == NULL)
284 {
287 }
293 {
296 }
298 {
301 }
302 }
303
304
306 if (backref)
308 else
310
311
312 if (st == REG_OKAY && nmatch > 0)
313 {
314 if (v->pmatch != pmatch)
315 {
316
317 assert(nmatch <= v->nmatch);
319 }
321 {
322
324 }
325 }
326
327
332 {
335 {
338 }
339 if (v->subdfas != subdfas)
341 }
342 if (v->ladfas != NULL)
343 {
346 {
349 }
351 }
356
357#ifdef REG_DEBUG
360#endif
361
362 return st;
363}
static void cleanup(void)
if(TABLE==NULL||TABLE_index==NULL)
static int find(struct vars *v, struct cnfa *cnfa, struct colormap *cm)
static void freedfa(struct dfa *d)
static void zapallsubs(regmatch_t *p, size_t n)
static int cfind(struct vars *v, struct cnfa *cnfa, struct colormap *cm)
References assert, cfind(), guts::cflags, cleanup(), guts::cmap, subre::cnfa, vars::details, vars::eflags, vars::err, find(), for(), FREE, freedfa(), vars::g, i, if(), guts::info, vars::ladfas, vars::lblastcp, vars::lblastcss, len, LOCALDFAS, LOCALMAT, MALLOC, guts::nlacons, vars::nmatch, guts::nsub, guts::ntree, pg_set_regex_collation(), vars::pmatch, vars::re, REG_ESPACE, REG_EXPECT, REG_FTRACE, REG_INVARG, REG_MIXED, REG_MTRACE, REG_NOMATCH, REG_NOSUB, REG_OKAY, REG_UBACKREF, REG_UIMPOSSIBLE, regmatch_t, REMAGIC, vars::search_start, vars::start, generate_unaccent_rules::stdout, vars::stop, vars::subdfas, guts::tree, VS, and zapallsubs().
Referenced by CheckAffix(), RE_wchar_execute(), regexec_auth_token(), replace_text_regexp(), and test_re_execute().
◆ pg_regfree()
◆ pg_regprefix()
Definition at line 46 of file regprefix.c.
49{
50 struct guts *g;
52 int st;
53
54
55 if (string == NULL || slength == NULL)
57 *string = NULL;
58 *slength = 0;
59 if (re == NULL || re->re_magic != REMAGIC)
61 if (re->re_csize != sizeof(chr))
63
64
66
67
68 g = (struct guts *) re->re_guts;
71
72
73
74
75
76
79
80
83
84
85
86
87
88
90 if (*string == NULL)
92
93
95
96 assert(*slength <= cnfa->nstates);
97
98
100 {
101 FREE(*string);
102 *string = NULL;
103 *slength = 0;
104 }
105
106 return st;
107}
static int findprefix(struct cnfa *cnfa, struct colormap *cm, chr *string, size_t *slength)
References assert, guts::cmap, subre::cnfa, findprefix(), cnfa::flags, FREE, if(), guts::info, MALLOC, MATCHALL, cnfa::nstates, pg_set_regex_collation(), REG_ESPACE, REG_EXACT, REG_INVARG, REG_MIXED, REG_NOMATCH, REG_PREFIX, REG_UIMPOSSIBLE, REMAGIC, and guts::tree.
Referenced by regexp_fixed_prefix().
◆ RE_compile_and_cache()
regex_t * RE_compile_and_cache | ( | text * | text_re, |
---|---|---|---|
int | cflags, | ||
Oid | collation | ||
) |
Definition at line 141 of file regexp.c.
142{
144 char *text_re_val = VARDATA_ANY(text_re);
146 int pattern_len;
147 int i;
148 int regcomp_result;
150 char errMsg[100];
152
153
154
155
156
157
159 {
160 if (re_array[i].cre_pat_len == text_re_len &&
161 re_array[i].cre_flags == cflags &&
162 re_array[i].cre_collation == collation &&
163 memcmp(re_array[i].cre_pat, text_re_val, text_re_len) == 0)
164 {
165
166
167
168 if (i > 0)
169 {
173 }
174
176 }
177 }
178
179
183 "RegexpCacheMemoryContext",
185
186
187
188
189
190
191
194 pattern,
195 text_re_len);
196
197
198
199
200
201
202
203
205 "RegexpMemoryContext",
208
210 pattern,
211 pattern_len,
212 cflags,
213 collation);
214
216
217 if (regcomp_result != REG_OKAY)
218 {
219
220 pg_regerror(regcomp_result, &re_temp.cre_re, errMsg, sizeof(errMsg));
222 (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
223 errmsg("invalid regular expression: %s", errMsg)));
224 }
225
226
228 memcpy(re_temp.cre_pat, text_re_val, text_re_len);
229
230
231
232
233
234 re_temp.cre_pat[text_re_len] = 0;
236
240
241
242
243
244
246 {
249
251 }
252
253
255
258
261
263
265}
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Assert(PointerIsAligned(start, uint64))
int pg_mb2wchar_with_len(const char *from, pg_wchar *to, int len)
void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)
void pfree(void *pointer)
MemoryContext TopMemoryContext
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
void MemoryContextSetIdentifier(MemoryContext context, const char *id)
#define AllocSetContextCreate
#define ALLOCSET_SMALL_SIZES
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
int pg_regcomp(regex_t *re, const chr *string, size_t len, int flags, Oid collation)
size_t pg_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
static MemoryContext RegexpCacheMemoryContext
static cached_re_str re_array[MAX_CACHED_RES]
MemoryContext cre_context
#define VARSIZE_ANY_EXHDR(PTR)
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().
◆ RE_compile_and_execute()
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.
361{
363
364
365 if (nmatch < 2)
367
368
370
371 return RE_execute(re, dat, dat_len, nmatch, pmatch);
372}
regex_t * RE_compile_and_cache(text *text_re, int cflags, Oid collation)
static bool RE_execute(regex_t *re, char *dat, int dat_len, int nmatch, regmatch_t *pmatch)
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().