Skip site navigation (1) Skip section navigation (2)

Re: C Function returning a tuple with a float4 array as column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tim <tim(dot)child(at)comcast(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: C Function returning a tuple with a float4 array as column
Date: 2010-12-05 20:43:19
Message-ID: 200.1291581799@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
Tim <tim(dot)child(at)comcast(dot)net> writes:
> Anyone have any ideas what wrong  with my C code to return a tuple with 
> 1 column that is a float4 array. I have tested  functions returning  a 
> float4 array and a row and both  work independently. When I combine the 
>   code  I get  the SQL error

> ERROR:  cache lookup failed for type 0

I don't think that has anything directly to do with the float4 array.
You'd be well ahead of the game if you cranked up gdb to see exactly
where the error is coming from (set a breakpoint at errfinish and
backtrace from there).  But what seems likely to be the problem is that
you've declared the function to return set (that's implied by the
RETURNS TABLE syntax) but not coded it to do any such thing.  I'm
guessing some piece of code is confused by the function's failure to
follow the SRF API.

FWIW, this is backwards:

>      /**  Set up the column Datum for the Tuple **/
>      column[0] = DatumGetPointer(arrayType);

Should be PointerGetDatum.  Now generally both of those are no-op
casts, so the difference is cosmetic.  It does however suggest that
you are either compiling without warnings or ignoring the warnings,
neither of which is a path to success in dealing with C code.

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2010-12-05 21:03:28
Subject: Re: C Function returning a tuple with a float4 array as column
Previous:From: TimDate: 2010-12-05 17:52:14
Subject: C Function returning a tuple with a float4 array as column

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group