diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-03-01 15:20:56 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-03-01 15:20:56 -0500 |
commit | 9662143f0c35d64d7042fbeaf879df8f0b54be32 (patch) | |
tree | e352c3468320e15d1a0e029558e84b47b4ac48c1 /src/include/regex/regex.h | |
parent | d8a42b150fa83de0a058843a4d9d61af3d98e333 (diff) | |
download | postgresql-9662143f0c35d64d7042fbeaf879df8f0b54be32.tar.gz postgresql-9662143f0c35d64d7042fbeaf879df8f0b54be32.zip |
Allow regex operations to be terminated early by query cancel requests.
The regex code didn't have any provision for query cancel; which is
unsurprising given its non-Postgres origin, but still problematic since
some operations can take a long time. Introduce a callback function to
check for a pending query cancel or session termination request, and
call it in a couple of strategic spots where we can make the regex code
exit with an error indicator.
If we ever actually split out the regex code as a standalone library,
some additional work will be needed to let the cancel callback function
be specified externally to the library. But that's straightforward
(certainly so by comparison to putting the locale-dependent character
classification logic on a similar arms-length basis), and there seems
no need to do it right now.
A bigger issue is that there may be more places than these two where
we need to check for cancels. We can always add more checks later,
now that the infrastructure is in place.
Since there are known examples of not-terribly-long regexes that can
lock up a backend for a long time, back-patch to all supported branches.
I have hopes of fixing the known performance problems later, but adding
query cancel ability seems like a good idea even if they were all fixed.
Diffstat (limited to 'src/include/regex/regex.h')
-rw-r--r-- | src/include/regex/regex.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/regex/regex.h b/src/include/regex/regex.h index 3e87dff17b2..2c7fa4df46f 100644 --- a/src/include/regex/regex.h +++ b/src/include/regex/regex.h @@ -154,6 +154,7 @@ typedef struct #define REG_BADOPT 18 /* invalid embedded option */ #define REG_ETOOBIG 19 /* nfa has too many states */ #define REG_ECOLORS 20 /* too many colors */ +#define REG_CANCEL 21 /* operation cancelled */ /* two specials for debugging and testing */ #define REG_ATOI 101 /* convert error-code name to number */ #define REG_ITOA 102 /* convert error-code number to name */ |