diff options
Diffstat (limited to 'src/backend/regex')
-rw-r--r-- | src/backend/regex/regc_locale.c | 6 | ||||
-rw-r--r-- | src/backend/regex/regc_nfa.c | 48 | ||||
-rw-r--r-- | src/backend/regex/regcomp.c | 18 | ||||
-rw-r--r-- | src/backend/regex/rege_dfa.c | 6 | ||||
-rw-r--r-- | src/backend/regex/regexec.c | 3 |
5 files changed, 11 insertions, 70 deletions
diff --git a/src/backend/regex/regc_locale.c b/src/backend/regex/regc_locale.c index b5f3a73b1bb..77d1ce28168 100644 --- a/src/backend/regex/regc_locale.c +++ b/src/backend/regex/regc_locale.c @@ -475,11 +475,7 @@ range(struct vars *v, /* context */ } addchr(cv, cc); } - if (CANCEL_REQUESTED(v->re)) - { - ERR(REG_CANCEL); - return NULL; - } + INTERRUPT(v->re); } return cv; diff --git a/src/backend/regex/regc_nfa.c b/src/backend/regex/regc_nfa.c index 60fb0bec5d7..f1819a24f6d 100644 --- a/src/backend/regex/regc_nfa.c +++ b/src/backend/regex/regc_nfa.c @@ -143,11 +143,7 @@ newstate(struct nfa *nfa) * compilation, since no code path will go very long without making a new * state or arc. */ - if (CANCEL_REQUESTED(nfa->v->re)) - { - NERR(REG_CANCEL); - return NULL; - } + INTERRUPT(nfa->v->re); /* first, recycle anything that's on the freelist */ if (nfa->freestates != NULL) @@ -297,11 +293,7 @@ newarc(struct nfa *nfa, * compilation, since no code path will go very long without making a new * state or arc. */ - if (CANCEL_REQUESTED(nfa->v->re)) - { - NERR(REG_CANCEL); - return; - } + INTERRUPT(nfa->v->re); /* check for duplicate arc, using whichever chain is shorter */ if (from->nouts <= to->nins) @@ -825,11 +817,7 @@ moveins(struct nfa *nfa, * Because we bypass newarc() in this code path, we'd better include a * cancel check. */ - if (CANCEL_REQUESTED(nfa->v->re)) - { - NERR(REG_CANCEL); - return; - } + INTERRUPT(nfa->v->re); sortins(nfa, oldState); sortins(nfa, newState); @@ -929,11 +917,7 @@ copyins(struct nfa *nfa, * Because we bypass newarc() in this code path, we'd better include a * cancel check. */ - if (CANCEL_REQUESTED(nfa->v->re)) - { - NERR(REG_CANCEL); - return; - } + INTERRUPT(nfa->v->re); sortins(nfa, oldState); sortins(nfa, newState); @@ -1000,11 +984,7 @@ mergeins(struct nfa *nfa, * Because we bypass newarc() in this code path, we'd better include a * cancel check. */ - if (CANCEL_REQUESTED(nfa->v->re)) - { - NERR(REG_CANCEL); - return; - } + INTERRUPT(nfa->v->re); /* Sort existing inarcs as well as proposed new ones */ sortins(nfa, s); @@ -1125,11 +1105,7 @@ moveouts(struct nfa *nfa, * Because we bypass newarc() in this code path, we'd better include a * cancel check. */ - if (CANCEL_REQUESTED(nfa->v->re)) - { - NERR(REG_CANCEL); - return; - } + INTERRUPT(nfa->v->re); sortouts(nfa, oldState); sortouts(nfa, newState); @@ -1226,11 +1202,7 @@ copyouts(struct nfa *nfa, * Because we bypass newarc() in this code path, we'd better include a * cancel check. */ - if (CANCEL_REQUESTED(nfa->v->re)) - { - NERR(REG_CANCEL); - return; - } + INTERRUPT(nfa->v->re); sortouts(nfa, oldState); sortouts(nfa, newState); @@ -3282,11 +3254,7 @@ checkmatchall_recurse(struct nfa *nfa, struct state *s, bool **haspaths) return false; /* In case the search takes a long time, check for cancel */ - if (CANCEL_REQUESTED(nfa->v->re)) - { - NERR(REG_CANCEL); - return false; - } + INTERRUPT(nfa->v->re); /* Create a haspath array for this state */ haspath = (bool *) MALLOC((DUPINF + 2) * sizeof(bool)); diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index bb8c2405989..8a6cfb2973d 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -86,7 +86,6 @@ static int newlacon(struct vars *v, struct state *begin, struct state *end, int latype); static void freelacons(struct subre *subs, int n); static void rfree(regex_t *re); -static int rcancelrequested(void); static int rstacktoodeep(void); #ifdef REG_DEBUG @@ -356,7 +355,6 @@ struct vars /* static function list */ static const struct fns functions = { rfree, /* regfree insides */ - rcancelrequested, /* check for cancel request */ rstacktoodeep /* check for stack getting dangerously deep */ }; @@ -2469,22 +2467,6 @@ rfree(regex_t *re) } /* - * rcancelrequested - check for external request to cancel regex operation - * - * Return nonzero to fail the operation with error code REG_CANCEL, - * zero to keep going - * - * The current implementation is Postgres-specific. If we ever get around - * to splitting the regex code out as a standalone library, there will need - * to be some API to let applications define a callback function for this. - */ -static int -rcancelrequested(void) -{ - return InterruptPending && (QueryCancelPending || ProcDiePending); -} - -/* * rstacktoodeep - check for stack getting dangerously deep * * Return nonzero to fail the operation with error code REG_ETOOBIG, diff --git a/src/backend/regex/rege_dfa.c b/src/backend/regex/rege_dfa.c index ba1289c64a9..1f8f2ab1441 100644 --- a/src/backend/regex/rege_dfa.c +++ b/src/backend/regex/rege_dfa.c @@ -805,11 +805,7 @@ miss(struct vars *v, * Checking for operation cancel in the inner text search loop seems * unduly expensive. As a compromise, check during cache misses. */ - if (CANCEL_REQUESTED(v->re)) - { - ERR(REG_CANCEL); - return NULL; - } + INTERRUPT(v->re); /* * What set of states would we end up in after consuming the co character? diff --git a/src/backend/regex/regexec.c b/src/backend/regex/regexec.c index 3d9ff2e6079..2a1d5bebda3 100644 --- a/src/backend/regex/regexec.c +++ b/src/backend/regex/regexec.c @@ -764,8 +764,7 @@ cdissect(struct vars *v, MDEBUG(("%d: cdissect %c %ld-%ld\n", t->id, t->op, LOFF(begin), LOFF(end))); /* handy place to check for operation cancel */ - if (CANCEL_REQUESTED(v->re)) - return REG_CANCEL; + INTERRUPT(v->re); /* ... and stack overrun */ if (STACK_TOO_DEEP(v->re)) return REG_ETOOBIG; |