From: | <david(at)andl(dot)org> |
---|---|
To: | <pgsql-general-owner+M220387=david=andl(dot)org(at)postgresql(dot)org> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: CStringGetTextDatum and other conversions in server-side code |
Date: | 2016-03-03 10:59:43 |
Message-ID: | 001c01d1753b$cd98d2c0$68ca7840$@andl.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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 more about 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 references both. 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 Postgres does 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 data types. [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 an encoding and I need Unicode. Decimal and time are proprietary formats of some kind, which I would prefer not to have to access 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 these conversions that have me stuck.
Regards
David M Bennett FACS
Andl - A New Database Language - andl.org
From | Date | Subject | |
---|---|---|---|
Next Message | Premsun Choltanwanich | 2016-03-03 11:53:05 | Re: could not migrate 8.0.13 database with large object data to 9.5.1 |
Previous Message | david | 2016-03-03 10:42:04 | Re: CStringGetTextDatum and other conversions in server-side code |