Thread: C function to return double precision[][]

C function to return double precision[][]

From
Markur Sens
Date:
Is there any piece of code I could see how to achieve $subject ?
I haven’t found anything in the standard library or contrib modules.

I’m trying to build ArrayType ** of sorts and return a Datum of those but I can’t seem to manage memory correctly.






Re: C function to return double precision[][]

From
Joe Conway
Date:
On 8/21/23 15:31, Markur Sens wrote:
> Is there any piece of code I could see how to achieve $subject ?
> I haven’t found anything in the standard library or contrib modules.
> 
> I’m trying to build ArrayType ** of sorts and return a Datum of those but I can’t seem to manage memory correctly.

There is an example in PL/R here:

https://github.com/postgres-plr/plr/blob/20a1f133bcf2bc8f37ac23da191aea590d612619/pg_conversion.c#L1275

which points to here with number of dims == 2:

https://github.com/postgres-plr/plr/blob/20a1f133bcf2bc8f37ac23da191aea590d612619/pg_conversion.c#L1493

This is all generic to the element type (i.e. not specifically float8), 
but the needed type conversion stuff happens in here:

https://github.com/postgres-plr/plr/blob/20a1f133bcf2bc8f37ac23da191aea590d612619/plr.c#L1109

HTH,

-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com