Skip to content

Commit 94c9152

Browse files
committed
Back-patch addition of stack overflow and interrupt checks for lquery.
Experimentation shows that it's not hard at all to drive the old implementation of "ltree ~ lquery" match to stack overflow, so throw in a check_stack_depth() call, as I just did in HEAD. I wasn't able to make it take a long time, because all the pathological cases I tried hit stack overflow first; but I bet there are some others that do take a long time, so add CHECK_FOR_INTERRUPTS() too. Discussion: https://postgr.es/m/CAP_rww=waX2Oo6q+MbMSiZ9ktdj6eaJj0cQzNu=Ry2cCDij5fw@mail.gmail.com
1 parent 3ec8576 commit 94c9152

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

contrib/ltree/lquery_op.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <ctype.h>
99

1010
#include "catalog/pg_collation.h"
11+
#include "miscadmin.h"
1112
#include "utils/formatting.h"
1213
#include "ltree.h"
1314

@@ -165,6 +166,12 @@ checkCond(lquery_level *curq, int query_numlevel, ltree_level *curt, int tree_nu
165166
lquery_level *prevq = NULL;
166167
ltree_level *prevt = NULL;
167168

169+
/* Since this function recurses, it could be driven to stack overflow */
170+
check_stack_depth();
171+
172+
/* Pathological patterns could take awhile, too */
173+
CHECK_FOR_INTERRUPTS();
174+
168175
if (SomeStack.muse)
169176
{
170177
high_pos = SomeStack.high_pos;

0 commit comments

Comments
 (0)