mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-15 10:57:02 +08:00
This replaces the former global variable PLy_curr_procedure, and provides a place to stash per-call-level information. In particular we create a per-call-level scratch memory context. For the moment, the scratch context is just used to avoid leaking memory from datatype output function calls in PLyDict_FromTuple. There probably will be more use-cases in future. Although this is a fix for a pre-existing memory leakage bug, it seems sufficiently invasive to not want to back-patch; it feels better as part of the major rearrangement of plpython code that we've already done as part of 9.2. Jan Urbański
29 lines
788 B
C
29 lines
788 B
C
/*
|
|
* src/pl/plpython/plpy_main.h
|
|
*/
|
|
|
|
#ifndef PLPY_MAIN_H
|
|
#define PLPY_MAIN_H
|
|
|
|
#include "plpy_procedure.h"
|
|
|
|
/* the interpreter's globals dict */
|
|
extern PyObject *PLy_interp_globals;
|
|
|
|
/*
|
|
* A stack of PL/Python execution contexts. Each time user-defined Python code
|
|
* is called, an execution context is created and put on the stack. After the
|
|
* Python code returns, the context is destroyed.
|
|
*/
|
|
typedef struct PLyExecutionContext
|
|
{
|
|
PLyProcedure *curr_proc; /* the currently executing procedure */
|
|
MemoryContext scratch_ctx; /* a context for things like type I/O */
|
|
struct PLyExecutionContext *next; /* previous stack level */
|
|
} PLyExecutionContext;
|
|
|
|
/* Get the current execution context */
|
|
extern PLyExecutionContext *PLy_current_execution_context(void);
|
|
|
|
#endif /* PLPY_MAIN_H */
|