MemoryContext and NodeTags

Поиск
Список
Период
Сортировка
От Thomas Hallgren
Тема MemoryContext and NodeTags
Дата
Msg-id 4353A7D3.7000509@home.se
обсуждение исходный текст
Ответы Re: MemoryContext and NodeTags  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
I'm rewriting parts of PL/Java to be more secure. One of the areas where 
I'd like to improve things concerns ownership of allocated structures. 
Many structures, such as TupleDesc, HeapTuple, ErrorData, etc. can be 
copied into another MemoryContext for safe keeping. PL/Java uses this 
when creating Java wrappers for such objects.

Prior to the rewrite, I maintained mappings from pointers to Java 
wrappers in a hash table. Now, I instead have a special MemoryContext 
that can hold a reference to the Java wrapper in the chunk header. Both 
simpler and more efficient (I also have wet dreams about a future 
MemoryContext that allocates shared memory). But, at present, and 
because of this macro:
 /*  * MemoryContextIsValid  *        True iff memory context is valid.  *  * Add new context types to the set accepted
bythis macro.  */ #define MemoryContextIsValid(context) \     ((context) != NULL && \      (IsA((context),
AllocSetContext)))

I have to cheat and claim that this MemoryContext has the NodeType of 
T_AllocSetContext.

I have a proposal:
The NodeTag T_MemoryContext has the value of 600 and the next occupied 
entry is T_Value which is 650.
- Reserve half of that range for PostgreSQL specific contexts (today you 
only use one), and the other half for custom contexts.
- Change the above macro to consider values between 601 and 649 as valid 
tags. The likelihood of an invalid context hitting that range is second 
to none.
- Accept patches to nodes/nodes.h for new custom tags (properly 
motivated of course).

What do you think? Would a patch that implements this proposal and adds 
a T_PLJavaContext NodeTag be accepted?

Regards,
Thomas Hallgren




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: PostgreSQL roadmap for 8.2 and beyond.
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Possible issue with win32 installer(8.1beta 3)...