Chapman Flack wrote: > I am tempted to apply HeapTupleGetDatum to a tuple retrieved from > the syscache (as I already have code for processing a tuple presented > as a Datum). > > But I see a comment on HeapTupleHeaderGetDatum: "This must *not* get > applied to an on-disk tuple; the tuple should be freshly made by > heap_form_tuple or some wrapper ..."
I suppose you could create a copy of the tuple (SysCacheSearchCopy) and use that for HeapTupleGetDatum. The problem with the syscache tuple is that it can go away as soon as you do the ReleaseSysCache -- it lives in shared_buffers memory, so when it's released the buffer might get evicted. heap_form_tuple returns a newly palloc'd tuple, which is what you want. > ... and here I confess I'm unsure whether a tuple retrieved from > the syscache is more like an on-disk one, or a freshly-made one, > for purposes of the warning in that comment. A "syscache tuple" is definitely an on-disk tuple. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers