Re: lo_copy() - Mailing list pgsql-general

From Tom Lane
Subject Re: lo_copy()
Date
Msg-id 782.1049210127@sss.pgh.pa.us
Whole thread Raw
In response to lo_copy()  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
Responses Re: lo_copy()  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
List pgsql-general
"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


pgsql-general by date:

Previous
From: Marc Drouin
Date:
Subject: Trigger functions
Next
From: "Nigel J. Andrews"
Date:
Subject: Re: lo_copy()