Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit aba3abe

Browse files
danielgustafssonpull[bot]
authored andcommitted
Check for interrupts in pg_trgm word similarity
Calculating similarity between large strings can be timesconsuming and overrun configured statement timeouts. Check for interrupts in the main loop to ensure query cancellation can be performed. Author: Robins Tharakan <tharakan@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAEP4nAxvmfc_XWTz73bqXRhgjONi=1HaX4_NhsopA3L6UvnN1g@mail.gmail.com
1 parent 024e00a commit aba3abe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

contrib/pg_trgm/trgm_op.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "catalog/pg_type.h"
99
#include "lib/qunique.h"
10+
#include "miscadmin.h"
1011
#include "trgm.h"
1112
#include "tsearch/ts_locale.h"
1213
#include "utils/lsyscache.h"
@@ -492,8 +493,12 @@ iterate_word_similarity(int *trg2indexes,
492493

493494
for (i = 0; i < len2; i++)
494495
{
496+
int trgindex;
497+
498+
CHECK_FOR_INTERRUPTS();
499+
495500
/* Get index of next trigram */
496-
int trgindex = trg2indexes[i];
501+
trgindex = trg2indexes[i];
497502

498503
/* Update last position of this trigram */
499504
if (lower >= 0 || found[trgindex])

0 commit comments

Comments
 (0)