SPI question (or not): trying to read from Large Objects from within a function - Mailing list pgsql-general

From David Helgason
Subject SPI question (or not): trying to read from Large Objects from within a function
Date
Msg-id 8107C1AD-40BF-11D8-BF3E-000A9566DA8A@uti.is
Whole thread Raw
Responses Re: SPI question (or not): trying to read from Large Objects from within a function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
What:
I'm having trouble finding out how to find the current PGconn
connection inside a C function. Looking through the documentation
didn't give this up. Could anyone suggest where to look? I didn't even
see anything similar to this in the SPI_* documentation. Perhaps I am
totally mislead here?

Why:
I am writing an wrapper around librsync, allowing differential updating
of large amounts of data (librsync wraps the clever algorithm of
rsync).

The first function I'm wrapping is the one which generates a signature
(a hash of each block of data, with some specified block-size) from a
LO. Its signature would be:

    create function rsync_signature(oid /* of an Large Object */) returns
bytea

But I can't figure out how to get the current PGconn to be able to run
the lo_* functions.


On another not, would it be possible to avoid using Large Objects, and
use TOAST columns instead? Ie. is it possible to quickly read/write
partial toast columns (I know it's not possible for clients, but on the
server side?).


There may be more questions later, but I'll try to pay back by
submitting the final implementation to contrib/ (if anyone is
interested). It'll allow for really fast incremental updates of a
columns, which I'll use to make storing of huge blobs less of a pain
(although it depends on the client also speaking rsync-ese, but that'll
be included with the package).


Regards,

d.
--
David Helgason
Over the Edge Entertainments




pgsql-general by date:

Previous
From: "Roderick A. Anderson"
Date:
Subject: Re: DBs and Schemas
Next
From: Paul Mc Gee
Date:
Subject: Loading a dumped databse from cd