Return-Path: owner-postman
Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.9/8.6.3) with SMTP id LAA07273 for postgres-redist; Tue, 6 Sep 1994 11:35:23 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199409061835.LAA07273@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from crseo.ucsb.edu (eos.crseo.ucsb.edu [128.111.100.50]) by nobozo.CS.Berkeley.EDU (8.6.9/8.6.3) with SMTP id LAA07263 for <postgres@nobozo.CS.Berkeley.EDU>; Tue, 6 Sep 1994 11:35:18 -0700
From: jimbo@crseo.ucsb.edu
Received: from scorpii.s2k.ucsb.edu (scorpii.crseo.ucsb.edu) by  crseo.ucsb.edu (4.1/SMI-4.4-Crseo Special)
	id AA29919; Tue, 6 Sep 94 11:35:12 PDT
Received: from localhost by scorpii.s2k.ucsb.edu (5.65/Crseo-Client-2.0)
	id AA21634; Tue, 6 Sep 1994 11:35:12 -0700
Message-Id: <9409061835.AA21634@scorpii.s2k.ucsb.edu>
To: raj@CS.UCLA.EDU (Raj Vadakkencherry)
Cc: postgres@postgres.Berkeley.EDU, jimbo@crseo.ucsb.edu
Subject: Re: Examples on Large Objects 
In-Reply-To: Your message of "Tue, 06 Sep 94 10:45:22 PDT."
             <9409061745.AA20754@oahu.cs.ucla.edu> 
Date: Tue, 06 Sep 94 11:35:11 -0700
Resent-To: postgres-redist@postgres.Berkeley.EDU
X-Mts: smtp
Resent-Date: Tue, 06 Sep 94 11:35:23 -0700
Resent-XMts: smtp


>Hi,
>
> Do you have source code examples for creating and using large objects
> from Unix files ? The ...src/bin/fsutils directory contains only an example
> for inversion large object.



Hello,


If you're familiar with Tcl you can use libpqtcl to manipulate Unix
large objects in a script.  Here's an example:


#
# test libpqtcl's large object interface
#

# copy /etc/motd to a new large object
set lo [PQlo open junk w+]
set fp [open /etc/motd]
PQlo copyin $fp $lo
close $fp

# copy the data back out to stdout
PQlo seek $lo 0
PQlo copyout $lo stdout

# now stat the large object and print the statbuf array to stdout
PQlo stat junk statBuf
parray statBuf

# dump a listing of files at the LO root to stdout
puts stdout [PQlo glob *]

# make a new directory and move the large object there
PQlo mkdir mydir
PQlo cd mydir
PQlo rename /junk /mydir/junk

# delete the large object and directory
PQlo unlink junk
PQlo cd /
PQlo rmdir mydir



Libpqtcl can be included in any Tcl or Tk application.  You can get it
at:

ftp://ftp.crseo.ucsb.edu/pub/libpqtcl.tar.Z



-Jim

 __________________________________________________________
  Jim Davidson                     |  jimbo@crseo.ucsb.edu
  CSL / Center for Remote Sensing  |  jimbo@sbitp.bitnet
  University of California         |  Phone (805)893-8475
  Santa Barbara, CA 93106          |  Fax           -2578

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
