|
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/builtins.h"
|
36 | 37 | #include "utils/guc.h"
|
@@ -183,6 +184,15 @@ RE_compile_and_cache(text *text_re, int cflags)
|
183 | 184 | if (regcomp_result != REG_OKAY)
|
184 | 185 | {
|
185 | 186 | /* re didn't compile (no need for pg_regfree, if so) */
|
| 187 | + |
| 188 | + /* |
| 189 | + * Here and in other places in this file, do CHECK_FOR_INTERRUPTS |
| 190 | + * before reporting a regex error. This is so that if the regex |
| 191 | + * library aborts and returns REG_CANCEL, we don't print an error |
| 192 | + * message that implies the regex was invalid. |
| 193 | + */ |
| 194 | + CHECK_FOR_INTERRUPTS(); |
| 195 | + |
186 | 196 | pg_regerror(regcomp_result, &re_temp.cre_re, errMsg, sizeof(errMsg));
|
187 | 197 | ereport(ERROR,
|
188 | 198 | (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
|
@@ -262,6 +272,7 @@ RE_wchar_execute(regex_t *re, pg_wchar *data, int data_len,
|
262 | 272 | if (regexec_result != REG_OKAY && regexec_result != REG_NOMATCH)
|
263 | 273 | {
|
264 | 274 | /* re failed??? */
|
| 275 | + CHECK_FOR_INTERRUPTS(); |
265 | 276 | pg_regerror(regexec_result, re, errMsg, sizeof(errMsg));
|
266 | 277 | ereport(ERROR,
|
267 | 278 | (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
|
@@ -1194,6 +1205,7 @@ regexp_fixed_prefix(text *text_re, bool case_insensitive,
|
1194 | 1205 |
|
1195 | 1206 | default:
|
1196 | 1207 | /* re failed??? */
|
| 1208 | + CHECK_FOR_INTERRUPTS(); |
1197 | 1209 | pg_regerror(re_result, re, errMsg, sizeof(errMsg));
|
1198 | 1210 | ereport(ERROR,
|
1199 | 1211 | (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
|
|
0 commit comments