Re: lo_copy() - Mailing list pgsql-general

From Nigel J. Andrews
Subject Re: lo_copy()
Date
Msg-id Pine.LNX.4.21.0304011620440.2573-100000@ponder.fairway2k.co.uk
Whole thread Raw
In response to Re: lo_copy()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Tue, 1 Apr 2003, Tom Lane wrote:

> "Nigel J. Andrews" <nandrews@investsystems.co.uk> writes:
> > I wonder if anyone has any comments on this [psuedo] code:
>
> > new loid := SELECT lo_creat(131072 + 262144);
>
> > UPDATE pg_largeobject SET
> >     data = (SELECT data
> >             FROM pg_largeobject
> >             WHERE loid = <source loid> AND pageno = 0)
> >     WHERE loid = <new loid> AND pageno = 0;
>
> > INSERT INTO pg_largeobject
> >     (loid, pageno, data)
> >     (SELECT <new loid>, pageno, data
> >         FROM pg_largeobject
> >         WHERE loid = <source loid> AND pageno > 0
> >     );
>
> I believe this will work, but it requires superuser privileges to
> scribble on pg_largeobject directly.  Probably would be better to go
> through the gruntwork of creating a fully supported lo_copy() operation.
>
>             regards, tom lane
>

Thanks Tom, I was just a little worried that the page 0 record contained some
housekeeping type data that really shouldn't be copied from another page
0.

I noticed the scribbling on pg_largeobject priviledge and had created the
function with '...INVOKE AS DEFINER...' with a switch into superuser just for
that function's definition. Apart from making it more suitable for inclusion in
the main distribution, and possibly speed, I'm not sure what recoding in C
gives me given that I'm happy at the moment to do it this way. I may look into
a C version for submision later.


--
Nigel J. Andrews


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: lo_copy()
Next
From: Bruno Wolff III
Date:
Subject: Re: stored procedure