File tree Expand file tree Collapse file tree 5 files changed +61
-5
lines changed
ydb/library/yql/parser/pg_wrapper
postgresql/src/backend/utils/adt Expand file tree Collapse file tree 5 files changed +61
-5
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ TArenaMemoryContext::TArenaMemoryContext() {
118
118
}
119
119
120
120
TArenaMemoryContext::~TArenaMemoryContext () {
121
+ MemoryContextDeleteChildren (MyContext);
121
122
Release ();
122
123
free (MyContext);
123
124
}
Original file line number Diff line number Diff line change @@ -4948,7 +4948,10 @@ void* PgInitializeMainContext() {
4948
4948
}
4949
4949
4950
4950
void PgDestroyMainContext (void * ctx) {
4951
- delete (TMainContext*)ctx;
4951
+ auto typedCtx = (TMainContext*)ctx;
4952
+ MemoryContextDeleteChildren ((MemoryContext)&typedCtx->Data );
4953
+ MemoryContextDeleteChildren ((MemoryContext)&typedCtx->ErrorData );
4954
+ delete typedCtx;
4952
4955
}
4953
4956
4954
4957
void PgAcquireThreadContext (void * ctx) {
Original file line number Diff line number Diff line change @@ -114,10 +114,9 @@ static __thread int num_res = 0; /* # of cached re's */
114
114
static __thread cached_re_str re_array [MAX_CACHED_RES ]; /* cached re's */
115
115
116
116
void RE_cleanup_cache (void ) {
117
- int i ;
118
- for (i = 0 ; i < num_res ; ++ i ) {
119
- pg_regfree (& re_array [i ].cre_re );
120
- free (re_array [i ].cre_pat );
117
+ if (RegexpCacheMemoryContext ) {
118
+ MemoryContextDelete (RegexpCacheMemoryContext );
119
+ RegexpCacheMemoryContext = NULL ;
121
120
}
122
121
123
122
num_res = 0 ;
Original file line number Diff line number Diff line change
1
+ #include " ../pg_compat.h"
2
+
3
+ extern " C" {
4
+ #include < ydb/library/yql/parser/pg_wrapper/postgresql/src/include/postgres.h>
5
+ #include < ydb/library/yql/parser/pg_wrapper/postgresql/src/include/utils/memutils.h>
6
+ }
7
+
8
+ #include " arena_ctx.h"
9
+
10
+ #include < ydb/library/yql/minikql/mkql_alloc.h>
11
+
12
+ #include < library/cpp/testing/unittest/registar.h>
13
+
14
+ namespace NYql {
15
+
16
+ Y_UNIT_TEST_SUITE (TPGMemoryTests) {
17
+ Y_UNIT_TEST (TestArenaContextBasic) {
18
+ TArenaMemoryContext arena;
19
+ auto p1 = palloc (123 );
20
+ auto p2 = palloc (456 );
21
+ Y_UNUSED (p2);
22
+ pfree (p1);
23
+ }
24
+
25
+ Y_UNIT_TEST (TestMkqlContextBasic) {
26
+ NKikimr::NMiniKQL::TScopedAlloc alloc (__LOCATION__);
27
+ auto p1 = palloc (123 );
28
+ auto p2 = palloc (456 );
29
+ Y_UNUSED (p2);
30
+ pfree (p1);
31
+ }
32
+
33
+ Y_UNIT_TEST (TestArenaContextCleanupChild) {
34
+ TArenaMemoryContext arena;
35
+ auto tmpContext = AllocSetContextCreate (CurrentMemoryContext, " Tmp" , ALLOCSET_SMALL_SIZES);
36
+ auto oldcontext = MemoryContextSwitchTo (tmpContext);
37
+ auto p1 = palloc (123 );
38
+ Y_UNUSED (p1);
39
+ MemoryContextSwitchTo (oldcontext);
40
+ }
41
+
42
+ Y_UNIT_TEST (TestMkqlContextCleanupChild) {
43
+ NKikimr::NMiniKQL::TScopedAlloc alloc (__LOCATION__);
44
+ auto tmpContext = AllocSetContextCreate (CurrentMemoryContext, " Tmp" , ALLOCSET_SMALL_SIZES);
45
+ auto oldcontext = MemoryContextSwitchTo (tmpContext);
46
+ auto p1 = palloc (123 );
47
+ Y_UNUSED (p1);
48
+ MemoryContextSwitchTo (oldcontext);
49
+ }
50
+ }
51
+
52
+ }
Original file line number Diff line number Diff line change 9
9
arrow_ut.cpp
10
10
codegen_ut.cpp
11
11
error_ut.cpp
12
+ memory_ut.cpp
12
13
parser_ut.cpp
13
14
sort_ut.cpp
14
15
type_cache_ut.cpp
You can’t perform that action at this time.
0 commit comments