Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4b7d637

Browse files
author
Nikita Glukhov
committed
Add global memory context to PL/Python
1 parent ff85306 commit 4b7d637

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/pl/plpython/plpy_main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ PyObject *PLy_interp_globals = NULL;
7373
/* this doesn't need to be global; use PLy_current_execution_context() */
7474
static PLyExecutionContext *PLy_execution_contexts = NULL;
7575

76+
static MemoryContext PLy_memory_context;
7677

7778
void
7879
_PG_init(void)
@@ -464,3 +465,14 @@ PLy_pop_execution_context(void)
464465
MemoryContextDelete(context->scratch_ctx);
465466
pfree(context);
466467
}
468+
469+
MemoryContext
470+
PLy_get_global_memory_context(void)
471+
{
472+
if (!PLy_memory_context)
473+
PLy_memory_context = AllocSetContextCreate(TopMemoryContext,
474+
"PL/Python global context",
475+
ALLOCSET_DEFAULT_SIZES);
476+
477+
return PLy_memory_context;
478+
}

src/pl/plpython/plpy_main.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ extern PLyExecutionContext *PLy_current_execution_context(void);
2828
/* Get the scratch memory context for specified execution context */
2929
extern MemoryContext PLy_get_scratch_context(PLyExecutionContext *context);
3030

31+
/* Get the global memory context */
32+
extern MemoryContext PLy_get_global_memory_context(void);
33+
3134
#endif /* PLPY_MAIN_H */

0 commit comments

Comments
 (0)