agora inbox for postgres@postgres.berkeley.edu
help / color / mirror / Atom feedFrom: J.Plewe <joerg.plewe@mpi-dortmund.mpg.de>
To: postgres@postgres.Berkeley.EDU
Subject: operators
Date: Thu, 30 Jun 94 13:23:50 +0200
Message-ID: <9406301123.AA02722@gs.mpi-dortmund.mpg.de> (raw)
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.
==============================================================================
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: postgres@postgres.berkeley.edu
Cc: joerg.plewe@mpi-dortmund.mpg.de
Subject: Re: operators
In-Reply-To: <9406301123.AA02722@gs.mpi-dortmund.mpg.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox