Safe to apply HeapTupleHeaderGetDatum to a tuple from syscache?

From: Chapman Flack <chap(at)anastigmatix(dot)net>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Safe to apply HeapTupleHeaderGetDatum to a tuple from syscache?
Date: 2016-04-14 01:30:02
Message-ID: 570EF29A.3050608@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 routine for 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2016-04-14 01:42:09 Re: SET ROLE and reserved roles
Previous Message Robert Haas 2016-04-14 01:20:07 Re: Odd system-column handling in postgres_fdw join pushdown patch