aboutsummaryrefslogtreecommitdiff
path: root/src/backend/regex
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2023-04-08 21:52:35 +1200
committerThomas Munro <tmunro@postgresql.org>2023-04-08 22:08:41 +1200
commitbea3d7e3831fa6a1395eadbad7d97cebc7aa8aee (patch)
tree9445cbc6015b1591ff310d813acfe7b1ef848ce4 /src/backend/regex
parentfcd77d53217b4c4049d176072a1763d6e11ca478 (diff)
downloadpostgresql-bea3d7e3831fa6a1395eadbad7d97cebc7aa8aee.tar.gz
postgresql-bea3d7e3831fa6a1395eadbad7d97cebc7aa8aee.zip
Use MemoryContext API for regex memory management.
Previously, regex_t objects' memory was managed with malloc() and free() directly. Switch to palloc()-based memory management instead. Advantages: * memory used by cached regexes is now visible with MemoryContext observability tools * cleanup can be done automatically in certain failure modes (something that later commits will take advantage of) * cleanup can be done in bulk On the downside, there may be more fragmentation (wasted memory) due to per-regex MemoryContext objects. This is a problem shared with other cached objects in PostgreSQL and can probably be improved with later tuning. Thanks to Noah Misch for suggesting this general approach, which unblocks later work on interrupts. Suggested-by: Noah Misch <noah@leadboat.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CA%2BhUKGK3PGKwcKqzoosamn36YW-fsuTdOPPF1i_rtEO%3DnEYKSg%40mail.gmail.com
Diffstat (limited to 'src/backend/regex')
-rw-r--r--src/backend/regex/regprefix.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/regex/regprefix.c b/src/backend/regex/regprefix.c
index 221f02da63d..c09b2a9778e 100644
--- a/src/backend/regex/regprefix.c
+++ b/src/backend/regex/regprefix.c
@@ -32,7 +32,7 @@ static int findprefix(struct cnfa *cnfa, struct colormap *cm,
* REG_EXACT: all strings satisfying the regex must match the same string
* or a REG_XXX error code
*
- * In the non-failure cases, *string is set to a malloc'd string containing
+ * In the non-failure cases, *string is set to a palloc'd string containing
* the common prefix or exact value, of length *slength (measured in chrs
* not bytes!).
*