FWIW here are examples from PL/R for incoming (argument) and outgoing
(result) conversions of scalar values:
https://github.com/jconway/plr/blob/master/pg_conversion.c#L632
https://github.com/jconway/plr/blob/master/pg_conversion.c#L1002
That same file also has routines for conversions of more complex data types.
[dmb>]
[dmb>] Thank you for the links. Obviously you've put a lot of effort into this work, and equally obviously you know far
moreabout this than I do. But I think the problem I face is a little different.
This code shows a programming environment in which both the Postgres and R declarations are in scope, and the code
referencesboth. I can't do that. I don't have any C code or any C API that I can bring into a Postgres scope, and
Postgresdoes not provide a 'pure' C API that can be referenced from another language.
So what I'm trying to do is to write that 'pure' interface, using a thin layer of C and a chosen set of intermediate
datatypes. [Take a look at https://www.sqlite.org/c3ref/funclist.html to see what I mean by a pure interface.]
For the fixed types, the Datum format is simple enough, but the variable types are much harder. Text comes as char with
anencoding and I need Unicode. Decimal and time are proprietary formats of some kind, which I would prefer not to have
toaccess directly. And so on.
I'm making progress, but it's slow. I've got everything else working: SPI queries, decoding tuples, etc. It's just
theseconversions that have me stuck.
Regards
David M Bennett FACS
Andl - A New Database Language - andl.org