Re: [HACKERS] C function to return tuple

2010-09-26 Thread Marios Vodas
Do you think it would be better to change d_type to this? CREATE TYPE d_type AS ( xi double precision, yi double precision, xe double precision, ye double precision, id integer ); *Note: This is NOT something I want to do but if there is no other way to form d_type tuple from the variables...* O

Re: [HACKERS] C function to return tuple

2010-09-26 Thread Marios Vodas
Suppose I had the data that form the returning tuple in 5 variables like this: float8 xi = 1; float8 yi = 2; float8 xe = 3; float8 ye = 4; int32 id = 1; In addition the function wouldn't have any input parameters. It just returns a tuple of type d_type. Can you tell me how it is possible to form t

Re: [HACKERS] C function to return tuple

2010-09-26 Thread Tom Lane
Marios Vodas writes: > //I need to get this working > *values[0] = e;* > *values[1] = i;* Maybe you're missing HeapTupleGetDatum() there? Just from a data type cleanliness standpoint, you shouldn't ever assign something to Datum or vice versa without applying the correct conversion macro

Re: [HACKERS] C function to return tuple

2010-09-26 Thread Marios Vodas
I see what you mean and I changed the code BUT still my main problem is that I want to know how to fill values array. I remind you that d_type contains attributes of another composite type p_type. I need a solution to that because I need to use it in other parts of the code. Datum d_swap(PG_FUNCTI

Re: [HACKERS] C function to return tuple

2010-09-26 Thread Tom Lane
Marios Vodas writes: > My problem is that I don't know how to construct the d_type tuple in the c > function. Seems like the main problem with that function is that you're passing an uninitialized "nulls" array to heap_form_tuple. I kinda wonder why you are using a fixed-length values array toge

[HACKERS] C function to return tuple

2010-09-26 Thread Marios Vodas
I have these types: CREATE TYPE p_type AS ( x double precision, y double precision ); CREATE TYPE d_type AS ( i p_type, e p_type, id integer ); CREATE OR REPLACE FUNCTION d_swap(d_type) RETURNS d_type AS '/home/user/PostgreSQL/9.0/lib/mylib','d_swap' LANGUAGE C STRICT; My problem is that I do