diff options
Diffstat (limited to 'src/backend/regex/regcomp.c')
-rw-r--r-- | src/backend/regex/regcomp.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index ca1ccc52023..d31d7f7b727 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -34,6 +34,8 @@ #include "regex/regguts.h" +#include "miscadmin.h" /* needed by rcancelrequested() */ + /* * forward declarations, up here so forward datatypes etc. are defined early */ @@ -67,6 +69,7 @@ static long nfanode(struct vars *, struct subre *, FILE *); static int newlacon(struct vars *, struct state *, struct state *, int); static void freelacons(struct subre *, int); static void rfree(regex_t *); +static int rcancelrequested(void); #ifdef REG_DEBUG static void dump(regex_t *, FILE *); @@ -276,6 +279,7 @@ struct vars /* static function list */ static const struct fns functions = { rfree, /* regfree insides */ + rcancelrequested /* check for cancel request */ }; @@ -1893,6 +1897,22 @@ 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); +} + #ifdef REG_DEBUG /* |