dbTalk Databases Forums  

[BUGS] about create type

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] about create type in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
zhuangjifeng
 
Posts: n/a

Default [BUGS] about create type - 08-29-2003 , 02:54 PM






This is a multi-part message in MIME format.
--------------000206060204080909020502
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

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(Comple x),INTERNALLENGTH=16);

but it shows
ERROR: parserarse 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

--------------000206060204080909020502
Content-Type: text/plain;
name="complex.c~"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="complex.c~"

#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);
}

--------------000206060204080909020502
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)

--------------000206060204080909020502--


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] about create type - 08-29-2003 , 03:25 PM






zhuangjifeng <zhuangjifeng (AT) 263 (DOT) net> writes:
Quote:
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:

CREATE TYPE
complex(INPUT=complex_in,OUTPUT=complex_out(Comple x),INTERNALLENGTH=16);
ERROR: parserarse error at or near '(' ".
You should not put parameters with the input/output function names.
(I'm pretty sure that none of our documentation suggests you should.)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.