Thread: large objects in 7.3

large objects in 7.3

From
"Dick Wieland"
Date:

I have a few questions about “large objects” in postreSQL 7.3 .

 

I see from the documentation that

(1) there is a table name pg_largeobject that seems to be the place where large objects are stored.

(2) Likewise there are psql commands (lo_list, lo_import, lo_export, lo_unlink) … lo_list seems to work,

  but the others require some parameters, the format of which is not documented)

(2) there is an example where server side built-in functions are used to apparently do 2 things

            (a) import a large object into pg_largeobject, and assign it an loid

            (b) and then insert that loid into the oid column in table “image”

CREATE TABLE image (
     name            text,
     raster          oid
 );
 
 INSERT INTO image (name, raster)
     VALUES ('beautiful image', lo_import('/etc/motd'));
 
 SELECT lo_export(image.raster, '/tmp/motd') FROM image
     WHERE name = 'beautiful image';

 

One question is …

            is this actually what’s going on (can’t find any other documentation) ?

 

another question is … how does one use \lo_import in psql?

 

and finally

            the test program does not run on a remote database. Is there any way to manipulate large objects

(import, export, read, write, etc.) on a remote database?

 

Thanks,

Dick Wieland

---

 

Re: large objects in 7.3

From
Tom Lane
Date:
"Dick Wieland" <dick.wieland@wiline.com> writes:
> another question is . how does one use \lo_import in psql?

See the psql man page, about halfway down --- the \lo_xxx commands are
in alphabetical order along with the other backslash commands, under
the heading "Meta-Commands".

> and finally
>             the test program does not run on a remote database.

It would if you ran it as postgres superuser ;-).  But realistically you
probably want to import/export files to your own filesystem, not the
server's filesystem.  For this you want client-side operations ---
either psql's \lo_xxx commands, or the libpq large-object functions they
are built upon.

            regards, tom lane