HeapTuple to JSON -- composite_to_json()?

From: Jason Dusek <jason(dot)dusek(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: HeapTuple to JSON -- composite_to_json()?
Date: 2016-01-21 22:41:32
Message-ID: CAO3NbwPEVOTE-X9LdoipJqfpMOqefdtC8s1_8j8xioiQfnShpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi All,

I am working on a logical decoder and would like to convert a heap tuple to
JSON (a HeapTuple obtained from ReorderBufferChange). It is the moral
equivalent of tuple_to_stringinfo in test_decode.c:

http://doxygen.postgresql.org/test__decoding_8c.html#a3986a57a0308de0150ebd45f7734d464

It seems like the easiest and best thing to do is to rely on Postgres’s
native JSON serialization. A HeapTuple is not a Datum; but reading
heaptuple.c they seem to have a close relationship. Do arrays of Datum
become HeapTuple? Is a HeapTuple basically Datum sans type information?
What is the best way to convert a HeapTuple to a Datum?

Best Regards,

Jason Dusek

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jason Dusek 2016-01-21 23:46:11 Re: HeapTuple to JSON -- composite_to_json()?
Previous Message Yury Zhuravlev 2016-01-21 22:16:28 Re: Building PostgreSQL 9.6devel sources with Microsoft Visual C++ 2015?