Re: [GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-04 Thread David Bennett
all the text types are simply a 32bit length and an array of characters. you need to be aware of the encoding, and null is just another character. [dmb>] Yes, I can see that. What I need is a function that will convert to and from whatever the actual encoding happens to be into Unicode,

Re: [GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-03 Thread david
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

Re: [GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-03 Thread david
all the text types are simply a 32bit length and an array of characters. you need to be aware of the encoding, and null is just another character. [dmb>] Yes, I can see that. What I need is a function that will convert to and from whatever the actual encoding happens to be into Unicode,

Re: [GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-02 Thread John R Pierce
On 3/2/2016 9:36 PM, da...@andl.org wrote: [dmb>] This is fairly easy for ints and reals, but is particularly a problem for all the variable length types (eg text, time and decimal). all the text types are simply a 32bit length and an array of characters. you need to be aware of the

Re: [GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-02 Thread david
> [dmb>] So how would I go about finding a set of useful conversion functions > for basic types (real, decimal, time, etc)? the basic SQL to C mappings are defined by the H files listed here, http://www.postgresql.org/docs/current/static/xfunc-c.html#XFUNC-C-TYPE-TABLE [dmb>] [dmb>] Yes,

Re: [GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-02 Thread Joe Conway
On 03/02/2016 04:20 PM, da...@andl.org wrote: > (please do not post HTML to these lists; see: > https://wiki.postgresql.org/wiki/Mailing_Lists) > [dmb>] I checked the list first: it looks like about 25-50% HTML. > Happy to oblige, but I think you've got your work cut out. Understood, but you

Re: [GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-02 Thread John R Pierce
On 3/2/2016 4:20 PM, da...@andl.org wrote: [dmb>] So how would I go about finding a set of useful conversion functions for basic types (real, decimal, time, etc)? the basic SQL to C mappings are defined by the H files listed here,

Re: [GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-02 Thread david
(please do not post HTML to these lists; see: https://wiki.postgresql.org/wiki/Mailing_Lists) [dmb>] I checked the list first: it looks like about 25-50% HTML. Happy to oblige, but I think you've got your work cut out. > and looks like it might work. Questions: > > 1. Is this the right

Re: [GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-02 Thread Joe Conway
(please do not post HTML to these lists; see: https://wiki.postgresql.org/wiki/Mailing_Lists) On 03/02/2016 03:06 PM, da...@andl.org wrote: > Writing a language handler: pl_language_handler. Need to do a variety of > data conversions. One of them is char* C-string to and from Text/Varchar. > >

[GENERAL] CStringGetTextDatum and other conversions in server-side code

2016-03-02 Thread david
Writing a language handler: pl_language_handler. Need to do a variety of data conversions. One of them is char* C-string to and from Text/Varchar. The include file postgres.h has the macro CStringGetDatum but this is of no use: it’s just a cast. There is a builtin macro