From: Martin Kleppmann <martin@kleppmann.com>
To: pgsql-interfaces@postgresql.org
Subject: Access to receive/output functions from libpq client
Date: Mon, 29 Dec 2014 21:36:46 +0100
Message-ID: <D7E62929-32EC-4664-BBB2-7EE3595379A1@kleppmann.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
--
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: martin@kleppmann.com
Subject: Re: Access to receive/output functions from libpq client
In-Reply-To: <D7E62929-32EC-4664-BBB2-7EE3595379A1@kleppmann.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox