Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA28056; Mon, 28 Jun 93 02:50:11 -0700
Message-Id: <9306280950.AA28056@postgres.Berkeley.EDU>
From: Wolf Guddat <guddat@faps.uni-erlangen.de>
Subject: CURRENT
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
To: postgres@postgres.berkeley.edu
Date: Mon, 28 Jun 93 11:51:43 MESZ
Mailer: Elm [revision: 70.30]

Hi everybody,

once again a problem with Large-Objects. Now LO-Interface is working fine
but i have some problems which deal with the design of it.

My problems are the following:

All remarks about LO in the manuals seem to use the LO-Interface as a
tool to import existing data (e.g. accessing wordprocessing-files or 
something similar).

But what i want to do is to create some large data inside of postgres and write it
to an inversion-file.
The design of the Input/Output-Functions in the normal way gives me
no information (inside of my functions) about the current value of my 
attribute i'm working on.

In detail:
Imagine i want to create an adt "mytype" which can be greater than 8KBytes. OK, 
let's use the LO-Interface. Where is the data to be written to? The destination
is an Inversion-File, e.g. named LO_filename.
This is the value which is assigned to some attributes of type mytype.
OK, i have no problems assigning the LO-filename to my attributes. 
But how can i write my "real" data into this file. Using the IO-functions is  not 
possible (the parameter is mytype == pathname). Do I have to write a new 
function like "write_data" which accepts the LO_filename plus the "real" data.
This is not very nice, isn't it? 
Until now i would have to do the following:

create CLASS (inv = mytpe)
append CLASS (inv = "/LO_filename")
replace CLASS (inv = write_data ("LO_filename", "real_data_stream") )
	      where select_the_right_tuple

the design of the functions would look like this:

    mytype *mytype_in (char *)
       ^		^
       :		:----------- external representation of filename
       :---------------------------- internal rep of filename

     char *mytype_out ( mytype*)
       ^		^
       :		:----------- internal rep of filename
       :---------------------------- external rep of filename

     char *write_data (mytype*, char *)
       ^                ^         ^
       : 		:         :
       :                :         :- external rep of data
       :		:----------- internal rep of filename
       :---------------------------- external rep of filename

I'm not very happy with this solution, i think it produces too much overhead.

The problem would disappear if i had the chance to read the old attr-value (
which represents  the filename) inside of my IO-Functions (in a way 
similar to using the built-in-function of libpq: GetAttributeByName(current_tuple) ).
I didn't find a hint on this in the manuals (footnote 1). 

-- Is there a global variable like CURRENT which i can access inside of my 
dynamically-loaded ADT-functions?

footnote 1: in the "postgres reference manual" p. 82 (this is the section
about defining rules) the new and current variables are described. This seems
to be what i search for. Can i access them in my C-functions? And if so, how
can i get the information to which of the attributes in this tuple i am assigning
a value. in detail: if i write 
      append CLASS (inv = "something")
how do i know that i'm working on CLASS.inv ?
					===

So far soo good, if anyone has a hint i would be very glad to hear from him.

Bye Wolf 
