lo_copy()

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: lo_copy()
Date: 2003-04-01 07:29:56
Message-ID: Pine.LNX.4.21.0304010738390.2573-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Razvan 2003-04-01 08:32:25 Re: How can I save/load all triggers/stored procedures from a file?
Previous Message Ian Barwick 2003-04-01 06:00:50 Re: Newsgroups/sites for SQL questions?