Calling lo_open within user defined C function

From: Vincent Roberts <vroberts(at)emanon(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Calling lo_open within user defined C function
Date: 2001-06-11 20:24:22
Message-ID: 3B2528F6.5D1D474@emanon.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I am trying to create a user defined C function that will
be called within PL/pgSQL

Namely, I need a function that will create a new Large Object and copy
the data
of an existing Large Object into the new Large Object.

This is the way the function would be registered

CREATE FUNCTION copyoid(oid) RETURNS oid AS '/copyoid.so' LANGUAGE
'C';

I notice that the lo_create and lo_open functions require a postgres
connection (PGConn)

Oid lo_creat(PGconn *conn, int mode)
int lo_open(PGconn *conn, Oid lobjId, int mode)

Since the function I wish to create will be executed within the backend,

how do I handle
the conn (PGconn) variable?

I realize I will need to open the original large object , create a new
large object and then
read the old and write the new until done, and then close both.

Every example I can find opens a connection and then uses the new
connection for these functions.

Is this required or can I use the "current" connection ?

Thanks

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-06-11 20:42:14 Re: OID Wrap
Previous Message Darren Johnson 2001-06-11 19:46:44 Postgres Replication