From: | Martin Kleppmann <martin(at)kleppmann(dot)com> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Access to receive/output functions from libpq client |
Date: | 2014-12-29 20:36:46 |
Message-ID: | D7E62929-32EC-4664-BBB2-7EE3595379A1@kleppmann.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Hi,
I'm trying to export the contents of a PG database to an external format, using 9.4's exciting new logical decoding facility. I am currently writing an 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 set up a transaction with the replication slot's exported snapshot, and doing 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 datum, and use PG's functions to decode the datum -- for example, it can use DatumGetNumeric() to get a Numeric struct, and it can use OidOutputFunctionCall() 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 format and use the same conversion functions as in the output plugin. This would 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 representation 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 symbols _OidOutputFunctionCall, _getTypeOutputInfo and _pg_detoast_datum, for example.
Is there a library that I could link into the libpq client to provide the functions for decoding binary datatypes? Or is there some other recommended way of decoding binary datums in a client?
Thanks,
Martin
From | Date | Subject | |
---|---|---|---|
Next Message | Bill Clay | 2015-03-02 22:31:39 | libpq connect keepalive* parms: no effect!? |
Previous Message | Michael Wallner | 2014-10-21 12:11:05 | New PHP binding: pecl/pq |