|
31 | 31 |
|
32 | 32 | #include "catalog/pg_type.h" |
33 | 33 | #include "funcapi.h" |
| 34 | +#include "miscadmin.h" |
34 | 35 | #include "regex/regex.h" |
35 | 36 | #include "utils/array.h" |
36 | 37 | #include "utils/builtins.h" |
@@ -188,6 +189,15 @@ RE_compile_and_cache(text *text_re, int cflags, Oid collation) |
188 | 189 | if (regcomp_result != REG_OKAY) |
189 | 190 | { |
190 | 191 | /* re didn't compile (no need for pg_regfree, if so) */ |
| 192 | + |
| 193 | + /* |
| 194 | + * Here and in other places in this file, do CHECK_FOR_INTERRUPTS |
| 195 | + * before reporting a regex error. This is so that if the regex |
| 196 | + * library aborts and returns REG_CANCEL, we don't print an error |
| 197 | + * message that implies the regex was invalid. |
| 198 | + */ |
| 199 | + CHECK_FOR_INTERRUPTS(); |
| 200 | + |
191 | 201 | pg_regerror(regcomp_result, &re_temp.cre_re, errMsg, sizeof(errMsg)); |
192 | 202 | ereport(ERROR, |
193 | 203 | (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION), |
@@ -268,6 +278,7 @@ RE_wchar_execute(regex_t *re, pg_wchar *data, int data_len, |
268 | 278 | if (regexec_result != REG_OKAY && regexec_result != REG_NOMATCH) |
269 | 279 | { |
270 | 280 | /* re failed??? */ |
| 281 | + CHECK_FOR_INTERRUPTS(); |
271 | 282 | pg_regerror(regexec_result, re, errMsg, sizeof(errMsg)); |
272 | 283 | ereport(ERROR, |
273 | 284 | (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION), |
@@ -1216,6 +1227,7 @@ regexp_fixed_prefix(text *text_re, bool case_insensitive, Oid collation, |
1216 | 1227 |
|
1217 | 1228 | default: |
1218 | 1229 | /* re failed??? */ |
| 1230 | + CHECK_FOR_INTERRUPTS(); |
1219 | 1231 | pg_regerror(re_result, re, errMsg, sizeof(errMsg)); |
1220 | 1232 | ereport(ERROR, |
1221 | 1233 | (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION), |
|
0 commit comments