lo_copy routine

Lists: pgsql-hackers
From: "Eric C(dot) Newton" <ecn(at)metaslash(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [Fwd: AW: Postgres Replication]
Date: 2001-06-12 14:46:07
Message-ID: 20010612104607.A26179@ecn
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> > I would be very interested in hearing about your experiences with
> > this...

Well, Eric thinks it works just spiffy. 8-)

Recall is written in C++, and is meant to be extensible. It was
extended for perl and the DBI layer.

Note that this hack for perl is not perfect, especially in the area of
transactions and locks (which weren't a big deal for MySQL). Recall
supports active repliation with strict consistency. The perl
interface is cool hack, but Recall can do even more.

I would love it if you folks could take a look. I'm working on an
CORBA version right now. Any feedback would be very helpful.

Besides... it don't cost nothin'

-Eric


From: Vince Roberts <vroberts(at)emanon(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: lo_copy routine
Date: 2001-06-12 16:33:51
Message-ID: Pine.BSF.4.21.0106121228310.94611-100000@unix1.emanon.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Here is a basic lo_copy routine

It copies a large object from an existing large object

PG_FUNCTION_INFO_V1(lo_copy);

Datum
lo_copy(PG_FUNCTION_ARGS)
{
Oid oldlobjId = PG_GETARG_OID(0);
LargeObjectDesc *lobj,*oldlobj;
int readbytes,
writebytes;
char buf[BUFSIZE];
Oid lobjOid;

oldlobj = inv_open(oldlobjId, INV_READ);
if (lobj == NULL)
elog(ERROR, "lo_copy: can't open inv object %u", oldlobjId);

lobj = inv_create(INV_READ | INV_WRITE);
if (lobj == NULL)
elog(ERROR, "lo_copy: can't create inv object");
lobjOid = lobj->id;

while ((readbytes = inv_read(oldlobj, buf, BUFSIZE)) > 0)
{
writebytes = inv_write(lobj, buf, readbytes);
if (writebytes != readbytes)
elog(ERROR, "lo_copy: error while copying");
}

inv_close(oldlobj);
inv_close(lobj);

PG_RETURN_OID(lobjOid);
}