Return-Path: postarch
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA28310; Thu, 30 Jul 92 16:46:30 -0700
Message-Id: <9207302346.AA28310@postgres.Berkeley.EDU>
From: postarch (Postgres Mailing Archive)
Subject: Re: C function
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Reply-To: mer@postgres.berkeley.edu
In-Reply-To: Your message of "Tue, 28 Jul 92 21:04:48 PDT."
             <9207290404.AA06398@postgres.Berkeley.EDU> 
Date: Thu, 30 Jul 92 16:46:21 PDT

you write:

> I got an error "link failed" when I tried to define a simple C function
> and use it in POSTGRES. I noticed that there was a discussion about the 
> same problem sometimes ago. The suggested solution is to do the 
> following:
>       ld -r ..
> However, the problem was still there after I tried this.  Could someone
> tell me how to deal with the problem?

There are two other possibilities why this might be failing.  One is that
you may be using a function name that is already defined in postgres.  To
be safe you should prepend your name to the function name (be careful not
to exceed 16 characters).  The other possibility is that /tmp is filling
up.  Postgres is a fairly large binary and ld uses /tmp for its
intermediate files.

> Another question, in the example given on page 50 of the manual. A
> function GetAttributeByName() is used to get the value of an attribute,
> but the result is taken differently between 'salary' and 'age', the
> former is an address while the later is a value, how can I explain
> this situation?

Each type instance has a boolean attribute called typbyval.  When this
is false you are dealing with pointers, otherwise you have the data in
your hands.  In general if the type length is <= sizeof (char *) it will
be 'by value'.  One exception is float4.


Jeff Meredith
mer@postgres.berkeley.edu
