1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

Update tsearch regex memory management.

Now that our regex engine uses palloc(), it's not necessary to set up a
special memory context callback to free compiled regexes.  The regex has
no resources other than the memory that is already going to be freed in
bulk.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA%2BhUKGK3PGKwcKqzoosamn36YW-fsuTdOPPF1i_rtEO%3DnEYKSg%40mail.gmail.com
This commit is contained in:
Thomas Munro
2023-04-08 21:54:45 +12:00
parent bea3d7e383
commit 4f51429dd7
2 changed files with 13 additions and 39 deletions

View File

@ -81,17 +81,6 @@ typedef struct spell_struct
#define SPELLHDRSZ (offsetof(SPELL, word))
/*
* If an affix uses a regex, we have to store that separately in a struct
* that won't move around when arrays of affixes are enlarged or sorted.
* This is so that it can be found to be cleaned up at context destruction.
*/
typedef struct aff_regex_struct
{
regex_t regex;
MemoryContextCallback mcallback;
} aff_regex_struct;
/*
* Represents an entry in an affix list.
*/
@ -108,7 +97,12 @@ typedef struct aff_struct
char *repl;
union
{
aff_regex_struct *pregex;
/*
* Arrays of AFFIX are moved and sorted. We'll use a pointer to
* regex_t to keep this struct small, and avoid assuming that regex_t
* is movable.
*/
regex_t *pregex;
Regis regis;
} reg;
} AFFIX;