Received: from sirius.fccc.edu (sirius.fccc.edu [131.249.2.106]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5BJX8E59488 for ; Mon, 11 Jun 2001 15:33:09 -0400 (EDT) (envelope-from V_Roberts@fccc.edu) Received: from fccc.edu (stargate2.fccc.edu [131.249.9.253]) by sirius.fccc.edu with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id MW708B1S; Mon, 11 Jun 2001 15:33:04 -0400 Message-ID: <3B251D32.7B27CC94@fccc.edu> Date: Mon, 11 Jun 2001 15:34:10 -0400 From: Vincent Roberts X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.16-3 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: Calling lo_open within user defined C function Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200106/48 X-Sequence-Number: 1711 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 it necessary to create/"open" a connection for code that executes within the backend ? ....... Thanks