diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c index 13b922d4375..af97b5b4213 100644 --- a/src/backend/tsearch/wparser_def.c +++ b/src/backend/tsearch/wparser_def.c @@ -18,6 +18,7 @@ #include "catalog/pg_collation.h" #include "commands/defrem.h" +#include "miscadmin.h" #include "tsearch/ts_locale.h" #include "tsearch/ts_public.h" #include "tsearch/ts_type.h" @@ -639,6 +640,12 @@ p_ishost(TParser *prs) tmpprs->wanthost = true; + /* + * Check stack depth before recursing. (Since TParserGet() doesn't + * normally recurse, we put the cost of checking here not there.) + */ + check_stack_depth(); + if (TParserGet(tmpprs) && tmpprs->type == HOST) { prs->state->posbyte += tmpprs->lenbytetoken; @@ -662,6 +669,12 @@ p_isURLPath(TParser *prs) tmpprs->state = newTParserPosition(tmpprs->state); tmpprs->state->state = TPS_InURLPathFirst; + /* + * Check stack depth before recursing. (Since TParserGet() doesn't + * normally recurse, we put the cost of checking here not there.) + */ + check_stack_depth(); + if (TParserGet(tmpprs) && tmpprs->type == URLPATH) { prs->state->posbyte += tmpprs->lenbytetoken; @@ -1705,6 +1718,8 @@ TParserGet(TParser *prs) { const TParserStateActionItem *item = NULL; + CHECK_FOR_INTERRUPTS(); + Assert(prs->state); if (prs->state->posbyte >= prs->lenstr)