PostgreSQL Source Code  git master
regex.h File Reference
#include "mb/pg_wchar.h"
Include dependency graph for regex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  regex_t
 
struct  regmatch_t
 
struct  rm_detail_t
 

Macros

#define _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_CANCEL   21 /* operation cancelled */
 
#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 */
 

Typedefs

typedef long regoff_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_tRE_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)
 

Macro Definition Documentation

◆ _REGEX_H_

#define _REGEX_H_   /* never again */

Definition at line 2 of file regex.h.

◆ REG_ADVANCED

#define REG_ADVANCED   000003 /* AREs (which are also EREs) */

Definition at line 103 of file regex.h.

◆ REG_ADVF

#define REG_ADVF   000002 /* advanced features in EREs */

Definition at line 102 of file regex.h.

◆ REG_ASSERT

#define REG_ASSERT   15 /* "can't happen" -- you found a bug */

Definition at line 151 of file regex.h.

◆ REG_ATOI

#define REG_ATOI   101 /* convert error-code name to number */

Definition at line 159 of file regex.h.

◆ REG_BADBR

#define REG_BADBR   10 /* invalid repetition count(s) */

Definition at line 147 of file regex.h.

◆ REG_BADOPT

#define REG_BADOPT   18 /* invalid embedded option */

Definition at line 154 of file regex.h.

◆ REG_BADPAT

#define REG_BADPAT   2 /* invalid regexp */

Definition at line 139 of file regex.h.

◆ REG_BADRPT

#define REG_BADRPT   13 /* quantifier operand invalid */

Definition at line 150 of file regex.h.

◆ REG_BASIC

#define REG_BASIC   000000 /* BREs (convenience) */

Definition at line 100 of file regex.h.

◆ REG_BOSONLY

#define REG_BOSONLY   002000 /* temporary kludge for BOS-only matches */

Definition at line 114 of file regex.h.

◆ REG_CANCEL

#define REG_CANCEL   21 /* operation cancelled */

Definition at line 157 of file regex.h.

◆ REG_DUMP

#define REG_DUMP   004000 /* none of your business :-) */

Definition at line 115 of file regex.h.

◆ REG_EBRACE

#define REG_EBRACE   9 /* braces {} not balanced */

Definition at line 146 of file regex.h.

◆ REG_EBRACK

#define REG_EBRACK   7 /* brackets [] not balanced */

Definition at line 144 of file regex.h.

◆ REG_ECOLLATE

#define REG_ECOLLATE   3 /* invalid collating element */

Definition at line 140 of file regex.h.

◆ REG_ECOLORS

#define REG_ECOLORS   20 /* too many colors */

Definition at line 156 of file regex.h.

◆ REG_ECTYPE

#define REG_ECTYPE   4 /* invalid character class */

Definition at line 141 of file regex.h.

◆ REG_EESCAPE

#define REG_EESCAPE   5 /* invalid escape \ sequence */

Definition at line 142 of file regex.h.

◆ REG_EPAREN

#define REG_EPAREN   8 /* parentheses () not balanced */

Definition at line 145 of file regex.h.

◆ REG_ERANGE

#define REG_ERANGE   11 /* invalid character range */

Definition at line 148 of file regex.h.

◆ REG_ESPACE

#define REG_ESPACE   12 /* out of memory */

Definition at line 149 of file regex.h.

◆ REG_ESUBREG

#define REG_ESUBREG   6 /* invalid backreference number */

Definition at line 143 of file regex.h.

◆ REG_ETOOBIG

#define REG_ETOOBIG   19 /* regular expression is too complex */

Definition at line 155 of file regex.h.

◆ REG_EXACT

#define REG_EXACT   (-2) /* identified an exact match */

Definition at line 163 of file regex.h.

◆ REG_EXPANDED

#define REG_EXPANDED   000040 /* expanded format, white space & comments */

Definition at line 108 of file regex.h.

◆ REG_EXPECT

#define REG_EXPECT   001000 /* report details on partial/limited matches */

Definition at line 113 of file regex.h.

◆ REG_EXTENDED

#define REG_EXTENDED   000001 /* EREs */

Definition at line 101 of file regex.h.

◆ REG_FAKE

#define REG_FAKE   010000 /* none of your business :-) */

Definition at line 116 of file regex.h.

◆ REG_FTRACE

#define REG_FTRACE   0010 /* none of your business */

Definition at line 127 of file regex.h.

◆ REG_ICASE

#define REG_ICASE   000010 /* ignore case */

Definition at line 106 of file regex.h.

◆ REG_INVARG

#define REG_INVARG   16 /* invalid argument to regex function */

Definition at line 152 of file regex.h.

◆ REG_ITOA

#define REG_ITOA   102 /* convert error-code number to name */

Definition at line 160 of file regex.h.

◆ REG_MIXED

#define REG_MIXED   17 /* character widths of regex and string differ */

Definition at line 153 of file regex.h.

◆ REG_MTRACE

#define REG_MTRACE   0020 /* none of your business */

Definition at line 128 of file regex.h.

◆ REG_NEWLINE

#define REG_NEWLINE   000300 /* newlines are line terminators */

Definition at line 111 of file regex.h.

◆ REG_NLANCH

#define REG_NLANCH   000200 /* ^ matches after \n, $ before */

Definition at line 110 of file regex.h.

◆ REG_NLSTOP

#define REG_NLSTOP   000100 /* \n doesn't match . or [^ ] */

Definition at line 109 of file regex.h.

◆ REG_NOMATCH

#define REG_NOMATCH   1 /* failed to match */

Definition at line 138 of file regex.h.

◆ REG_NOSPEC

#define REG_NOSPEC   REG_QUOTE /* historical synonym */

Definition at line 105 of file regex.h.

◆ REG_NOSUB

#define REG_NOSUB   000020 /* caller doesn't need subexpr match data */

Definition at line 107 of file regex.h.

◆ REG_NOTBOL

#define REG_NOTBOL   0001 /* BOS is not BOL */

Definition at line 124 of file regex.h.

◆ REG_NOTEOL

#define REG_NOTEOL   0002 /* EOS is not EOL */

Definition at line 125 of file regex.h.

◆ REG_OKAY

#define REG_OKAY   0 /* no errors detected */

Definition at line 137 of file regex.h.

◆ REG_PEND

#define REG_PEND   000400 /* ugh -- backward-compatibility hack */

Definition at line 112 of file regex.h.

◆ REG_PREFIX

#define REG_PREFIX   (-1) /* identified a common prefix */

Definition at line 162 of file regex.h.

◆ REG_PROGRESS

#define REG_PROGRESS   020000 /* none of your business :-) */

Definition at line 117 of file regex.h.

◆ REG_QUOTE

#define REG_QUOTE   000004 /* no special characters, none */

Definition at line 104 of file regex.h.

◆ REG_SMALL

#define REG_SMALL   0040 /* none of your business */

Definition at line 129 of file regex.h.

◆ REG_STARTEND

#define REG_STARTEND   0004 /* backward compatibility kludge */

Definition at line 126 of file regex.h.

◆ REG_UBACKREF

#define REG_UBACKREF   000001 /* has back-reference (\n) */

Definition at line 60 of file regex.h.

◆ REG_UBBS

#define REG_UBBS   000100 /* has backslash within bracket expr */

Definition at line 66 of file regex.h.

◆ REG_UBOUNDS

#define REG_UBOUNDS   000004 /* has bounded quantifier ({m,n}) */

Definition at line 62 of file regex.h.

◆ REG_UBRACES

#define REG_UBRACES   000010 /* has { that doesn't begin a quantifier */

Definition at line 63 of file regex.h.

◆ REG_UBSALNUM

#define REG_UBSALNUM   000020 /* has backslash-alphanumeric in non-ARE */

Definition at line 64 of file regex.h.

◆ REG_UEMPTYMATCH

#define REG_UEMPTYMATCH   004000 /* can match a zero-length string */

Definition at line 71 of file regex.h.

◆ REG_UIMPOSSIBLE

#define REG_UIMPOSSIBLE   010000 /* provably cannot match anything */

Definition at line 72 of file regex.h.

◆ REG_ULOCALE

#define REG_ULOCALE   002000 /* has locale dependency */

Definition at line 70 of file regex.h.

◆ REG_ULOOKAROUND

#define REG_ULOOKAROUND   000002 /* has lookahead/lookbehind constraint */

Definition at line 61 of file regex.h.

◆ REG_UNONPOSIX

#define REG_UNONPOSIX   000200 /* has any construct that extends POSIX */

Definition at line 67 of file regex.h.

◆ REG_UPBOTCH

#define REG_UPBOTCH
Value:
000040 /* has unmatched right paren in ERE (legal
* per spec, but that was a mistake) */

Definition at line 65 of file regex.h.

◆ REG_USHORTEST

#define REG_USHORTEST   020000 /* has non-greedy quantifier */

Definition at line 73 of file regex.h.

◆ REG_UUNPORT

#define REG_UUNPORT   001000 /* has numeric character code dependency */

Definition at line 69 of file regex.h.

◆ REG_UUNSPEC

#define REG_UUNSPEC
Value:
000400 /* has any case disallowed by POSIX, e.g.
* an empty branch */

Definition at line 68 of file regex.h.

Typedef Documentation

◆ regoff_t

typedef long regoff_t

Definition at line 48 of file regex.h.

Function Documentation

◆ 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
385  FILE *debug = (flags & REG_PROGRESS) ? stdout : (FILE *) NULL;
386 #else
387  FILE *debug = (FILE *) NULL;
388 #endif
389 
390 #define CNOERR() { if (ISERR()) return freev(v, v->err); }
391 
392  /* sanity checks */
393 
394  if (re == NULL || string == NULL)
395  return REG_INVARG;
396  if ((flags & REG_QUOTE) &&
397  (flags & (REG_ADVANCED | REG_EXPANDED | REG_NEWLINE)))
398  return REG_INVARG;
399  if (!(flags & REG_EXTENDED) && (flags & REG_ADVF))
400  return REG_INVARG;
401 
402  /* Initialize locale-dependent support */
403  pg_set_regex_collation(collation);
404 
405  /* initial setup (after which freev() is callable) */
406  v->re = re;
407  v->now = string;
408  v->stop = v->now + len;
409  v->err = 0;
410  v->cflags = flags;
411  v->nsubexp = 0;
412  v->subs = v->sub10;
413  v->nsubs = 10;
414  for (j = 0; j < v->nsubs; j++)
415  v->subs[j] = NULL;
416  v->nfa = NULL;
417  v->cm = NULL;
418  v->nlcolor = COLORLESS;
419  v->wordchrs = NULL;
420  v->tree = NULL;
421  v->treechain = NULL;
422  v->treefree = NULL;
423  v->cv = NULL;
424  v->cv2 = NULL;
425  v->lacons = NULL;
426  v->nlacons = 0;
427  v->spaceused = 0;
428  re->re_magic = REMAGIC;
429  re->re_info = 0; /* bits get set during parse */
430  re->re_csize = sizeof(chr);
431  re->re_collation = collation;
432  re->re_guts = NULL;
433  re->re_fns = VS(&functions);
434 
435  /* more complex setup, malloced things */
436  re->re_guts = VS(MALLOC(sizeof(struct guts)));
437  if (re->re_guts == NULL)
438  return freev(v, REG_ESPACE);
439  g = (struct guts *) re->re_guts;
440  g->tree = NULL;
441  initcm(v, &g->cmap);
442  v->cm = &g->cmap;
443  g->lacons = NULL;
444  g->nlacons = 0;
445  ZAPCNFA(g->search);
446  v->nfa = newnfa(v, v->cm, (struct nfa *) NULL);
447  CNOERR();
448  /* set up a reasonably-sized transient cvec for getcvec usage */
449  v->cv = newcvec(100, 20);
450  if (v->cv == NULL)
451  return freev(v, REG_ESPACE);
452 
453  /* parsing */
454  lexstart(v); /* also handles prefixes */
455  if ((v->cflags & REG_NLSTOP) || (v->cflags & REG_NLANCH))
456  {
457  /* assign newline a unique color */
458  v->nlcolor = subcolor(v->cm, newline());
459  okcolors(v->nfa, v->cm);
460  }
461  CNOERR();
462  v->tree = parse(v, EOS, PLAIN, v->nfa->init, v->nfa->final);
463  assert(SEE(EOS)); /* even if error; ISERR() => SEE(EOS) */
464  CNOERR();
465  assert(v->tree != NULL);
466 
467  /* finish setup of nfa and its subre tree */
468  specialcolors(v->nfa);
469  CNOERR();
470 #ifdef REG_DEBUG
471  if (debug != NULL)
472  {
473  fprintf(debug, "\n\n\n========= RAW ==========\n");
474  dumpnfa(v->nfa, debug);
475  dumpst(v->tree, debug, 1);
476  }
477 #endif
478  if (v->cflags & REG_NOSUB)
479  removecaptures(v, v->tree);
480  v->ntree = numst(v->tree, 1);
481  markst(v->tree);
482  cleanst(v);
483 #ifdef REG_DEBUG
484  if (debug != NULL)
485  {
486  fprintf(debug, "\n\n\n========= TREE FIXED ==========\n");
487  dumpst(v->tree, debug, 1);
488  }
489 #endif
490 
491  /* build compacted NFAs for tree and lacons */
492  re->re_info |= nfatree(v, v->tree, debug);
493  CNOERR();
494  assert(v->nlacons == 0 || v->lacons != NULL);
495  for (i = 1; i < v->nlacons; i++)
496  {
497  struct subre *lasub = &v->lacons[i];
498 
499 #ifdef REG_DEBUG
500  if (debug != NULL)
501  fprintf(debug, "\n\n\n========= LA%d ==========\n", i);
502 #endif
503 
504  /* Prepend .* to pattern if it's a lookbehind LACON */
505  nfanode(v, lasub, !LATYPE_IS_AHEAD(lasub->latype), debug);
506  }
507  CNOERR();
508  if (v->tree->flags & SHORTER)
510 
511  /* build compacted NFAs for tree, lacons, fast search */
512 #ifdef REG_DEBUG
513  if (debug != NULL)
514  fprintf(debug, "\n\n\n========= SEARCH ==========\n");
515 #endif
516  /* can sacrifice main NFA now, so use it as work area */
517  (DISCARD) optimize(v->nfa, debug);
518  CNOERR();
519  makesearch(v, v->nfa);
520  CNOERR();
521  compact(v->nfa, &g->search);
522  CNOERR();
523 
524  /* looks okay, package it up */
525  re->re_nsub = v->nsubexp;
526  v->re = NULL; /* freev no longer frees re */
527  g->magic = GUTSMAGIC;
528  g->cflags = v->cflags;
529  g->info = re->re_info;
530  g->nsub = re->re_nsub;
531  g->tree = v->tree;
532  v->tree = NULL;
533  g->ntree = v->ntree;
534  g->compare = (v->cflags & REG_ICASE) ? casecmp : cmp;
535  g->lacons = v->lacons;
536  v->lacons = NULL;
537  g->nlacons = v->nlacons;
538 
539 #ifdef REG_DEBUG
540  if (flags & REG_DUMP)
541  {
542  dump(re, stdout);
543  fflush(stdout);
544  }
545 #endif
546 
547  assert(v->err == 0);
548  return freev(v, 0);
549 }
static bool debug
Definition: initdb.c:145
int j
Definition: isn.c:74
int i
Definition: isn.c:73
static void const char fflush(stdout)
const void size_t len
#define fprintf
Definition: port.h:242
char string[11]
Definition: preproc-type.c:52
void pg_set_regex_collation(Oid collation)
#define NOTE(b)
Definition: regcomp.c:325
static void compact(struct nfa *nfa, struct cnfa *cnfa)
static void specialcolors(struct nfa *nfa)
static void makesearch(struct vars *v, struct nfa *nfa)
Definition: regcomp.c:621
static int casecmp(const chr *x, const chr *y, size_t len)
static const struct fns functions
Definition: regcomp.c:357
static void cleanst(struct vars *v)
Definition: regcomp.c:2312
#define SEE(t)
Definition: regcomp.c:314
static struct nfa * newnfa(struct vars *v, struct colormap *cm, struct nfa *parent)
static long optimize(struct nfa *nfa, FILE *f)
#define CNOERR()
static void okcolors(struct nfa *nfa, struct colormap *cm)
static void initcm(struct vars *v, struct colormap *cm)
static chr newline(void)
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)
Definition: regcomp.c:2351
static void removecaptures(struct vars *v, struct subre *t)
Definition: regcomp.c:2218
#define EOS
Definition: regcomp.c:330
static void lexstart(struct vars *v)
#define PLAIN
Definition: regcomp.c:331
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
Definition: regcomp.c:717
static color subcolor(struct colormap *cm, chr c)
static void dumpnfa(struct nfa *nfa, FILE *f)
static int numst(struct subre *t, int start)
Definition: regcomp.c:2264
static int freev(struct vars *v, int err)
Definition: regcomp.c:592
static long nfatree(struct vars *v, struct subre *t, FILE *f)
Definition: regcomp.c:2331
static void markst(struct subre *t)
Definition: regcomp.c:2297
static struct cvec * newcvec(int nchrs, int nranges)
#define MALLOC(n)
Definition: regcustom.h:52
pg_wchar chr
Definition: regcustom.h:58
#define assert(x)
Definition: regcustom.h:55
#define REG_ICASE
Definition: regex.h:106
#define REG_DUMP
Definition: regex.h:115
#define REG_PROGRESS
Definition: regex.h:117
#define REG_ADVANCED
Definition: regex.h:103
#define REG_EXPANDED
Definition: regex.h:108
#define REG_NLANCH
Definition: regex.h:110
#define REG_INVARG
Definition: regex.h:152
#define REG_EXTENDED
Definition: regex.h:101
#define REG_NLSTOP
Definition: regex.h:109
#define REG_ADVF
Definition: regex.h:102
#define REG_NEWLINE
Definition: regex.h:111
#define REG_NOSUB
Definition: regex.h:107
#define REG_USHORTEST
Definition: regex.h:73
#define REG_ESPACE
Definition: regex.h:149
#define REG_QUOTE
Definition: regex.h:104
#define ZAPCNFA(cnfa)
Definition: regguts.h:429
#define REMAGIC
Definition: regguts.h:96
#define GUTSMAGIC
Definition: regguts.h:530
#define COLORLESS
Definition: regguts.h:153
#define LATYPE_IS_AHEAD(la)
Definition: regguts.h:104
#define DISCARD
Definition: regguts.h:58
#define VS(x)
Definition: regguts.h:61
#define SHORTER
Definition: regguts.h:476
Definition: regguts.h:528
struct subre * tree
Definition: regguts.h:534
struct subre * lacons
Definition: regguts.h:539
int magic
Definition: regguts.h:529
long info
Definition: regguts.h:532
struct cnfa search
Definition: regguts.h:535
int ntree
Definition: regguts.h:536
int cflags
Definition: regguts.h:531
size_t nsub
Definition: regguts.h:533
int nlacons
Definition: regguts.h:540
struct colormap cmap
Definition: regguts.h:537
Definition: regguts.h:344
struct state * final
Definition: regguts.h:347
struct state * init
Definition: regguts.h:346
char * re_guts
Definition: regex.h:78
long re_info
Definition: regex.h:59
int re_csize
Definition: regex.h:74
size_t re_nsub
Definition: regex.h:58
int re_magic
Definition: regex.h:57
Oid re_collation
Definition: regex.h:76
char * re_fns
Definition: regex.h:79
Definition: regguts.h:472
char flags
Definition: regguts.h:474
char latype
Definition: regguts.h:490
Definition: regcomp.c:282
const chr * now
Definition: regcomp.c:284
struct colormap * cm
Definition: regcomp.c:297
struct subre * tree
Definition: regcomp.c:300
struct subre ** subs
Definition: regcomp.c:293
int nlacons
Definition: regcomp.c:307
const chr * stop
Definition: regcomp.c:285
struct subre * lacons
Definition: regcomp.c:306
size_t spaceused
Definition: regcomp.c:309
int err
Definition: regcomp.c:286
int cflags
Definition: regcomp.c:287
struct subre * treechain
Definition: regcomp.c:301
int ntree
Definition: regcomp.c:303
regex_t * re
Definition: regcomp.c:283
struct subre * sub10[10]
Definition: regcomp.c:295
struct cvec * cv2
Definition: regcomp.c:305
struct subre * treefree
Definition: regcomp.c:302
struct nfa * nfa
Definition: regcomp.c:296
size_t nsubs
Definition: regcomp.c:294
struct state * wordchrs
Definition: regcomp.c:299
int nsubexp
Definition: regcomp.c:292
struct cvec * cv
Definition: regcomp.c:304
color nlcolor
Definition: regcomp.c:298

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, fflush(), 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, regex_t::re_collation, regex_t::re_csize, regex_t::re_fns, regex_t::re_guts, regex_t::re_info, regex_t::re_magic, regex_t::re_nsub, 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]; /* 50 = plenty for int */
68  size_t len;
69  int icode;
70 
71  switch (errcode)
72  {
73  case REG_ATOI: /* convert name to number */
74  for (r = rerrs; r->code >= 0; r++)
75  if (strcmp(r->name, errbuf) == 0)
76  break;
77  sprintf(convbuf, "%d", r->code); /* -1 for unknown */
78  msg = convbuf;
79  break;
80  case REG_ITOA: /* convert number to name */
81  icode = atoi(errbuf); /* not our problem if this fails */
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  { /* unknown; tell him the number */
89  sprintf(convbuf, "REG_%u", (unsigned) icode);
90  msg = convbuf;
91  }
92  break;
93  default: /* a real, normal error code */
94  for (r = rerrs; r->code >= 0; r++)
95  if (r->code == errcode)
96  break;
97  if (r->code >= 0)
98  msg = r->explain;
99  else
100  { /* unknown; say so */
101  sprintf(convbuf, unk, errcode);
102  msg = convbuf;
103  }
104  break;
105  }
106 
107  len = strlen(msg) + 1; /* space needed, including NUL */
108  if (errbuf_size > 0)
109  {
110  if (errbuf_size > len)
111  strcpy(errbuf, msg);
112  else
113  { /* truncate to fit */
114  memcpy(errbuf, msg, errbuf_size - 1);
115  errbuf[errbuf_size - 1] = '\0';
116  }
117  }
118 
119  return len;
120 }
int errcode(int sqlerrcode)
Definition: elog.c:858
#define sprintf
Definition: port.h:240
static const struct rerr rerrs[]
static const char unk[]
Definition: regerror.c:37
#define REG_ITOA
Definition: regex.h:160
#define REG_ATOI
Definition: regex.h:159
Definition: regerror.c:41
const char * explain
Definition: regerror.c:44
int code
Definition: regerror.c:42
const char * name
Definition: regerror.c:43

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()

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 
)

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
202  regmatch_t mat[LOCALMAT];
203 
204 #define LOCALDFAS 40
205  struct dfa *subdfas[LOCALDFAS];
206 
207  /* sanity checks */
208  if (re == NULL || string == NULL || re->re_magic != REMAGIC)
209  return REG_INVARG;
210  if (re->re_csize != sizeof(chr))
211  return REG_MIXED;
212  if (search_start > len)
213  return REG_NOMATCH;
214 
215  /* Initialize locale-dependent support */
217 
218  /* setup */
219  v->re = re;
220  v->g = (struct guts *) re->re_guts;
221  if ((v->g->cflags & REG_EXPECT) && details == NULL)
222  return REG_INVARG;
223  if (v->g->info & REG_UIMPOSSIBLE)
224  return REG_NOMATCH;
225  backref = (v->g->info & REG_UBACKREF) ? 1 : 0;
226  v->eflags = flags;
227  if (backref && nmatch <= v->g->nsub)
228  {
229  /* need larger work area */
230  v->nmatch = v->g->nsub + 1;
231  if (v->nmatch <= LOCALMAT)
232  v->pmatch = mat;
233  else
234  v->pmatch = (regmatch_t *) MALLOC(v->nmatch * sizeof(regmatch_t));
235  if (v->pmatch == NULL)
236  return REG_ESPACE;
237  zapallsubs(v->pmatch, v->nmatch);
238  }
239  else
240  {
241  /* we can store results directly in caller's array */
242  v->pmatch = pmatch;
243  /* ensure any extra entries in caller's array are filled with -1 */
244  if (nmatch > 0)
245  zapallsubs(pmatch, nmatch);
246  /* then forget about extra entries, to avoid useless work in find() */
247  if (nmatch > v->g->nsub + 1)
248  nmatch = v->g->nsub + 1;
249  v->nmatch = nmatch;
250  }
251  v->details = details;
252  v->start = (chr *) string;
253  v->search_start = (chr *) string + search_start;
254  v->stop = (chr *) string + len;
255  v->err = 0;
256  v->subdfas = NULL;
257  v->ladfas = NULL;
258  v->lblastcss = NULL;
259  v->lblastcp = NULL;
260  /* below this point, "goto cleanup" will behave sanely */
261 
262  assert(v->g->ntree >= 0);
263  n = (size_t) v->g->ntree;
264  if (n <= LOCALDFAS)
265  v->subdfas = subdfas;
266  else
267  {
268  v->subdfas = (struct dfa **) MALLOC(n * sizeof(struct dfa *));
269  if (v->subdfas == NULL)
270  {
271  st = REG_ESPACE;
272  goto cleanup;
273  }
274  }
275  for (i = 0; i < n; i++)
276  v->subdfas[i] = NULL;
277 
278  assert(v->g->nlacons >= 0);
279  n = (size_t) v->g->nlacons;
280  if (n > 0)
281  {
282  v->ladfas = (struct dfa **) MALLOC(n * sizeof(struct dfa *));
283  if (v->ladfas == NULL)
284  {
285  st = REG_ESPACE;
286  goto cleanup;
287  }
288  for (i = 0; i < n; i++)
289  v->ladfas[i] = NULL;
290  v->lblastcss = (struct sset **) MALLOC(n * sizeof(struct sset *));
291  v->lblastcp = (chr **) MALLOC(n * sizeof(chr *));
292  if (v->lblastcss == NULL || v->lblastcp == NULL)
293  {
294  st = REG_ESPACE;
295  goto cleanup;
296  }
297  for (i = 0; i < n; i++)
298  {
299  v->lblastcss[i] = NULL;
300  v->lblastcp[i] = NULL;
301  }
302  }
303 
304  /* do it */
305  assert(v->g->tree != NULL);
306  if (backref)
307  st = cfind(v, &v->g->tree->cnfa, &v->g->cmap);
308  else
309  st = find(v, &v->g->tree->cnfa, &v->g->cmap);
310 
311  /* on success, ensure caller's match vector is filled correctly */
312  if (st == REG_OKAY && nmatch > 0)
313  {
314  if (v->pmatch != pmatch)
315  {
316  /* copy portion of match vector over from (larger) work area */
317  assert(nmatch <= v->nmatch);
318  memcpy(VS(pmatch), VS(v->pmatch), nmatch * sizeof(regmatch_t));
319  }
320  if (v->g->cflags & REG_NOSUB)
321  {
322  /* don't expose possibly-partial sub-match results to caller */
323  zapallsubs(pmatch, nmatch);
324  }
325  }
326 
327  /* clean up */
328 cleanup:
329  if (v->pmatch != pmatch && v->pmatch != mat)
330  FREE(v->pmatch);
331  if (v->subdfas != NULL)
332  {
333  n = (size_t) v->g->ntree;
334  for (i = 0; i < n; i++)
335  {
336  if (v->subdfas[i] != NULL)
337  freedfa(v->subdfas[i]);
338  }
339  if (v->subdfas != subdfas)
340  FREE(v->subdfas);
341  }
342  if (v->ladfas != NULL)
343  {
344  n = (size_t) v->g->nlacons;
345  for (i = 0; i < n; i++)
346  {
347  if (v->ladfas[i] != NULL)
348  freedfa(v->ladfas[i]);
349  }
350  FREE(v->ladfas);
351  }
352  if (v->lblastcss != NULL)
353  FREE(v->lblastcss);
354  if (v->lblastcp != NULL)
355  FREE(v->lblastcp);
356 
357 #ifdef REG_DEBUG
358  if (v->eflags & (REG_FTRACE | REG_MTRACE))
359  fflush(stdout);
360 #endif
361 
362  return st;
363 }
static void cleanup(void)
Definition: bootstrap.c:696
#define FREE(ptr)
Definition: cryptohash.c:37
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:77
#define REG_NOMATCH
Definition: regex.h:138
#define REG_UIMPOSSIBLE
Definition: regex.h:72
#define REG_MTRACE
Definition: regex.h:128
#define REG_FTRACE
Definition: regex.h:127
#define REG_EXPECT
Definition: regex.h:113
#define REG_OKAY
Definition: regex.h:137
#define REG_MIXED
Definition: regex.h:153
#define REG_UBACKREF
Definition: regex.h:60
static int find(struct vars *v, struct cnfa *cnfa, struct colormap *cm)
Definition: regexec.c:419
static void freedfa(struct dfa *d)
static void zapallsubs(regmatch_t *p, size_t n)
Definition: regexec.c:663
static int cfind(struct vars *v, struct cnfa *cnfa, struct colormap *cm)
Definition: regexec.c:509
#define LOCALMAT
#define LOCALDFAS
Definition: regexec.c:64
Definition: regexec.c:46
struct cnfa cnfa
Definition: regguts.h:500
size_t nmatch
Definition: regexec.c:111
struct dfa ** ladfas
Definition: regexec.c:119
struct dfa ** subdfas
Definition: regexec.c:118
chr * search_start
Definition: regexec.c:115
struct sset ** lblastcss
Definition: regexec.c:120
struct guts * g
Definition: regexec.c:109
chr ** lblastcp
Definition: regexec.c:121
int eflags
Definition: regexec.c:110
chr * start
Definition: regexec.c:114
rm_detail_t * details
Definition: regexec.c:113
regmatch_t * pmatch
Definition: regexec.c:112

References assert, cfind(), guts::cflags, cleanup(), guts::cmap, subre::cnfa, vars::details, vars::eflags, vars::err, fflush(), find(), 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, regex_t::re_collation, regex_t::re_csize, regex_t::re_guts, regex_t::re_magic, REG_ESPACE, REG_EXPECT, REG_FTRACE, REG_INVARG, REG_MIXED, REG_MTRACE, REG_NOMATCH, REG_NOSUB, REG_OKAY, REG_UBACKREF, REG_UIMPOSSIBLE, 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()

void pg_regfree ( regex_t re)

Definition at line 49 of file regfree.c.

50 {
51  if (re == NULL)
52  return;
53  (*((struct fns *) re->re_fns)->free) (re);
54 }
Definition: regguts.h:511

References regex_t::re_fns.

Referenced by createTrgmNFA(), free_auth_token(), RE_compile_and_cache(), regex_affix_deletion_callback(), and test_regex().

◆ pg_regprefix()

int pg_regprefix ( regex_t re,
pg_wchar **  string,
size_t *  slength 
)

Definition at line 46 of file regprefix.c.

49 {
50  struct guts *g;
51  struct cnfa *cnfa;
52  int st;
53 
54  /* sanity checks */
55  if (string == NULL || slength == NULL)
56  return REG_INVARG;
57  *string = NULL; /* initialize for failure cases */
58  *slength = 0;
59  if (re == NULL || re->re_magic != REMAGIC)
60  return REG_INVARG;
61  if (re->re_csize != sizeof(chr))
62  return REG_MIXED;
63 
64  /* Initialize locale-dependent support */
66 
67  /* setup */
68  g = (struct guts *) re->re_guts;
69  if (g->info & REG_UIMPOSSIBLE)
70  return REG_NOMATCH;
71 
72  /*
73  * This implementation considers only the search NFA for the topmost regex
74  * tree node. Therefore, constraints such as backrefs are not fully
75  * applied, which is allowed per the function's API spec.
76  */
77  assert(g->tree != NULL);
78  cnfa = &g->tree->cnfa;
79 
80  /* matchall NFAs never have a fixed prefix */
81  if (cnfa->flags & MATCHALL)
82  return REG_NOMATCH;
83 
84  /*
85  * Since a correct NFA should never contain any exit-free loops, it should
86  * not be possible for our traversal to return to a previously visited NFA
87  * state. Hence we need at most nstates chrs in the output string.
88  */
89  *string = (chr *) MALLOC(cnfa->nstates * sizeof(chr));
90  if (*string == NULL)
91  return REG_ESPACE;
92 
93  /* do it */
94  st = findprefix(cnfa, &g->cmap, *string, slength);
95 
96  assert(*slength <= cnfa->nstates);
97 
98  /* clean up */
99  if (st != REG_PREFIX && st != REG_EXACT)
100  {
101  FREE(*string);
102  *string = NULL;
103  *slength = 0;
104  }
105 
106  return st;
107 }
#define REG_EXACT
Definition: regex.h:163
#define REG_PREFIX
Definition: regex.h:162
#define MATCHALL
Definition: regguts.h:407
static int findprefix(struct cnfa *cnfa, struct colormap *cm, chr *string, size_t *slength)
Definition: regprefix.c:116
Definition: regguts.h:402
int flags
Definition: regguts.h:405
int nstates
Definition: regguts.h:403

References assert, guts::cmap, subre::cnfa, findprefix(), cnfa::flags, FREE, if(), guts::info, MALLOC, MATCHALL, cnfa::nstates, pg_set_regex_collation(), regex_t::re_collation, regex_t::re_csize, regex_t::re_guts, regex_t::re_magic, 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 138 of file regexp.c.

139 {
140  int text_re_len = VARSIZE_ANY_EXHDR(text_re);
141  char *text_re_val = VARDATA_ANY(text_re);
142  pg_wchar *pattern;
143  int pattern_len;
144  int i;
145  int regcomp_result;
146  cached_re_str re_temp;
147  char errMsg[100];
148 
149  /*
150  * Look for a match among previously compiled REs. Since the data
151  * structure is self-organizing with most-used entries at the front, our
152  * search strategy can just be to scan from the front.
153  */
154  for (i = 0; i < num_res; i++)
155  {
156  if (re_array[i].cre_pat_len == text_re_len &&
157  re_array[i].cre_flags == cflags &&
158  re_array[i].cre_collation == collation &&
159  memcmp(re_array[i].cre_pat, text_re_val, text_re_len) == 0)
160  {
161  /*
162  * Found a match; move it to front if not there already.
163  */
164  if (i > 0)
165  {
166  re_temp = re_array[i];
167  memmove(&re_array[1], &re_array[0], i * sizeof(cached_re_str));
168  re_array[0] = re_temp;
169  }
170 
171  return &re_array[0].cre_re;
172  }
173  }
174 
175  /*
176  * Couldn't find it, so try to compile the new RE. To avoid leaking
177  * resources on failure, we build into the re_temp local.
178  */
179 
180  /* Convert pattern string to wide characters */
181  pattern = (pg_wchar *) palloc((text_re_len + 1) * sizeof(pg_wchar));
182  pattern_len = pg_mb2wchar_with_len(text_re_val,
183  pattern,
184  text_re_len);
185 
186  regcomp_result = pg_regcomp(&re_temp.cre_re,
187  pattern,
188  pattern_len,
189  cflags,
190  collation);
191 
192  pfree(pattern);
193 
194  if (regcomp_result != REG_OKAY)
195  {
196  /* re didn't compile (no need for pg_regfree, if so) */
197 
198  /*
199  * Here and in other places in this file, do CHECK_FOR_INTERRUPTS
200  * before reporting a regex error. This is so that if the regex
201  * library aborts and returns REG_CANCEL, we don't print an error
202  * message that implies the regex was invalid.
203  */
205 
206  pg_regerror(regcomp_result, &re_temp.cre_re, errMsg, sizeof(errMsg));
207  ereport(ERROR,
208  (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
209  errmsg("invalid regular expression: %s", errMsg)));
210  }
211 
212  /*
213  * We use malloc/free for the cre_pat field because the storage has to
214  * persist across transactions, and because we want to get control back on
215  * out-of-memory. The Max() is because some malloc implementations return
216  * NULL for malloc(0).
217  */
218  re_temp.cre_pat = malloc(Max(text_re_len, 1));
219  if (re_temp.cre_pat == NULL)
220  {
221  pg_regfree(&re_temp.cre_re);
222  ereport(ERROR,
223  (errcode(ERRCODE_OUT_OF_MEMORY),
224  errmsg("out of memory")));
225  }
226  memcpy(re_temp.cre_pat, text_re_val, text_re_len);
227  re_temp.cre_pat_len = text_re_len;
228  re_temp.cre_flags = cflags;
229  re_temp.cre_collation = collation;
230 
231  /*
232  * Okay, we have a valid new item in re_temp; insert it into the storage
233  * array. Discard last entry if needed.
234  */
235  if (num_res >= MAX_CACHED_RES)
236  {
237  --num_res;
239  pg_regfree(&re_array[num_res].cre_re);
240  free(re_array[num_res].cre_pat);
241  }
242 
243  if (num_res > 0)
244  memmove(&re_array[1], &re_array[0], num_res * sizeof(cached_re_str));
245 
246  re_array[0] = re_temp;
247  num_res++;
248 
249  return &re_array[0].cre_re;
250 }
#define Max(x, y)
Definition: c.h:982
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
#define free(a)
Definition: header.h:65
#define malloc(a)
Definition: header.h:50
Assert(fmt[strlen(fmt) - 1] !='\n')
unsigned int pg_wchar
Definition: mbprint.c:31
int pg_mb2wchar_with_len(const char *from, pg_wchar *to, int len)
Definition: mbutils.c:987
void pfree(void *pointer)
Definition: mcxt.c:1436
void * palloc(Size size)
Definition: mcxt.c:1210
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:121
int pg_regcomp(regex_t *re, const chr *string, size_t len, int flags, Oid collation)
Definition: regcomp.c:372
size_t pg_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
Definition: regerror.c:60
#define MAX_CACHED_RES
Definition: regexp.c:96
static int num_res
Definition: regexp.c:109
static cached_re_str re_array[MAX_CACHED_RES]
Definition: regexp.c:110
void pg_regfree(regex_t *re)
Definition: regfree.c:49
char * cre_pat
Definition: regexp.c:102
int cre_pat_len
Definition: regexp.c:103
regex_t cre_re
Definition: regexp.c:106
Oid cre_collation
Definition: regexp.c:105
int cre_flags
Definition: regexp.c:104
#define VARDATA_ANY(PTR)
Definition: varatt.h:324
#define VARSIZE_ANY_EXHDR(PTR)
Definition: varatt.h:317

References Assert(), CHECK_FOR_INTERRUPTS, cached_re_str::cre_collation, cached_re_str::cre_flags, cached_re_str::cre_pat, cached_re_str::cre_pat_len, cached_re_str::cre_re, ereport, errcode(), errmsg(), ERROR, free, i, malloc, Max, MAX_CACHED_RES, num_res, palloc(), pfree(), pg_mb2wchar_with_len(), pg_regcomp(), pg_regerror(), pg_regfree(), re_array, REG_OKAY, 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 344 of file regexp.c.

347 {
348  regex_t *re;
349 
350  /* Use REG_NOSUB if caller does not want sub-match details */
351  if (nmatch < 2)
352  cflags |= REG_NOSUB;
353 
354  /* Compile RE */
355  re = RE_compile_and_cache(text_re, cflags, collation);
356 
357  return RE_execute(re, dat, dat_len, nmatch, pmatch);
358 }
regex_t * RE_compile_and_cache(text *text_re, int cflags, Oid collation)
Definition: regexp.c:138
static bool RE_execute(regex_t *re, char *dat, int dat_len, int nmatch, regmatch_t *pmatch)
Definition: regexp.c:310
Definition: regex.h:56

References RE_compile_and_cache(), RE_execute(), and REG_NOSUB.

Referenced by executeLikeRegex(), nameicregexeq(), nameicregexne(), nameregexeq(), nameregexne(), regexp_like(), texticregexeq(), texticregexne(), textregexeq(), and textregexne().