lo_copy() - Mailing list pgsql-general

From Nigel J. Andrews
Subject lo_copy()
Date
Msg-id Pine.LNX.4.21.0304010738390.2573-100000@ponder.fairway2k.co.uk
Whole thread Raw
Responses Re: lo_copy()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general

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
    );


It does seem to work but I wouldn't like to swear it's safe, hence this
posting.

I was originally looking for a newoid() function to use, then thought about
wrapping my own seeing as there wasn't one but then spotted there were some lo_
functions available. Therefore, lo_creat() I'm really just using to grab a new
oid for the new large object.


--
Nigel J. Andrews


pgsql-general by date:

Previous
From: Ian Barwick
Date:
Subject: Re: Newsgroups/sites for SQL questions?
Next
From: Thomas Kellerer
Date:
Subject: Re: How can I save/load all triggers/stored procedures from a file?