Re: CStringGetTextDatum and other conversions in server-side code

From: "David Bennett" <davidb(at)pfxcorp(dot)com>
To: <pgsql-general-owner+M220397=david=andl(dot)org(at)postgresql(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: CStringGetTextDatum and other conversions in server-side code
Date: 2016-03-03 10:35:58
Message-ID: 000d01d17538$7bcee4f0$736caed0$@pfxcorp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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, period. I can handle UTF8/16/32 as long as I know which.

single and double real/floats are stored in standard x86 IEEE floating point.
[dmb>] Apart from the x86/x64 oddity that seems easy enough (I'm using x64).

the date and time types are all fixed lengths, mostly a long int or two.
[dmb>] Again, I just need a function to convert to and from one single date/time format that covers everything. I use 2xint64 and no TZ. It covers year 9999 down to milliseconds and then some.

numeric in postgres is a bit tricky. its a decimal number stored in
base 10000 as a series of short integers, and can represent. does your
language even have a decimal or BCD or something numeric type?
[dmb>] Of course. I have decimal which is also 2xint64: it equates to about 28 digits. For business purposes I think that's enough, but I may go for something bigger in future. Most likely the simplest solution will be to use string as an intermediate.

[dmb>] The point is that none of my code is in C, so I can't get Postgres macros or data types and my conversion routines into the same scope. That's why I'm looking for basic routines that support basic C data types as the go between, so I don't have to write too much C code.

Regards
David M Bennett FACS

Andl - A New Database Language - andl.org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message david 2016-03-03 10:42:04 Re: CStringGetTextDatum and other conversions in server-side code
Previous Message schoetbi 2016-03-03 08:31:04 Re: pg_upgrade 9.5.1: pg_upgrade_support missing