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

From: Joe Conway <mail(at)joeconway(dot)com>
To: Markur Sens <markursens(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: C function to return double precision[][]
Date: 2023-08-21 20:04:53
Message-ID: 714e6e48-1ad0-9172-2731-9682e0266dc7@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-08-21 20:08:46 Re: should frontend tools use syncfs() ?
Previous Message Nathan Bossart 2023-08-21 20:04:46 Re: Optimize Arm64 crc32 implementation in PostgreSQL