Dear Sir: I have tried to create a new Type in postgreSQL-7.2. The example is defined in Chapter 39 of extended type. We do follow your defination of "Complex" completely.But there is always an error:
I entered : CREATE TYPE complex(INPUT=complex_in,OUTPUT=complex_out(Complex),INTERNALLENGTH=16);
but it shows ERROR: parser:parse error at or near '(' ".
Could you please give me a comprehensible explanation. I
expect to hear from you!
Thank you very much!
PS: our source code is in attachment
#include "stdio.h" #include "/usr/local/src/pgsql/src/include/postgres.h"
typedef struct Complex{ double x; double y; }Complex; Complex *complex_in(char *str) { double x,y; Complex *result; if(sscanf(str,"(%lf,%lf)",&x,&y)!=2) { elog(WARN,"complex_in error") return NULL; } result=(Complex *)palloc(sizeof(Complex)); result->x=x; result->y=y; return(result);} char *complex_out(Complex *complex) { char *result; if(complex==NULL) return(null); sprintf(result,"(%g,%g)",complex->x,complex->y); return(result); }
---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])