Re: C function to return double precision[][] - Mailing list pgsql-hackers

From Joe Conway
Subject Re: C function to return double precision[][]
Date
Msg-id 714e6e48-1ad0-9172-2731-9682e0266dc7@joeconway.com
Whole thread Raw
In response to C function to return double precision[][]  (Markur Sens <markursens@gmail.com>)
List pgsql-hackers
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




pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Optimize Arm64 crc32 implementation in PostgreSQL
Next
From: Robert Haas
Date:
Subject: Re: should frontend tools use syncfs() ?