Subject: Large Objects

From: Gunter Strube <[email-masked]>
Date: Fri, 20 Aug 1993 14:52:26 +0200

Hi,

I've been trying to work with Large_Objects in Postgres for quite a
while now, trying to store or access them either from the monitor
or via LIBPQ.
Even though I've tried it in about a thousand different versions
it doesn't seem to work right. The documentation in Manual Section 7 
is rather poor and the Example doesn't work either.

The closest I could get was that the some writing access was done to
"pg_largre_object" but the attemt to read it out failed.

A frequent error message was after the command:
	inv_fd = p_open("/inv_file2", INV_WRITE, Inversion);

	Error: Unexpected identifier: ?

so before I describe the whole mess in more detail:

1. Does anybody have experience with large objects who can explain
   the access via LIBPQ or via the monitor.

2. Can anybody send me some example-programms for storing data in
   large objects (in Unix as well as in in Inversion files).

Thanks in advance
 Gunter
-- 
------------------------------------------------------------------------
Gunter Strube                                 Phone +49 89 551 743-74 
Institute of Electronic Design Automation    
Prof. Dr.-Ing. K. Antreich               
Technical University of Munich          
P.O. Box 202420                        
W-80290 Munich 2                 
Germany                            [email-masked]
------------------------------------------------------------------------

---

From: [email-masked] (Paul M. Aoki)
Date: Sun, 22 Aug 93 17:13:17 -0700

> 	Error: Unexpected identifier: ?

this means the backend dumped core (or was never invoked).  the 
arguments you give are appropriate for p_creat, which must be called 
before p_open is called.  as far as i can tell this was correctly 
documented in 4.1..

>    large objects (in Unix as well as in in Inversion files).

the inversion file system utilities (especially icopy) contain
lots of uses of large objects.. look in src/bin/fsutils.

changing icopy to use unix/inversion large objects is pretty simple. 
only two lines must be changed:

593c593
<     if ((destfd = p_creat(destfname, 0666, Unix)) < 0) {
---
>     if ((destfd = p_creat(destfname, INV_WRITE|smgrno, Inversion)) < 0) {
670c670
<     if ((srcfd = p_open(srcfname, O_RDONLY)) < 0) {
---
>     if ((srcfd = p_open(srcfname, INV_READ)) < 0) {

(the line numbers are approximate since they come from our development
source code, not 4.1.)
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  [email-masked]
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki