Access to receive/output functions from libpq client
Martin Kleppmann <[email protected]> Mon, 29 Dec 2014 21:36:46 +0100
| Newsgroups | gmane.comp.db.postgresql.interfaces |
|---|---|
| Message-ID | <[email protected]> |
Hi, I'm trying to export the contents of a PG database to an external format, u= sing 9.4's exciting new logical decoding facility. I am currently writing a= n output plugin for logical replication (using PGXS). To capture a snapshot= of the data before the replication slot was created, I am using libpq to s= et up a transaction with the replication slot's exported snapshot, and doin= g a "select * from table". In this context, my question is about decoding datatypes. An output plugin = sees the changed tuples in binary format, it can find the the OID of a datu= m, and use PG's functions to decode the datum -- for example, it can use Da= tumGetNumeric() to get a Numeric struct, and it can use OidOutputFunctionCa= ll() to get the text representation of a datum. That's very nice. In the external client, when doing PQsendQueryParams() I can choose between= binary and text result format. I'd like to be able to request the binary f= ormat and use the same conversion functions as in the output plugin. This w= ould allow the data to be exported in a structured representation, and only= falling back to using a datatype's output function to get a string represe= ntation if we don't know what to do with a particular OID. My problem is that the libpq client doesn't have access to the same library= functions as the output plugin. The linker complains about undefined symbo= ls _OidOutputFunctionCall, _getTypeOutputInfo and _pg_detoast_datum, for ex= ample. Is there a library that I could link into the libpq client to provide the f= unctions for decoding binary datatypes? Or is there some other recommended = way of decoding binary datums in a client? Thanks, Martin --=20 Sent via pgsql-interfaces mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-interfaces