From: Thomas Munro <tmunro@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Redesign interrupt/cancel API for regex engine.
Date: Sat, 08 Apr 2023 10:18:13 +0000
Message-ID: <E1pl5e7-0021l1-R5@gemulon.postgresql.org> (raw)
Redesign interrupt/cancel API for regex engine.
Previously, a PostgreSQL-specific callback checked by the regex engine
had a way to trigger a special error code REG_CANCEL if it detected that
the next call to CHECK_FOR_INTERRUPTS() would certainly throw via
ereport().
A later proposed bugfix aims to move some complex logic out of signal
handlers, so that it won't run until the next CHECK_FOR_INTERRUPTS(),
which makes the above design impossible unless we split
CHECK_FOR_INTERRUPTS() into two phases, one to run logic and another to
ereport(). We may develop such a system in the future, but for the
regex code it is no longer necessary.
An earlier commit moved regex memory management over to our
MemoryContext system. Given that the purpose of the two-phase interrupt
checking was to free memory before throwing, something we don't need to
worry about anymore, it seems simpler to inject CHECK_FOR_INTERRUPTS()
directly into cancelation points, and just let it throw.
Since the plan is to keep PostgreSQL-specific concerns separate from the
main regex engine code (with a view to bein able to stay in sync with
other projects), do this with a new macro INTERRUPT(), customizable in
regcustom.h and defaulting to nothing.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA%2BhUKGK3PGKwcKqzoosamn36YW-fsuTdOPPF1i_rtEO%3DnEYKSg%40mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/db4f21e4a34b1d5a3f7123e28e77f575d1a971ea
Modified Files
--------------
src/backend/regex/regc_locale.c | 6 +---
src/backend/regex/regc_nfa.c | 48 ++++++--------------------------
src/backend/regex/regcomp.c | 18 ------------
src/backend/regex/rege_dfa.c | 6 +---
src/backend/regex/regexec.c | 3 +-
src/backend/utils/adt/jsonpath_gram.y | 2 --
src/backend/utils/adt/regexp.c | 11 --------
src/backend/utils/adt/varlena.c | 1 -
src/include/regex/regcustom.h | 3 +-
src/include/regex/regerrs.h | 4 ---
src/include/regex/regex.h | 1 -
src/include/regex/regguts.h | 9 +++---
src/test/modules/test_regex/test_regex.c | 10 -------
13 files changed, 18 insertions(+), 104 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: tmunro@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Redesign interrupt/cancel API for regex engine.
In-Reply-To: <E1pl5e7-0021l1-R5@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox