Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA14995; Fri, 25 Jun 93 02:38:12 -0700
Message-Id: <9306250938.AA14995@postgres.Berkeley.EDU>
From: Wolf Guddat <guddat@faps.uni-erlangen.de>
Subject: define operator
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
To: postgres@postgres.berkeley.edu
Date: Fri, 25 Jun 93 11:33:56 MESZ
Mailer: Elm [revision: 70.30]

Hi everybody,

I'm trying to define some operators on my adt-types. Binary operators
don't make problems, but unary do.

I think the postgres "define operator" command doesn't work
correct. 
Or am I doing something wrong?

Having written and defined an operator-adt-function called "my_func"
           MYTYPE *my_func (MYTYPE *)
i tried to define the following operator ++.

define operator ++
(arg1 = MYTYPE,
procedure = my_func
)

1.)
-- How will the backend know if it is a right-unary or a left-unary operator?
(I don't know how to tell it the backend, perhaps the reference-manual is incomplete)
Working with this operator is impossible, the backend always misses
the left operand, when i send the following query:

append I (i = ++"data"::MYTYPE)

2.)
Consulting the system-catalog pg_operator shows the mistake.
oprkind = l                  ## this means left-unary
oprleft = oid_of_my_type     ## left operand type
oprright = 0                 ## right operand type
oprresult = oid_of_my_type   ## result type

-- How can a left-unary operator have a left operand and no right operand?

3.)
Ok, then i tried this:
First i removed my operator.
Second i appended a tuple in the pg_operator catalog by my own
with oprname = "++"
     oprkind=l
     oprleft=0
     oprright=oid_of_my_type
     opr_result=oid_of_my_type
now it works fine.

4.)
Trying the same with
  oprname = "+"
don't works ("parser: syntax error at or near +", when doing an 
	     append I (i= +"data"::MYTYPE) 
            )


Has someone of you similar problems? If so i would be glad if you contact me.

Bye Wolf
