Обсуждение: Safe to apply HeapTupleHeaderGetDatum to a tuple from syscache?

Поиск
Список
Период
Сортировка

Safe to apply HeapTupleHeaderGetDatum to a tuple from syscache?

От
Chapman Flack
Дата:
I'm still learning, and looking at the HeapTupleHeaderGetDatum comment
that says
 This must *not* get applied to an on-disk tuple; the tuple should be freshly made by heap_form_tuple or some wrapper
routinefor it (such as BuildTupleFromCStrings).  Be sure also that the tupledesc used to build the tuple has a properly
"blessed"rowtype.
 

... and I'm not 100% confident I know where a pg_proc or pg_language
tuple just retrieved from the syscache fits in that picture.

It would be convenient if safe, because I'd like to take a bit of
brittle C code in PL/Java that works out what to do from the proc
tuple, and reimplement that part in Java where it can be expressed
more concisely, and PL/Java already has infrastructure to take a
Datum representing a HeapTupleHeader and present it as an introspectable
readonly Java type. So if I can safely pass a pg_proc tuple from the cache
to HeapTupleGetDatum, then I'm only a couple lines of code away from
passing it into a Java method to do the remaining work there.

Or do I need to do something harder than that?

Thanks,
-Chap