Thread overview
Creating Postgresql extensions in D
Sep 06, 2020
kajaru
Sep 06, 2020
mw
Sep 06, 2020
Andre Pany
Sep 07, 2020
Laeeth Isharc
Sep 14, 2020
Denis Feklushkin
September 06, 2020
I haven't found anything except a single topic here where there's no helpful information.

Has anyone done that nowadays? Is there any simple example? Is it possible at all in D?

September 06, 2020
On Sunday, 6 September 2020 at 05:07:36 UTC, kajaru wrote:
> I haven't found anything except a single topic here where there's no helpful information.
>
> Has anyone done that nowadays? Is there any simple example? Is it possible at all in D?


Maybe the first thing to check is goto https://code.dlang.org/
and search if someone has done that already:

https://code.dlang.org/search?q=Postgresql
September 06, 2020
On Sunday, 6 September 2020 at 05:07:36 UTC, kajaru wrote:
> I haven't found anything except a single topic here where there's no helpful information.
>
> Has anyone done that nowadays? Is there any simple example? Is it possible at all in D?

As far as I understand it is easily possible. You have to translate the postgres C headers to D (I think you might  find them on code.dlang.org or use DPP to generate it yourself).

Then you have to do s.th. similiar to this example for C
https://www.percona.com/blog/2019/04/05/writing-postgresql-extensions-is-fun-c-language/

Just ask, when you have questions.

Kind regards
Andre
September 07, 2020
On Sunday, 6 September 2020 at 05:07:36 UTC, kajaru wrote:
> I haven't found anything except a single topic here where there's no helpful information.
>
> Has anyone done that nowadays? Is there any simple example? Is it possible at all in D?

Some unfinished work towards porting the git example for postgresql FDW to D.  Uses dpp but if can't handle some of the macros.  This is all I have right now.


https://gist.github.com/Laeeth/82d5b1f1c5c3b643ea718a8f24c29741


https://gist.github.com/Laeeth/c46a48fea8bb6e125c21a28c7d684020

September 14, 2020
On Sunday, 6 September 2020 at 05:07:36 UTC, kajaru wrote:
> I haven't found anything except a single topic here where there's no helpful information.
>
> Has anyone done that nowadays? Is there any simple example? Is it possible at all in D?

A bit offtopic: it might be worth find or developing a protocol for calling Postgres functions and aggregates from PG server to local external handlers. Something like WCGI but binary for local processes. This will lead to tiny well-tested loadable PG module.

This will be more safe than run custom binaries on production RDBMS.

Support of PG binary types is already implemented in https://github.com/denizzzka/dpq2