Re: Missing CFI in iterate_word_similarity()
Daniel Gustafsson <daniel@yesql.se>
From: Daniel Gustafsson <daniel@yesql.se>
To: Robins Tharakan <tharakan@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2022-09-02T12:26:50Z
Lists: pgsql-hackers
Attachments
- v2-0002-Update-out-of-date-comments-in-pg_trgm.patch (application/octet-stream) patch v2-0002
- v2-0001-Check-for-interrupts-in-pg_trgm-word-similarity.patch (application/octet-stream) patch v2-0001
> On 2 Aug 2022, at 04:41, Robins Tharakan <tharakan@gmail.com> wrote:
> For long strings, iterate_word_similarity() can run into long-running
> tight-loops without honouring interrupts or statement_timeouts.
> Adding CHECK_FOR_INTERRUPTS() ensures that such queries respond to
> statement_timeout & Ctrl-C signals. With the patch applied, the
> above query will interrupt more quickly:
Makes sense. While this might be a bit of a theoretical issue given the
lengths required, the fix is still sane and any such query should honor
statement timeouts (especially in a trusted extension).
> Please find the patch attached. The patch does not show any performance
> regressions when run against the above use-case.
I wasn't able to find one either.
+ CHECK_FOR_INTERRUPTS();
+
/* Get index of next trigram */
int trgindex = trg2indexes[i];
Placing code before declarations will generate a compiler warning, so the check
must go after trgindex is declared. I've fixed that in the attached to get the
cfbot green. Marking this ready for committer in the meantime.
Looking at this I also noticed that commit be8a7a68662 changed the check_only
param to instead use a flag value but didn't update all comments. 0002 fixes
that while in there.
--
Daniel Gustafsson https://vmware.com/
Commits
-
Update out of date comments in pg_trgm
- 6dc0738812c3 16.0 landed
-
Check for interrupts in pg_trgm word similarity
- ae4fc52ae247 16.0 landed
-
Add strict_word_similarity to pg_trgm module
- be8a7a686627 11.0 cited