Defining input function for new datatype

From: Nick Raj <nickrajjain(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Defining input function for new datatype
Date: 2011-04-21 12:12:26
Message-ID: BANLkTimknwTEuqcQL9YqupLqS64_sz5TEw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hi,
I am defining a new data type called mpoint
i.e.
typedef struct mpoint
{
Point p;
Timestamp t;
} mpoint;

For defining input/output function

1 Datum mpoint_in(PG_FUNCTION_ARGS)
2 {
3
4 mpoint *result;
5 char *pnt=(char *)malloc (sizeof (20));
6 char *ts=(char *)malloc (sizeof (20));
7 result= (mpoint *) palloc(sizeof(mpoint));
8 char *st = PG_GETARG_CSTRING(0);
9 mpoint_decode(st,pnt,ts);
// st breaks down into pnt that corresponds to Point and ts corresponds to
Timestamp
10
11 result->p = point_in(PointerGetDatum(pnt)); //
point_in (input function for point that assigns x, y into point)
12 result-> t = timestamp_in(PointerGetDatum(ts)); // similar
for timestamp
13
14 PG_RETURN_MPOINT_P(result);
15 }

line no 11 warning: passing argument 1 of ‘point_in’ makes pointer from
integer without a cast
../../../include/utils/geo_decls.h:191: note: expected
‘FunctionCallInfo’ but argument is of type ‘unsigned int’
line no 11 error: incompatible types when assigning to type ‘Point’ from
type ‘Datum’
line no 12 warning: passing argument 1 of ‘timestamp_in’ makes pointer from
integer without a cast
../../../include/utils/timestamp.h:205: note: expected
‘FunctionCallInfo’ but argument is of type ‘unsigned int’

Can anybody figure out what kind of mistake i am doing?
Also, why it got related to 'FunctionCallInfo' ?

Thanks
Nick

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2011-04-21 12:17:27 Re: Installing PGDG on a fresh CentOS 5.6
Previous Message Vibhor Kumar 2011-04-21 11:47:12 Re: Which version of postgresql supports replication on RHEL6?

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2011-04-21 12:31:57 Re: [HACKERS] Defining input function for new datatype
Previous Message Daniel Farina 2011-04-21 11:15:48 hot backups: am I doing it wrong, or do we have a problem with pg_clog?