Return-Path: owner-postman
Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id EAA17424 for postgres-redist; Thu, 30 Jun 1994 04:24:47 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199406301124.EAA17424@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from ks.mpi-dortmund.mpg.de (ks.mpi-dortmund.mpg.de [141.5.68.16]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id EAA17414 for <postgres@postgres.berkeley.edu>; Thu, 30 Jun 1994 04:24:37 -0700
Received: from gs.mpi-dortmund.mpg.de by ks.mpi-dortmund.mpg.de (4.1/SMI-4.1MHS-mpi-1.4.93)
	id AA24625; Thu, 30 Jun 94 13:24:02 +0200
Received: by gs.mpi-dortmund.mpg.de (4.1/SMI-4.1-mpi-30.3.93)
	id AA02722; Thu, 30 Jun 94 13:23:50 +0200
Date: Thu, 30 Jun 94 13:23:50 +0200
From: joerg.plewe@mpi-dortmund.mpg.de (J.Plewe)
Message-Id: <9406301123.AA02722@gs.mpi-dortmund.mpg.de>
To: postgres@postgres.Berkeley.EDU
Subject: operators
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Thu, 30 Jun 94 04:24:47 -0700
Resent-XMts: smtp

I have defined a function to concatenate text-values 
in order to be abel to construct strings in the output:


  #define TEXT2CHAR(t,c) { strncpy(c,VARDATA(t),VARSIZE(t)-VARHDRSZ); \
  	c[VARSIZE(t)-VARHDRSZ] = '\0'; }


  text *textcat(text1,text2)
  text *text1, *text2;
  {
    text *res;
    char resbuf[512];
    char t2[256];

    TEXT2CHAR(text1,resbuf);
    TEXT2CHAR(text2,t2);

    strcat(resbuf,t2);
    res = (text*)palloc(strlen(resbuf) + VARHDRSZ + 1);

    VARSIZE(res) = strlen(resbuf) + VARHDRSZ;
    strcpy(VARDATA(res), resbuf);

    return res;
  }


------------------------------------------------------------------

  define function textcat( language="C",
                          returntype=text)
    arg is (text, text)
    as "/work/plewe/vis/mvd_connect.o"
  \g


  define operator $+ (
          arg1 = text,
          arg2 = text,
          procedure = textcat,
          associativity = any
          )
  \g      

------------------------------------------------------------------


So now I'm able to write:

  retrieve (x="Hello" $+ " world")


What I want to have work is:

  retrieve (x="Hello" $+ " world," $+ " what's on?")
  WARN:Jun 30 11:19:39:parser: syntax error at or near "$+"


I can help myself using brackets:

  Go 
  * retrieve (x=("Hello" $+ " world,") $+ " what's on?") \g

  Query sent to backend is "retrieve (x=("Hello" $+ " world,") $+ " what's on?")   "
  ---------------
  | x           |
  ---------------
  | Hello world, what's on?|
  ---------------


How do I have to define the operator '$+' to work like '+' does?
I admit that I do not understand the meanings of all the options of 
'define operator'.


Thank you,

- Joerg







==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
