Subject: Empty 'append', Tuple functions, user-defined indices

From: [email-masked] (Wolf-D. Ihlenfeldt)
Date: Tue, 11 May 93 00:37:12 -0700

Postgres 4.1 on SparcII

My application sometimes needs to append an empty record
(no props set) just in order to get an oid which is later used
as access key in replace operations.

However, postquel statements like 

append zz ()

or

append zz

result in syntax errors - this also follows from the documentation.
Is there any way to append an empty record ? I typically do not
know the fields of the class in advance, so I cannot simply store
some NULL value in a known field. Querying the database for the fields
takes too long.

Thanks for your help.

WDI

---
Another problem with functions on tuples:
The function declaration seems to need the name of a specific
class as input argument. However, I need to have functions
on similar, but not identical classes. Is there a way to 
make the tuple parameter generic, i.e. the function should be
able to determine with GetAttributeByName() calls whether all
needed fields are actually available and probably use some 
default values if not. In the current syntax such a function
seems to be limited to a specific class with a precisely defined
name. As far as I understand, such a function cannot even be
generically specified for an identical class (same attributes,
other name). Looking into the code of GetAttributeByName(), I
find that the function calls elog() if the attribute is not
present - which is a BadThing. I prefer a silent, non-abortive
return code. Am I overlooking something, or am I experiencing
some awkward built-in limitations ?

WDI
---

Various documentation issues which might be helpful:

a) DEFINE FUNCTION`

  ,trusted   must be  ,trusted=t  or ,trusted=f

b) DEFINE TYPE

  the second 'externallength' should be 'internallength'

c) User-defined index types (appendix)

The btree oid is initially retrieved as 403, but the
later examples assume the value 400.

The example (absolute int4 values) is incomplete.
The necessary pg_amproc entry is not mentioned.
(Thanks for the responses of the
user community to this question when I was lost!!!) 
You need an entry in pg_amproc analog to 

append pg_amproc
   ( amid = "%btree_oid"::oid,
     amopclaid = "%opc_oid"::oid,
     amproc = "%cfunc_oid"::oid,
     amprocnum = "1"::int2)
 
(The %-strings are placeholders the the oid of the btree
index method from pg_am, the opclass oid from pg_opclass,
the support function oid from pg_proc.)

The support function (taking two values of the indexed type
as input, returning -1,0 or 1 for smaller/equal/larger) is also
not clearly mentioned and missing in the example setup. It must
be defined similar to 

define function int4_abs_cmp (language = "c", returntype = int4,
   trusted=t)
   arg is (int4,int4) as "/home2/wolf/WB/PG/pg_absint4.o"
 
(if you use the 'trusted' argument, note the '=t')

WDI