about create type - Mailing list pgsql-bugs

From zhuangjifeng
Subject about create type
Date
Msg-id 3F4EC6C0.7080007@263.net
Whole thread Raw
Responses Re: about create type  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
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);
}

pgsql-bugs by date:

Previous
From: Karthik K S
Date:
Subject: True64 Unix v5.1 - postgresql-7.2.4 compilation problem
Next
From: Tom Lane
Date:
Subject: Re: about create type