diff options
author | vvvv <vvvv@ydb.tech> | 2023-10-12 20:13:46 +0300 |
---|---|---|
committer | vvvv <vvvv@ydb.tech> | 2023-10-12 20:36:53 +0300 |
commit | 3db4565eda76a69121a9a083c43fdb0026857808 (patch) | |
tree | 76e63f0582d72f3ebb17315588e937229f483832 | |
parent | 5a5d809f923d4d66e5e2d91bdf3b329ca2e1b682 (diff) | |
download | ydb-3db4565eda76a69121a9a083c43fdb0026857808.tar.gz |
cleanup PG RE cache
-rw-r--r-- | ydb/library/yql/parser/pg_wrapper/parser.cpp | 2 | ||||
-rw-r--r-- | ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/regexp.c | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/ydb/library/yql/parser/pg_wrapper/parser.cpp b/ydb/library/yql/parser/pg_wrapper/parser.cpp index fc74e000ec7..76a0d86a2cc 100644 --- a/ydb/library/yql/parser/pg_wrapper/parser.cpp +++ b/ydb/library/yql/parser/pg_wrapper/parser.cpp @@ -60,6 +60,7 @@ extern __thread Latch LocalLatchData; extern void destroy_timezone_hashtable(); extern void destroy_typecache_hashtable(); extern void free_current_locale_conv(); +extern void RE_cleanup_cache(); const char *progname; #define STDERR_BUFFER_LEN 4096 @@ -228,6 +229,7 @@ extern "C" void setup_pg_thread_cleanup() { ~TThreadCleanup() { destroy_timezone_hashtable(); destroy_typecache_hashtable(); + RE_cleanup_cache(); free_current_locale_conv(); ResourceOwnerDelete(CurrentResourceOwner); diff --git a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/regexp.c b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/regexp.c index 9ad1337622c..30b55ee9249 100644 --- a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/regexp.c +++ b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/regexp.c @@ -109,6 +109,15 @@ typedef struct cached_re_str static __thread int num_res = 0; /* # of cached re's */ static __thread cached_re_str re_array[MAX_CACHED_RES]; /* cached re's */ +void RE_cleanup_cache(void) { + int i; + for (i = 0; i < num_res; ++i) { + pg_regfree(&re_array[i].cre_re); + free(re_array[i].cre_pat); + } + + num_res = 0; +} /* Local functions */ static regexp_matches_ctx *setup_regexp_matches(text *orig_str, text *pattern, |