Return-Path: postman 
Delivery-Date: Mon, 20 Sep 93 02:35:07 PDT
Return-Path: postman
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA18608; Mon, 20 Sep 93 02:31:33 -0700
Resent-From: postman (POSTGRES mailing list)
Resent-Message-Id: <9309200931.AA18608@postgres.Berkeley.EDU>
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: guddat@faps.uni-erlangen.de
Received: from faui45.informatik.uni-erlangen.de by postgres.Berkeley.EDU (5.61/1.29)
	id AA18600; Mon, 20 Sep 93 02:31:23 -0700
Received: from behaim.faps.uni-erlangen.de by uni-erlangen.de with SMTP;
	id AA28437 (5.65c-5/7.3v-FAU); Mon, 20 Sep 1993 11:32:17 +0200
Received: from faber.faps.uni-erlangen.de by faps.uni-erlangen.de with SMTP;
	id AA19250 (16.8/7.3s-FAU); Mon, 20 Sep 93 11:34:29 +0200
From: Wolf Guddat <guddat@faps.uni-erlangen.de>
Message-Id: <9309200934.AA19250@behaim.faps.uni-erlangen.de>
Subject: operators and brackets
To: postgres@postgres.berkeley.edu
Date: Mon, 20 Sep 93 11:36:18 MESZ
Mailer: Elm [revision: 70.30]
Resent-To: postgres-dist
Resent-Date: Mon, 20 Sep 93 02:31:32 PDT

Hi everybody,

I've got a problem in using operators.
I defined my ADT XPR_NUMBER, with inout-functions as usual.
After that i defined a lot of binary operators. 
Testing them all alone shows no errors, but when i try to build more
complex expression they produce a "parser syntax error"

/***** This is how i defined the *****/
define function xpr_nn_mult (language="c", returntype=XPR_NUMBER, trusted=t
			    ) 
			    arg is (XPR_NUMBER, XPR_NUMBER) 
			    as "/user/sonst/wfguddat/XPR2PG/num_op.o"\g
define function xpr_nn_quot (language="c", returntype=XPR_NUMBER, trusted=t
			    ) 
			    arg is (XPR_NUMBER, XPR_NUMBER) 
			    as "/user/sonst/wfguddat/XPR2PG/num_op.o"\g
define function xpr_nn_add  (language="c", returntype=XPR_NUMBER, trusted=t
			    ) 
			    arg is (XPR_NUMBER, XPR_NUMBER) 
			    as "/user/sonst/wfguddat/XPR2PG/num_op.o"\g
define function xpr_nn_sub  (language="c", returntype=XPR_NUMBER, trusted=t
			    )
                            arg is (XPR_NUMBER, XPR_NUMBER)
                            as "/user/sonst/wfguddat/XPR2PG/num_op.o"\g
define operator * (arg1 = XPR_NUMBER, 
		   arg2 = XPR_NUMBER, 
		   procedure = xpr_nn_mult)\g
define operator / (arg1 = XPR_NUMBER, 
                   arg2 = XPR_NUMBER, 
                   procedure = xpr_nn_quot)\g
define operator ++ (arg1 = XPR_NUMBER, 
		    arg2 = XPR_NUMBER, 
		    procedure = xpr_nn_add)\g

define operator -- (arg1 = XPR_NUMBER, 
		    arg2 = XPR_NUMBER, 
		    procedure = xpr_nn_sub)\g

/***** This are the commands which produce an error *****/
create N (n=XPR_NUMBER)/g
append N (n = "3.0"::XPR_NUMBER ++ "2.0"::XPR_NUMBER / "5.0"::XPR_NUMBER)\g
append N (n = "3.0"::XPR_NUMBER -- "2.0"::XPR_NUMBER ++ "5.0"::XPR_NUMBER)\g

    The second append produces the following monitor error-statement:

    *
    Query sent to backend is "append N (n = "3.0"::XPR_NUMBER -- "2.0"::XPR_NUMBER ++ "5.0"::XPR_NUMBER)"
    WARN:Sep 20 10:46:01:parser: syntax error at or near "++"
   
But if i put the first operation into brackets the message disappears:

append N (n = ("3.0"::XPR_NUMBER -- "2.0"::XPR_NUMBER) ++ "5.0"::XPR_NUMBER)\g


My Question is: Why is the first append OK and the second not? Do I always
                have to use selfdefined operators with brackets?


Thanks for all help. Wolf

****************************************************
**                                                **
** Wolf Guddat, guddat@faber.faps.uni-erlangen.de **
**                                                **
**       University of Erlangen/Nuernberg         **
**                     Germany                    **
**                                                **
**     Postgres 4.1, DECstation, ULTRIX 4.3       **
**                                                **
****************************************************
